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 |
|
|
172 |
// Volume slider... |
// Volume slider... |
173 |
m_ui.channelsToolbar->addSeparator(); |
m_ui.channelsToolbar->addSeparator(); |
174 |
m_pVolumeSlider = new QSlider(Qt::Horizontal, m_ui.channelsToolbar); |
m_pVolumeSlider = new QSlider(Qt::Horizontal, m_ui.channelsToolbar); |
175 |
m_pVolumeSlider->setTickPosition(QSlider::TicksBelow); |
m_pVolumeSlider->setTickPosition(QSlider::TicksBothSides); |
176 |
m_pVolumeSlider->setTickInterval(10); |
m_pVolumeSlider->setTickInterval(10); |
177 |
m_pVolumeSlider->setPageStep(10); |
m_pVolumeSlider->setPageStep(10); |
178 |
m_pVolumeSlider->setSingleStep(10); |
m_pVolumeSlider->setSingleStep(10); |
190 |
// Volume spin-box |
// Volume spin-box |
191 |
m_ui.channelsToolbar->addSeparator(); |
m_ui.channelsToolbar->addSeparator(); |
192 |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
193 |
|
m_pVolumeSpinBox->setMaximumHeight(24); |
194 |
m_pVolumeSpinBox->setSuffix(" %"); |
m_pVolumeSpinBox->setSuffix(" %"); |
195 |
m_pVolumeSpinBox->setMinimum(0); |
m_pVolumeSpinBox->setMinimum(0); |
196 |
m_pVolumeSpinBox->setMaximum(100); |
m_pVolumeSpinBox->setMaximum(100); |
207 |
// Set the activation connection. |
// Set the activation connection. |
208 |
QObject::connect(m_pWorkspace, |
QObject::connect(m_pWorkspace, |
209 |
SIGNAL(windowActivated(QWidget *)), |
SIGNAL(windowActivated(QWidget *)), |
210 |
SLOT(stabilizeForm())); |
SLOT(activateStrip(QWidget *))); |
211 |
// Make it shine :-) |
// Make it shine :-) |
212 |
setCentralWidget(m_pWorkspace); |
setCentralWidget(m_pWorkspace); |
213 |
|
|
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) { |
if (pEvent->event() == LSCP_EVENT_CHANNEL_INFO) { |
555 |
int iChannelID = pEvent->data().toInt(); |
int iChannelID = pEvent->data().toInt(); |
556 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
577 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
578 |
|
|
579 |
// The global options settings property. |
// The global options settings property. |
580 |
qsamplerOptions *MainForm::options (void) const |
Options *MainForm::options (void) const |
581 |
{ |
{ |
582 |
return m_pOptions; |
return m_pOptions; |
583 |
} |
} |
738 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
739 |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
740 |
if (pChannelStrip) { |
if (pChannelStrip) { |
741 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
742 |
if (bForce && pChannel) |
if (bForce && pChannel) |
743 |
pChannel->removeChannel(); |
pChannel->removeChannel(); |
744 |
delete pChannelStrip; |
delete pChannelStrip; |
878 |
|
|
879 |
// Audio device mapping. |
// Audio device mapping. |
880 |
QMap<int, int> audioDeviceMap; |
QMap<int, int> audioDeviceMap; |
881 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Audio); |
882 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
883 |
ts << endl; |
ts << endl; |
884 |
qsamplerDevice device(qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
Device device(Device::Audio, piDeviceIDs[iDevice]); |
885 |
// Audio device specification... |
// Audio device specification... |
886 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
887 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
888 |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
889 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
890 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
891 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
892 |
++deviceParam) { |
++deviceParam) { |
893 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
894 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
895 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
896 |
} |
} |
897 |
ts << endl; |
ts << endl; |
898 |
// Audio channel parameters... |
// Audio channel parameters... |
899 |
int iPort = 0; |
int iPort = 0; |
900 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
901 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
902 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
903 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
904 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
905 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
906 |
++portParam) { |
++portParam) { |
907 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
908 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
909 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
910 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
920 |
|
|
921 |
// MIDI device mapping. |
// MIDI device mapping. |
922 |
QMap<int, int> midiDeviceMap; |
QMap<int, int> midiDeviceMap; |
923 |
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
piDeviceIDs = Device::getDevices(m_pClient, Device::Midi); |
924 |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
925 |
ts << endl; |
ts << endl; |
926 |
qsamplerDevice device(qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
Device device(Device::Midi, piDeviceIDs[iDevice]); |
927 |
// MIDI device specification... |
// MIDI device specification... |
928 |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
929 |
<< " " << tr("Device") << " " << iDevice << endl; |
<< " " << tr("Device") << " " << iDevice << endl; |
930 |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
931 |
qsamplerDeviceParamMap::ConstIterator deviceParam; |
DeviceParamMap::ConstIterator deviceParam; |
932 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
933 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
934 |
++deviceParam) { |
++deviceParam) { |
935 |
const qsamplerDeviceParam& param = deviceParam.value(); |
const DeviceParam& param = deviceParam.value(); |
936 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
937 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
938 |
} |
} |
939 |
ts << endl; |
ts << endl; |
940 |
// MIDI port parameters... |
// MIDI port parameters... |
941 |
int iPort = 0; |
int iPort = 0; |
942 |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
QListIterator<DevicePort *> iter(device.ports()); |
943 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
944 |
qsamplerDevicePort *pPort = iter.next(); |
DevicePort *pPort = iter.next(); |
945 |
qsamplerDeviceParamMap::ConstIterator portParam; |
DeviceParamMap::ConstIterator portParam; |
946 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
947 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
948 |
++portParam) { |
++portParam) { |
949 |
const qsamplerDeviceParam& param = portParam.value(); |
const DeviceParam& param = portParam.value(); |
950 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
951 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
952 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
1038 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
1039 |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
1040 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1041 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1042 |
if (pChannel) { |
if (pChannel) { |
1043 |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
1044 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
1070 |
ts << "LOAD INSTRUMENT NON_MODAL '" |
ts << "LOAD INSTRUMENT NON_MODAL '" |
1071 |
<< pChannel->instrumentFile() << "' " |
<< pChannel->instrumentFile() << "' " |
1072 |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
<< pChannel->instrumentNr() << " " << iChannel << endl; |
1073 |
qsamplerChannelRoutingMap::ConstIterator audioRoute; |
ChannelRoutingMap::ConstIterator audioRoute; |
1074 |
for (audioRoute = pChannel->audioRouting().begin(); |
for (audioRoute = pChannel->audioRouting().begin(); |
1075 |
audioRoute != pChannel->audioRouting().end(); |
audioRoute != pChannel->audioRouting().end(); |
1076 |
++audioRoute) { |
++audioRoute) { |
1315 |
return; |
return; |
1316 |
|
|
1317 |
// Just create the channel instance... |
// Just create the channel instance... |
1318 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
Channel *pChannel = new Channel(); |
1319 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1320 |
return; |
return; |
1321 |
|
|
1333 |
return; |
return; |
1334 |
} |
} |
1335 |
|
|
1336 |
|
// Do we auto-arrange? |
1337 |
|
if (m_pOptions && m_pOptions->bAutoArrange) |
1338 |
|
channelsArrange(); |
1339 |
|
|
1340 |
// Make that an overall update. |
// Make that an overall update. |
1341 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1342 |
stabilizeForm(); |
stabilizeForm(); |
1353 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1354 |
return; |
return; |
1355 |
|
|
1356 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1357 |
if (pChannel == NULL) |
if (pChannel == NULL) |
1358 |
return; |
return; |
1359 |
|
|
1925 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1926 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
1927 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
1928 |
createChannelStrip(new qsamplerChannel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
1929 |
} |
} |
1930 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1931 |
} |
} |
2177 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
2178 |
|
|
2179 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2180 |
ChannelStrip* MainForm::createChannelStrip(qsamplerChannel* pChannel) |
ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel ) |
2181 |
{ |
{ |
2182 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
2183 |
return NULL; |
return NULL; |
2184 |
|
|
|
// Prepare for auto-arrange? |
|
|
ChannelStrip* pChannelStrip = NULL; |
|
|
int y = 0; |
|
|
if (m_pOptions && m_pOptions->bAutoArrange) { |
|
|
QWidgetList wlist = m_pWorkspace->windowList(); |
|
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
|
|
pChannelStrip = static_cast<ChannelStrip *> (wlist.at(iChannel)); |
|
|
if (pChannelStrip) { |
|
|
// y += pChannelStrip->height() |
|
|
// + pChannelStrip->parentWidget()->baseSize().height(); |
|
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
2185 |
// Add a new channel itema... |
// Add a new channel itema... |
2186 |
pChannelStrip = new ChannelStrip(); |
ChannelStrip *pChannelStrip = new ChannelStrip(); |
2187 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
2188 |
return NULL; |
return NULL; |
2189 |
|
|
2190 |
m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint); |
// Set some initial channel strip options... |
|
|
|
|
// Actual channel strip setup... |
|
|
pChannelStrip->setup(pChannel); |
|
|
QObject::connect(pChannelStrip, |
|
|
SIGNAL(channelChanged(ChannelStrip*)), |
|
|
SLOT(channelStripChanged(ChannelStrip*))); |
|
|
// Set some initial aesthetic options... |
|
2191 |
if (m_pOptions) { |
if (m_pOptions) { |
2192 |
// Background display effect... |
// Background display effect... |
2193 |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2199 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
2200 |
} |
} |
2201 |
|
|
2202 |
|
// Add it to workspace... |
2203 |
|
m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint); |
2204 |
|
|
2205 |
|
// Actual channel strip setup... |
2206 |
|
pChannelStrip->setup(pChannel); |
2207 |
|
|
2208 |
|
QObject::connect(pChannelStrip, |
2209 |
|
SIGNAL(channelChanged(ChannelStrip*)), |
2210 |
|
SLOT(channelStripChanged(ChannelStrip*))); |
2211 |
|
|
2212 |
// Now we show up us to the world. |
// Now we show up us to the world. |
2213 |
pChannelStrip->show(); |
pChannelStrip->show(); |
|
// Only then, we'll auto-arrange... |
|
|
if (m_pOptions && m_pOptions->bAutoArrange) { |
|
|
int iWidth = m_pWorkspace->width(); |
|
|
// int iHeight = pChannel->height() |
|
|
// + pChannel->parentWidget()->baseSize().height(); |
|
|
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
|
|
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
|
|
} |
|
2214 |
|
|
2215 |
// This is pretty new, so we'll watch for it closely. |
// This is pretty new, so we'll watch for it closely. |
2216 |
channelStripChanged(pChannelStrip); |
channelStripChanged(pChannelStrip); |
2249 |
ChannelStrip* pChannelStrip |
ChannelStrip* pChannelStrip |
2250 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2251 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2252 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2253 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2254 |
return pChannelStrip; |
return pChannelStrip; |
2255 |
} |
} |
2390 |
switch (QMessageBox::warning(this, |
switch (QMessageBox::warning(this, |
2391 |
QSAMPLER_TITLE ": " + tr("Warning"), |
QSAMPLER_TITLE ": " + tr("Warning"), |
2392 |
tr("Could not start the LinuxSampler server.\n\n" |
tr("Could not start the LinuxSampler server.\n\n" |
2393 |
"Maybe it ss already started."), |
"Maybe it is already started."), |
2394 |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
tr("Stop"), tr("Kill"), tr("Cancel"))) { |
2395 |
case 0: |
case 0: |
2396 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2410 |
return; |
return; |
2411 |
|
|
2412 |
// OK. Let's build the startup process... |
// OK. Let's build the startup process... |
2413 |
m_pServer = new QProcess(this); |
m_pServer = new QProcess(); |
2414 |
|
bForceServerStop = true; |
2415 |
|
|
2416 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2417 |
// if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
2418 |
//m_pServer->setProcessChannelMode( |
#if QT_VERSION >= 0x040200 |
2419 |
// QProcess::StandardOutput); |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
2420 |
|
#endif |
2421 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2422 |
SIGNAL(readyReadStandardOutput()), |
SIGNAL(readyReadStandardOutput()), |
2423 |
SLOT(readServerStdout())); |
SLOT(readServerStdout())); |
2428 |
|
|
2429 |
// The unforgiveable signal communication... |
// The unforgiveable signal communication... |
2430 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2431 |
SIGNAL(finished(int,QProcess::ExitStatus)), |
SIGNAL(finished(int, QProcess::ExitStatus)), |
2432 |
SLOT(processServerExit())); |
SLOT(processServerExit())); |
2433 |
|
|
2434 |
// Build process arguments... |
// Build process arguments... |
2459 |
|
|
2460 |
|
|
2461 |
// Stop linuxsampler server... |
// Stop linuxsampler server... |
2462 |
void MainForm::stopServer (void) |
void MainForm::stopServer (bool bInteractive) |
2463 |
{ |
{ |
2464 |
// Stop client code. |
// Stop client code. |
2465 |
stopClient(); |
stopClient(); |
2466 |
|
|
2467 |
|
if (m_pServer && bInteractive) { |
2468 |
|
if (QMessageBox::question(this, |
2469 |
|
QSAMPLER_TITLE ": " + tr("The backend's fate ..."), |
2470 |
|
tr("You have the option to keep the sampler backend (LinuxSampler)\n" |
2471 |
|
"running in the background. The sampler would continue to work\n" |
2472 |
|
"according to your current sampler session and you could alter the\n" |
2473 |
|
"sampler session at any time by relaunching QSampler.\n\n" |
2474 |
|
"Do you want LinuxSampler to stop or to keep running in\n" |
2475 |
|
"the background?"), |
2476 |
|
tr("Stop"), tr("Keep Running")) == 1) |
2477 |
|
{ |
2478 |
|
bForceServerStop = false; |
2479 |
|
} |
2480 |
|
} |
2481 |
|
|
2482 |
// And try to stop server. |
// And try to stop server. |
2483 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2484 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
2485 |
if (m_pServer->state() == QProcess::Running) |
if (m_pServer->state() == QProcess::Running) { |
2486 |
|
#if defined(WIN32) |
2487 |
|
// Try harder... |
2488 |
|
m_pServer->kill(); |
2489 |
|
#else |
2490 |
|
// Try softly... |
2491 |
m_pServer->terminate(); |
m_pServer->terminate(); |
2492 |
} |
#endif |
2493 |
|
} |
2494 |
|
} // Do final processing anyway. |
2495 |
|
else processServerExit(); |
2496 |
|
|
2497 |
// Give it some time to terminate gracefully and stabilize... |
// Give it some time to terminate gracefully and stabilize... |
2498 |
QTime t; |
QTime t; |
2499 |
t.start(); |
t.start(); |
2500 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2501 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
|
|
|
|
// Do final processing anyway. |
|
|
processServerExit(); |
|
2502 |
} |
} |
2503 |
|
|
2504 |
|
|
2520 |
if (m_pMessages) |
if (m_pMessages) |
2521 |
m_pMessages->flushStdoutBuffer(); |
m_pMessages->flushStdoutBuffer(); |
2522 |
|
|
2523 |
if (m_pServer) { |
if (m_pServer && bForceServerStop) { |
2524 |
|
if (m_pServer->state() != QProcess::NotRunning) { |
2525 |
|
appendMessages(tr("Server is being forced...")); |
2526 |
|
// Force final server shutdown... |
2527 |
|
m_pServer->kill(); |
2528 |
|
// Give it some time to terminate gracefully and stabilize... |
2529 |
|
QTime t; |
2530 |
|
t.start(); |
2531 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2532 |
|
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2533 |
|
} |
2534 |
// Force final server shutdown... |
// Force final server shutdown... |
2535 |
appendMessages( |
appendMessages( |
2536 |
tr("Server was stopped with exit status %1.") |
tr("Server was stopped with exit status %1.") |
2537 |
.arg(m_pServer->exitStatus())); |
.arg(m_pServer->exitStatus())); |
|
m_pServer->terminate(); |
|
|
if (!m_pServer->waitForFinished(2000)) |
|
|
m_pServer->kill(); |
|
|
// Destroy it. |
|
2538 |
delete m_pServer; |
delete m_pServer; |
2539 |
m_pServer = NULL; |
m_pServer = NULL; |
2540 |
} |
} |
2559 |
// as this is run under some other thread context. |
// as this is run under some other thread context. |
2560 |
// A custom event must be posted here... |
// A custom event must be posted here... |
2561 |
QApplication::postEvent(pMainForm, |
QApplication::postEvent(pMainForm, |
2562 |
new qsamplerCustomEvent(event, pchData, cchData)); |
new CustomEvent(event, pchData, cchData)); |
2563 |
|
|
2564 |
return LSCP_OK; |
return LSCP_OK; |
2565 |
} |
} |
2677 |
stabilizeForm(); |
stabilizeForm(); |
2678 |
} |
} |
2679 |
|
|
2680 |
|
|
2681 |
|
// Channel strip activation/selection. |
2682 |
|
void MainForm::activateStrip ( QWidget *pWidget ) |
2683 |
|
{ |
2684 |
|
ChannelStrip *pChannelStrip |
2685 |
|
= static_cast<ChannelStrip *> (pWidget); |
2686 |
|
if (pChannelStrip) |
2687 |
|
pChannelStrip->setSelected(true); |
2688 |
|
|
2689 |
|
stabilizeForm(); |
2690 |
|
} |
2691 |
|
|
2692 |
|
|
2693 |
} // namespace QSampler |
} // namespace QSampler |
2694 |
|
|
2695 |
|
|