Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 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 |
comparison
equal
deleted
inserted
replaced
724:cd1e8c731095 | 725:16f6737fa557 |
---|---|
528 { | 528 { |
529 if (m_oscQueue && m_oscQueue->isOK()) { | 529 if (m_oscQueue && m_oscQueue->isOK()) { |
530 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); | 530 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); |
531 QTimer *oscTimer = new QTimer(this); | 531 QTimer *oscTimer = new QTimer(this); |
532 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); | 532 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); |
533 oscTimer->start(1000); | 533 oscTimer->start(2000); |
534 | 534 |
535 if (m_oscQueue->hasPort()) { | 535 if (m_oscQueue->hasPort()) { |
536 SVDEBUG << "Finished setting up OSC interface" << endl; | 536 SVDEBUG << "Finished setting up OSC interface" << endl; |
537 } else { | 537 } else { |
538 SVDEBUG << "Finished setting up internal-only OSC queue" << endl; | 538 SVDEBUG << "Finished setting up internal-only OSC queue" << endl; |
4213 | 4213 |
4214 void | 4214 void |
4215 MainWindowBase::pollOSC() | 4215 MainWindowBase::pollOSC() |
4216 { | 4216 { |
4217 if (!m_oscQueue || m_oscQueue->isEmpty()) return; | 4217 if (!m_oscQueue || m_oscQueue->isEmpty()) return; |
4218 SVDEBUG << "MainWindowBase::pollOSC: have " << m_oscQueue->getMessagesAvailable() << " messages" << endl; | 4218 |
4219 | 4219 while (!m_oscQueue->isEmpty()) { |
4220 if (m_openingAudioFile) return; | 4220 |
4221 | 4221 if (m_openingAudioFile) { |
4222 OSCMessage message = m_oscQueue->readMessage(); | 4222 SVDEBUG << "MainWindowBase::pollOSC: " |
4223 | 4223 << "waiting for audio to finish loading" |
4224 if (message.getTarget() != 0) { | 4224 << endl; |
4225 return; //!!! for now -- this class is target 0, others not handled yet | 4225 return; |
4226 } | 4226 } |
4227 | 4227 |
4228 handleOSCMessage(message); | 4228 if (ModelTransformerFactory::getInstance()->haveRunningTransformers()) { |
4229 SVDEBUG << "MainWindowBase::pollOSC: " | |
4230 << "waiting for running transforms to complete" | |
4231 << endl; | |
4232 return; | |
4233 } | |
4234 | |
4235 SVDEBUG << "MainWindowBase::pollOSC: have " | |
4236 << m_oscQueue->getMessagesAvailable() | |
4237 << " messages" << endl; | |
4238 | |
4239 OSCMessage message = m_oscQueue->readMessage(); | |
4240 | |
4241 if (message.getTarget() != 0) { | |
4242 SVCERR << "MainWindowBase::pollOSC: ignoring message with target " | |
4243 << message.getTarget() << " (we are target 0)" << endl; | |
4244 continue; | |
4245 } | |
4246 | |
4247 handleOSCMessage(message); | |
4248 | |
4249 disconnect(m_oscQueue, SIGNAL(messagesAvailable()), | |
4250 this, SLOT(pollOSC())); | |
4251 | |
4252 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents | | |
4253 QEventLoop::ExcludeSocketNotifiers); | |
4254 | |
4255 connect(m_oscQueue, SIGNAL(messagesAvailable()), | |
4256 this, SLOT(pollOSC())); | |
4257 } | |
4229 } | 4258 } |
4230 | 4259 |
4231 void | 4260 void |
4232 MainWindowBase::inProgressSelectionChanged() | 4261 MainWindowBase::inProgressSelectionChanged() |
4233 { | 4262 { |