# HG changeset patch # User Chris Cannam # Date 1578497597 0 # Node ID 16f6737fa5573faca3219a3f7519b540f4726dee # Parent cd1e8c731095328da09ebc0fe25b396be2b3fc9c Rework OSC handler so as to consume all available messages rather than having to wait for the timeout in between them. Pause to process events, and also wait for file loads and transforms to complete. (Should only certain kinds of OSC command wait for transforms?) diff -r cd1e8c731095 -r 16f6737fa557 framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Jan 08 15:31:27 2020 +0000 +++ b/framework/MainWindowBase.cpp Wed Jan 08 15:33:17 2020 +0000 @@ -530,7 +530,7 @@ connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); QTimer *oscTimer = new QTimer(this); connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); - oscTimer->start(1000); + oscTimer->start(2000); if (m_oscQueue->hasPort()) { SVDEBUG << "Finished setting up OSC interface" << endl; @@ -4215,17 +4215,46 @@ MainWindowBase::pollOSC() { if (!m_oscQueue || m_oscQueue->isEmpty()) return; - SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl; - - if (m_openingAudioFile) return; - - OSCMessage message = m_oscQueue->readMessage(); - - if (message.getTarget() != 0) { - return; //!!! for now -- this class is target 0, others not handled yet + + while (!m_oscQueue->isEmpty()) { + + if (m_openingAudioFile) { + SVDEBUG << "MainWindowBase::pollOSC: " + << "waiting for audio to finish loading" + << endl; + return; + } + + if (ModelTransformerFactory::getInstance()->haveRunningTransformers()) { + SVDEBUG << "MainWindowBase::pollOSC: " + << "waiting for running transforms to complete" + << endl; + return; + } + + SVDEBUG << "MainWindowBase::pollOSC: have " + << m_oscQueue->getMessagesAvailable() + << " messages" << endl; + + OSCMessage message = m_oscQueue->readMessage(); + + if (message.getTarget() != 0) { + SVCERR << "MainWindowBase::pollOSC: ignoring message with target " + << message.getTarget() << " (we are target 0)" << endl; + continue; + } + + handleOSCMessage(message); + + disconnect(m_oscQueue, SIGNAL(messagesAvailable()), + this, SLOT(pollOSC())); + + QApplication::processEvents(QEventLoop::ExcludeUserInputEvents | + QEventLoop::ExcludeSocketNotifiers); + + connect(m_oscQueue, SIGNAL(messagesAvailable()), + this, SLOT(pollOSC())); } - - handleOSCMessage(message); } void