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 |
|
|
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 |
CustomEvent *pEvent = static_cast<CustomEvent *> (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 |
} |
} |
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 |
} |
} |
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; |