Mercurial > hg > svapp
changeset 725:16f6737fa557 spectrogram-export
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?)
author | Chris Cannam |
---|---|
date | Wed, 08 Jan 2020 15:33:17 +0000 |
parents | cd1e8c731095 |
children | 1e2e03197b8c |
files | framework/MainWindowBase.cpp |
diffstat | 1 files changed, 40 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- 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