93 |
#endif |
#endif |
94 |
|
|
95 |
|
|
96 |
|
//------------------------------------------------------------------------- |
97 |
|
// LADISH Level 1 support stuff. |
98 |
|
|
99 |
|
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
100 |
|
|
101 |
|
#include <QSocketNotifier> |
102 |
|
|
103 |
|
#include <sys/types.h> |
104 |
|
#include <sys/socket.h> |
105 |
|
|
106 |
|
#include <signal.h> |
107 |
|
|
108 |
|
// File descriptor for SIGUSR1 notifier. |
109 |
|
static int g_fdUsr1[2]; |
110 |
|
|
111 |
|
// Unix SIGUSR1 signal handler. |
112 |
|
static void qsampler_sigusr1_handler ( int /* signo */ ) |
113 |
|
{ |
114 |
|
char c = 1; |
115 |
|
|
116 |
|
(::write(g_fdUsr1[0], &c, sizeof(c)) > 0); |
117 |
|
} |
118 |
|
|
119 |
|
#endif // HAVE_SIGNAL_H |
120 |
|
|
121 |
|
|
122 |
|
//------------------------------------------------------------------------- |
123 |
|
// qsampler -- namespace |
124 |
|
|
125 |
|
|
126 |
namespace QSampler { |
namespace QSampler { |
127 |
|
|
128 |
// Timer constant stuff. |
// Timer constant stuff. |
135 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
136 |
|
|
137 |
|
|
138 |
|
// Specialties for thread-callback comunication. |
139 |
|
#define QSAMPLER_LSCP_EVENT QEvent::Type(QEvent::User + 1) |
140 |
|
|
141 |
|
|
142 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
143 |
// CustomEvent -- specialty for callback comunication. |
// LscpEvent -- specialty for LSCP callback comunication. |
144 |
|
|
|
#define QSAMPLER_CUSTOM_EVENT QEvent::Type(QEvent::User + 0) |
|
145 |
|
|
146 |
class CustomEvent : public QEvent |
class LscpEvent : public QEvent |
147 |
{ |
{ |
148 |
public: |
public: |
149 |
|
|
150 |
// Constructor. |
// Constructor. |
151 |
CustomEvent(lscp_event_t event, const char *pchData, int cchData) |
LscpEvent(lscp_event_t event, const char *pchData, int cchData) |
152 |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
: QEvent(QSAMPLER_LSCP_EVENT) |
153 |
{ |
{ |
154 |
m_event = event; |
m_event = event; |
155 |
m_data = QString::fromUtf8(pchData, cchData); |
m_data = QString::fromUtf8(pchData, cchData); |
202 |
|
|
203 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
204 |
|
|
205 |
#ifdef HAVE_SIGNAL_H |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
206 |
|
|
207 |
// Set to ignore any fatal "Broken pipe" signals. |
// Set to ignore any fatal "Broken pipe" signals. |
208 |
::signal(SIGPIPE, SIG_IGN); |
::signal(SIGPIPE, SIG_IGN); |
209 |
#endif |
|
210 |
|
// LADISH Level 1 suport. |
211 |
|
|
212 |
|
// Initialize file descriptors for SIGUSR1 socket notifier. |
213 |
|
::socketpair(AF_UNIX, SOCK_STREAM, 0, g_fdUsr1); |
214 |
|
m_pUsr1Notifier |
215 |
|
= new QSocketNotifier(g_fdUsr1[1], QSocketNotifier::Read, this); |
216 |
|
|
217 |
|
QObject::connect(m_pUsr1Notifier, |
218 |
|
SIGNAL(activated(int)), |
219 |
|
SLOT(handle_sigusr1())); |
220 |
|
|
221 |
|
// Install SIGUSR1 signal handler. |
222 |
|
struct sigaction usr1; |
223 |
|
usr1.sa_handler = qsampler_sigusr1_handler; |
224 |
|
::sigemptyset(&usr1.sa_mask); |
225 |
|
usr1.sa_flags = 0; |
226 |
|
usr1.sa_flags |= SA_RESTART; |
227 |
|
::sigaction(SIGUSR1, &usr1, NULL); |
228 |
|
|
229 |
|
#else // HAVE_SIGNAL_H |
230 |
|
|
231 |
|
m_pUsr1Notifier = NULL; |
232 |
|
|
233 |
|
#endif // !HAVE_SIGNAL_H |
234 |
|
|
235 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
236 |
// Make some extras into the toolbar... |
// Make some extras into the toolbar... |
403 |
WSACleanup(); |
WSACleanup(); |
404 |
#endif |
#endif |
405 |
|
|
406 |
|
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
407 |
|
if (m_pUsr1Notifier) |
408 |
|
delete m_pUsr1Notifier; |
409 |
|
#endif |
410 |
|
|
411 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
412 |
if (m_pDeviceForm) |
if (m_pDeviceForm) |
413 |
delete m_pDeviceForm; |
delete m_pDeviceForm; |
498 |
} |
} |
499 |
|
|
500 |
// Try to restore old window positioning and initial visibility. |
// Try to restore old window positioning and initial visibility. |
501 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this, true); |
502 |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
503 |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
504 |
|
|
542 |
// And the children, and the main windows state,. |
// And the children, and the main windows state,. |
543 |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
544 |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
545 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(this, true); |
546 |
// Close popup widgets. |
// Close popup widgets. |
547 |
if (m_pInstrumentListForm) |
if (m_pInstrumentListForm) |
548 |
m_pInstrumentListForm->close(); |
m_pInstrumentListForm->close(); |
591 |
QListIterator<QUrl> iter(pMimeData->urls()); |
QListIterator<QUrl> iter(pMimeData->urls()); |
592 |
while (iter.hasNext()) { |
while (iter.hasNext()) { |
593 |
const QString& sPath = iter.next().toLocalFile(); |
const QString& sPath = iter.next().toLocalFile(); |
594 |
if (Channel::isInstrumentFile(sPath)) { |
// if (Channel::isDlsInstrumentFile(sPath)) { |
595 |
|
if (QFileInfo(sPath).exists()) { |
596 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
597 |
Channel *pChannel = new Channel(); |
Channel *pChannel = new Channel(); |
598 |
if (pChannel == NULL) |
if (pChannel == NULL) |
626 |
|
|
627 |
|
|
628 |
// Custome event handler. |
// Custome event handler. |
629 |
void MainForm::customEvent(QEvent* pCustomEvent) |
void MainForm::customEvent ( QEvent* pEvent ) |
630 |
{ |
{ |
631 |
// For the time being, just pump it to messages. |
// For the time being, just pump it to messages. |
632 |
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
if (pEvent->type() == QSAMPLER_LSCP_EVENT) { |
633 |
CustomEvent *pEvent = static_cast<CustomEvent *> (pCustomEvent); |
LscpEvent *pLscpEvent = static_cast<LscpEvent *> (pEvent); |
634 |
switch (pEvent->event()) { |
switch (pLscpEvent->event()) { |
635 |
case LSCP_EVENT_CHANNEL_COUNT: |
case LSCP_EVENT_CHANNEL_COUNT: |
636 |
updateAllChannelStrips(true); |
updateAllChannelStrips(true); |
637 |
break; |
break; |
638 |
case LSCP_EVENT_CHANNEL_INFO: { |
case LSCP_EVENT_CHANNEL_INFO: { |
639 |
int iChannelID = pEvent->data().toInt(); |
int iChannelID = pLscpEvent->data().toInt(); |
640 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
641 |
if (pChannelStrip) |
if (pChannelStrip) |
642 |
channelStripChanged(pChannelStrip); |
channelStripChanged(pChannelStrip); |
649 |
break; |
break; |
650 |
case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: { |
case LSCP_EVENT_MIDI_INPUT_DEVICE_INFO: { |
651 |
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
if (m_pDeviceForm) m_pDeviceForm->refreshDevices(); |
652 |
const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt(); |
const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
653 |
DeviceStatusForm::onDeviceChanged(iDeviceID); |
DeviceStatusForm::onDeviceChanged(iDeviceID); |
654 |
break; |
break; |
655 |
} |
} |
661 |
break; |
break; |
662 |
#if CONFIG_EVENT_CHANNEL_MIDI |
#if CONFIG_EVENT_CHANNEL_MIDI |
663 |
case LSCP_EVENT_CHANNEL_MIDI: { |
case LSCP_EVENT_CHANNEL_MIDI: { |
664 |
const int iChannelID = pEvent->data().section(' ', 0, 0).toInt(); |
const int iChannelID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
665 |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
ChannelStrip *pChannelStrip = channelStrip(iChannelID); |
666 |
if (pChannelStrip) |
if (pChannelStrip) |
667 |
pChannelStrip->midiActivityLedOn(); |
pChannelStrip->midiActivityLedOn(); |
670 |
#endif |
#endif |
671 |
#if CONFIG_EVENT_DEVICE_MIDI |
#if CONFIG_EVENT_DEVICE_MIDI |
672 |
case LSCP_EVENT_DEVICE_MIDI: { |
case LSCP_EVENT_DEVICE_MIDI: { |
673 |
const int iDeviceID = pEvent->data().section(' ', 0, 0).toInt(); |
const int iDeviceID = pLscpEvent->data().section(' ', 0, 0).toInt(); |
674 |
const int iPortID = pEvent->data().section(' ', 1, 1).toInt(); |
const int iPortID = pLscpEvent->data().section(' ', 1, 1).toInt(); |
675 |
DeviceStatusForm *pDeviceStatusForm |
DeviceStatusForm *pDeviceStatusForm |
676 |
= DeviceStatusForm::getInstance(iDeviceID); |
= DeviceStatusForm::getInstance(iDeviceID); |
677 |
if (pDeviceStatusForm) |
if (pDeviceStatusForm) |
680 |
} |
} |
681 |
#endif |
#endif |
682 |
default: |
default: |
683 |
appendMessagesColor(tr("Notify event: %1 data: %2") |
appendMessagesColor(tr("LSCP Event: %1 data: %2") |
684 |
.arg(::lscp_event_to_text(pEvent->event())) |
.arg(::lscp_event_to_text(pLscpEvent->event())) |
685 |
.arg(pEvent->data()), "#996699"); |
.arg(pLscpEvent->data()), "#996699"); |
686 |
} |
} |
687 |
} |
} |
688 |
} |
} |
689 |
|
|
690 |
|
|
691 |
|
// LADISH Level 1 -- SIGUSR1 signal handler. |
692 |
|
void MainForm::handle_sigusr1 (void) |
693 |
|
{ |
694 |
|
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
695 |
|
|
696 |
|
char c; |
697 |
|
|
698 |
|
if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0) |
699 |
|
saveSession(false); |
700 |
|
|
701 |
|
#endif |
702 |
|
} |
703 |
|
|
704 |
|
|
705 |
void MainForm::updateViewMidiDeviceStatusMenu (void) |
void MainForm::updateViewMidiDeviceStatusMenu (void) |
706 |
{ |
{ |
707 |
m_ui.viewMidiDeviceStatusMenu->clear(); |
m_ui.viewMidiDeviceStatusMenu->clear(); |
2780 |
// as this is run under some other thread context. |
// as this is run under some other thread context. |
2781 |
// A custom event must be posted here... |
// A custom event must be posted here... |
2782 |
QApplication::postEvent(pMainForm, |
QApplication::postEvent(pMainForm, |
2783 |
new CustomEvent(event, pchData, cchData)); |
new LscpEvent(event, pchData, cchData)); |
2784 |
|
|
2785 |
return LSCP_OK; |
return LSCP_OK; |
2786 |
} |
} |