77 |
} |
} |
78 |
#endif |
#endif |
79 |
|
|
80 |
|
|
81 |
|
// All winsock apps needs this. |
82 |
|
#if defined(WIN32) |
83 |
|
static WSADATA _wsaData; |
84 |
|
#endif |
85 |
|
|
86 |
|
|
87 |
|
namespace QSampler { |
88 |
|
|
89 |
// Timer constant stuff. |
// Timer constant stuff. |
90 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
91 |
|
|
96 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
97 |
|
|
98 |
|
|
|
// All winsock apps needs this. |
|
|
#if defined(WIN32) |
|
|
static WSADATA _wsaData; |
|
|
#endif |
|
|
|
|
|
|
|
99 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
100 |
// qsamplerCustomEvent -- specialty for callback comunication. |
// CustomEvent -- specialty for callback comunication. |
101 |
|
|
102 |
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
103 |
|
|
104 |
class qsamplerCustomEvent : public QEvent |
class CustomEvent : public QEvent |
105 |
{ |
{ |
106 |
public: |
public: |
107 |
|
|
108 |
// Constructor. |
// Constructor. |
109 |
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
CustomEvent(lscp_event_t event, const char *pchData, int cchData) |
110 |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
111 |
{ |
{ |
112 |
m_event = event; |
m_event = event; |
129 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
130 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
131 |
|
|
|
namespace QSampler { |
|
|
|
|
132 |
// Kind of singleton reference. |
// Kind of singleton reference. |
133 |
MainForm* MainForm::g_pMainForm = NULL; |
MainForm* MainForm::g_pMainForm = NULL; |
134 |
|
|
367 |
|
|
368 |
|
|
369 |
// Make and set a proper setup options step. |
// Make and set a proper setup options step. |
370 |
void MainForm::setup ( qsamplerOptions *pOptions ) |
void MainForm::setup ( Options *pOptions ) |
371 |
{ |
{ |
372 |
// We got options? |
// We got options? |
373 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
383 |
if (m_pOptions->bKeepOnTop) |
if (m_pOptions->bKeepOnTop) |
384 |
wflags |= Qt::Tool; |
wflags |= Qt::Tool; |
385 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
386 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new Messages(this); |
387 |
m_pDeviceForm = new DeviceForm(this, wflags); |
m_pDeviceForm = new DeviceForm(this, wflags); |
388 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
389 |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
m_pInstrumentListForm = new InstrumentListForm(this, wflags); |
471 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
472 |
m_pDeviceForm->close(); |
m_pDeviceForm->close(); |
473 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
474 |
stopServer(); |
stopServer(true /*interactive*/); |
475 |
} |
} |
476 |
} |
} |
477 |
|
|
512 |
QListIterator<QUrl> iter(pMimeData->urls()); |
QListIterator<QUrl> iter(pMimeData->urls()); |
513 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
514 |
const QString& sPath = iter.next().toLocalFile(); |
const QString& sPath = iter.next().toLocalFile(); |
515 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
if (Channel::isInstrumentFile(sPath)) { |
516 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
517 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
518 |
if (pChannel == NULL) |
if (pChannel == NULL) |
519 |
return; |
return; |
520 |
// Start setting the instrument filename... |
// Start setting the instrument filename... |
550 |
{ |
{ |
551 |
// For the time being, just pump it to messages. |
// For the time being, just pump it to messages. |
552 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
553 |
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent); |
554 |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
switch (pEvent->event()) { |
555 |
int iChannelID = pEvent->data().toInt(); |
case LSCP_EVENT_CHANNEL_INFO: { |
556 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
int iChannelID = pEvent->data().toInt(); |
557 |
if (pChannelStrip) |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
558 |
channelStripChanged(pChannelStrip); |
if (pChannelStrip) |
559 |
} else { |
channelStripChanged(pChannelStrip); |
560 |
appendMessagesColor(tr("Notify event: %1 data: %2") |
break; |
561 |
.arg(::lscp_event_to_text(pEvent->event())) |
} |
562 |
.arg(pEvent->data()), "#996699"); |
#if CONFIG_LSCP_CHANNEL_MIDI |
563 |
|
case LSCP_EVENT_CHANNEL_MIDI: { |
564 |
|
int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
565 |
|
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
566 |
|
if (pChannelStrip) |
567 |
|
pChannelStrip->midiArrived(); |
568 |
|
break; |
569 |
|
} |
570 |
|
#endif |
571 |
|
default: |
572 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
573 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
574 |
|
.arg(pEvent->data()), "#996699"); |
575 |
} |
} |
576 |
} |
} |
577 |
} |
} |
589 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
590 |
|
|
591 |
// The global options settings property. |
// The global options settings property. |
592 |
qsamplerOptions *MainForm::options (void) const |
Options *MainForm::options (void) const |
593 |
{ |
{ |
594 |
return m_pOptions; |
return m_pOptions; |
595 |
} |
} |
750 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
751 |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
752 |
if (pChannelStrip) { |
if (pChannelStrip) { |
753 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
754 |
if (bForce && pChannel) |
if (bForce && pChannel) |
755 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
756 |
delete pChannelStrip; |
delete pChannelStrip; |
890 |
|
|
891 |
// Audio device mapping. |
// Audio device mapping. |
892 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
893 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
894 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
895 |
ts << endl; |
ts << endl; |
896 |
qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
Device device(Device::Audio, piDeviceIDs[iDevice]); |
897 |
// Audio device specification... |
// Audio device specification... |
898 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
899 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
900 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
901 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
902 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
903 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
904 |
++deviceParam) { |
++deviceParam) { |
905 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
906 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
907 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
908 |
} |
} |
909 |
ts << endl; |
ts << endl; |
910 |
// Audio channel parameters... |
// Audio channel parameters... |
911 |
int iPort = 0; |
int iPort = 0; |
912 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
913 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
914 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
915 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
916 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
917 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
918 |
++portParam) { |
++portParam) { |
919 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
920 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
921 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
922 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
932 |
|
|
933 |
// MIDI device mapping. |
// MIDI device mapping. |
934 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
935 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
936 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
937 |
ts << endl; |
ts << endl; |
938 |
qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
Device device(Device::Midi, piDeviceIDs[iDevice]); |
939 |
// MIDI device specification... |
// MIDI device specification... |
940 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
941 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
942 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
943 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
944 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
945 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
946 |
++deviceParam) { |
++deviceParam) { |
947 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
948 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
949 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
950 |
} |
} |
951 |
ts << endl; |
ts << endl; |
952 |
// MIDI port parameters... |
// MIDI port parameters... |
953 |
int iPort = 0; |
int iPort = 0; |
954 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
955 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
956 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
957 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
958 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
959 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
960 |
++portParam) { |
++portParam) { |
961 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
962 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
963 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
964 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1050 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
1051 |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
1052 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1053 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1054 |
if (pChannel) { |
if (pChannel) { |
1055 |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
1056 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
1082 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1083 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1084 |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
1085 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1086 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1087 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1088 |
++audioRoute) { |
++audioRoute) { |
1327 |
return; |
return; |
1328 |
|
|
1329 |
// Just create the channel instance... |
// Just create the channel instance... |
1330 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
1331 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1332 |
return; |
return; |
1333 |
|
|
1365 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1366 |
return; |
return; |
1367 |
|
|
1368 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1369 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1370 |
return; |
return; |
1371 |
|
|
1937 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1938 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
1939 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
1940 |
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
1941 |
} |
} |
1942 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1943 |
} |
} |
2189 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
2190 |
|
|
2191 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2192 |
ChannelStrip* MainForm::createChannelStrip ( qsamplerChannel *pChannel ) |
ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel ) |
2193 |
{ |
{ |
2194 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
2195 |
return NULL; |
return NULL; |
2261 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
2262 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2263 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2264 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2265 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2266 |
return pChannelStrip; |
return pChannelStrip; |
2267 |
} |
} |
2402 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
2403 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
2404 |
tr("Could not start the LinuxSampler server.\n\n" |
tr("Could not start the LinuxSampler server.\n\n" |
2405 |
"Maybe it ss already started."), |
"Maybe it is already started."), |
2406 |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
2407 |
case 0: |
case 0: |
2408 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2422 |
return; |
return; |
2423 |
|
|
2424 |
// OK. Let's build the startup process... |
// OK. Let's build the startup process... |
2425 |
m_pServer = new QProcess(this); |
m_pServer = new QProcess(); |
2426 |
|
bForceServerStop = true; |
2427 |
|
|
2428 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2429 |
// if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
2430 |
//m_pServer->setProcessChannelMode( |
#if QT_VERSION >= 0x040200 |
2431 |
// QProcess::StandardOutput); |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
2432 |
|
#endif |
2433 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2434 |
SIGNAL(readyReadStandardOutput()), |
SIGNAL(readyReadStandardOutput()), |
2435 |
SLOT(readServerStdout())); |
SLOT(readServerStdout())); |
2440 |
|
|
2441 |
// The unforgiveable signal communication... |
// The unforgiveable signal communication... |
2442 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2443 |
SIGNAL(finished(int,QProcess::ExitStatus)), |
SIGNAL(finished(int, QProcess::ExitStatus)), |
2444 |
SLOT(processServerExit())); |
SLOT(processServerExit())); |
2445 |
|
|
2446 |
// Build process arguments... |
// Build process arguments... |
2471 |
|
|
2472 |
|
|
2473 |
// Stop linuxsampler server... |
// Stop linuxsampler server... |
2474 |
void MainForm::stopServer (void) |
void MainForm::stopServer (bool bInteractive) |
2475 |
{ |
{ |
2476 |
// Stop client code. |
// Stop client code. |
2477 |
stopClient(); |
stopClient(); |
2478 |
|
|
2479 |
|
if (m_pServer && bInteractive) { |
2480 |
|
if (QMessageBox::question(this, |
2481 |
|
QSAMPLER_TITLE ": " + tr("The backend's fate ..."), |
2482 |
|
tr("You have the option to keep the sampler backend (LinuxSampler)\n" |
2483 |
|
"running in the background. The sampler would continue to work\n" |
2484 |
|
"according to your current sampler session and you could alter the\n" |
2485 |
|
"sampler session at any time by relaunching QSampler.\n\n" |
2486 |
|
"Do you want LinuxSampler to stop or to keep running in\n" |
2487 |
|
"the background?"), |
2488 |
|
tr("Stop"), tr("Keep Running")) == 1) |
2489 |
|
{ |
2490 |
|
bForceServerStop = false; |
2491 |
|
} |
2492 |
|
} |
2493 |
|
|
2494 |
// And try to stop server. |
// And try to stop server. |
2495 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2496 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
2497 |
if (m_pServer->state() == QProcess::Running) |
if (m_pServer->state() == QProcess::Running) { |
2498 |
|
#if defined(WIN32) |
2499 |
|
// Try harder... |
2500 |
|
m_pServer->kill(); |
2501 |
|
#else |
2502 |
|
// Try softly... |
2503 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2504 |
} |
#endif |
2505 |
|
} |
2506 |
|
} // Do final processing anyway. |
2507 |
|
else processServerExit(); |
2508 |
|
|
2509 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
2510 |
QTime t; |
QTime t; |
2511 |
t.start(); |
t.start(); |
2512 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2513 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
|
|
|
|
// Do final processing anyway. |
|
|
processServerExit(); |
|
2514 |
} |
} |
2515 |
|
|
2516 |
|
|
2532 |
if (m_pMessages) |
if (m_pMessages) |
2533 |
m_pMessages->flushStdoutBuffer(); |
m_pMessages->flushStdoutBuffer(); |
2534 |
|
|
2535 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2536 |
|
if (m_pServer->state() != QProcess::NotRunning) { |
2537 |
|
appendMessages(tr("Server is being forced...")); |
2538 |
|
// Force final server shutdown... |
2539 |
|
m_pServer->kill(); |
2540 |
|
// Give it some time to terminate gracefully and stabilize... |
2541 |
|
QTime t; |
2542 |
|
t.start(); |
2543 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2544 |
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2545 |
|
} |
2546 |
// Force final server shutdown... |
// Force final server shutdown... |
2547 |
appendMessages( |
appendMessages( |
2548 |
tr("Server was stopped with exit status %1.") |
tr("Server was stopped with exit status %1.") |
2549 |
.arg(m_pServer->exitStatus())); |
.arg(m_pServer->exitStatus())); |
|
m_pServer->terminate(); |
|
|
if (!m_pServer->waitForFinished(2000)) |
|
|
m_pServer->kill(); |
|
|
// Destroy it. |
|
2550 |
delete m_pServer; |
delete m_pServer; |
2551 |
m_pServer = NULL; |
m_pServer = NULL; |
2552 |
} |
} |
2571 |
// as this is run under some other thread context. |
// as this is run under some other thread context. |
2572 |
// A custom event must be posted here... |
// A custom event must be posted here... |
2573 |
QApplication::postEvent(pMainForm, |
QApplication::postEvent(pMainForm, |
2574 |
new qsamplerCustomEvent(event, pchData, cchData)); |
new CustomEvent(event, pchData, cchData)); |
2575 |
|
|
2576 |
return LSCP_OK; |
return LSCP_OK; |
2577 |
} |
} |
2617 |
|
|
2618 |
// Subscribe to channel info change notifications... |
// Subscribe to channel info change notifications... |
2619 |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO) != LSCP_OK) |
2620 |
appendMessagesClient("lscp_client_subscribe"); |
appendMessagesClient("lscp_client_subscribe(CHANNEL_INFO)"); |
2621 |
|
|
2622 |
|
#if CONFIG_LSCP_CHANNEL_MIDI |
2623 |
|
// Subscribe to channel MIDI data notifications... |
2624 |
|
if (::lscp_client_subscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI) != LSCP_OK) |
2625 |
|
appendMessagesClient("lscp_client_subscribe(CHANNEL_MIDI)"); |
2626 |
|
#endif |
2627 |
|
|
2628 |
// We may stop scheduling around. |
// We may stop scheduling around. |
2629 |
stopSchedule(); |
stopSchedule(); |
2677 |
closeSession(false); |
closeSession(false); |
2678 |
|
|
2679 |
// Close us as a client... |
// Close us as a client... |
2680 |
|
#if CONFIG_LSCP_CHANNEL_MIDI |
2681 |
|
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_MIDI); |
2682 |
|
#endif |
2683 |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
::lscp_client_unsubscribe(m_pClient, LSCP_EVENT_CHANNEL_INFO); |
2684 |
::lscp_client_destroy(m_pClient); |
::lscp_client_destroy(m_pClient); |
2685 |
m_pClient = NULL; |
m_pClient = NULL; |