comparison framework/MainWindowBase.cpp @ 758:5b6655449ba6

Refuse to nest OSC invocations
author Chris Cannam
date Wed, 29 Apr 2020 15:27:13 +0100
parents baa7d3a85317
children 5f8fc01e01c7
comparison
equal deleted inserted replaced
750:e7c77c366360 758:5b6655449ba6
158 m_midiInput(nullptr), 158 m_midiInput(nullptr),
159 m_recentFiles("RecentFiles", 20), 159 m_recentFiles("RecentFiles", 20),
160 m_recentTransforms("RecentTransforms", 20), 160 m_recentTransforms("RecentTransforms", 20),
161 m_documentModified(false), 161 m_documentModified(false),
162 m_openingAudioFile(false), 162 m_openingAudioFile(false),
163 m_handlingOSC(false),
163 m_labeller(nullptr), 164 m_labeller(nullptr),
164 m_lastPlayStatusSec(0), 165 m_lastPlayStatusSec(0),
165 m_initialDarkBackground(false), 166 m_initialDarkBackground(false),
166 m_defaultFfwdRwdStep(2, 0), 167 m_defaultFfwdRwdStep(2, 0),
167 m_audioRecordMode(RecordCreateAdditionalModel), 168 m_audioRecordMode(RecordCreateAdditionalModel),
1563 } else { 1564 } else {
1564 return FileOpenFailed; 1565 return FileOpenFailed;
1565 } 1566 }
1566 } 1567 }
1567 1568
1569 m_openingAudioFile = true;
1570
1568 source.waitForData(); 1571 source.waitForData();
1569
1570 m_openingAudioFile = true;
1571 1572
1572 sv_samplerate_t rate = 0; 1573 sv_samplerate_t rate = 0;
1573 1574
1574 SVDEBUG << "Checking whether to preserve incoming audio file's sample rate" 1575 SVDEBUG << "Checking whether to preserve incoming audio file's sample rate"
1575 << endl; 1576 << endl;
4277 void 4278 void
4278 MainWindowBase::pollOSC() 4279 MainWindowBase::pollOSC()
4279 { 4280 {
4280 if (!m_oscQueue || m_oscQueue->isEmpty()) return; 4281 if (!m_oscQueue || m_oscQueue->isEmpty()) return;
4281 4282
4283 if (m_handlingOSC) {
4284 SVDEBUG << "MainWindowBase::pollOSC: "
4285 << "not making nested invocations, waiting"
4286 << endl;
4287 return;
4288 }
4289
4290 m_handlingOSC = true;
4291
4282 while (!m_oscQueue->isEmpty()) { 4292 while (!m_oscQueue->isEmpty()) {
4283 4293
4284 if (m_openingAudioFile) { 4294 if (m_openingAudioFile) {
4285 SVDEBUG << "MainWindowBase::pollOSC: " 4295 SVDEBUG << "MainWindowBase::pollOSC: "
4286 << "waiting for audio to finish loading" 4296 << "waiting for audio to finish loading"
4287 << endl; 4297 << endl;
4298 m_handlingOSC = false;
4288 return; 4299 return;
4289 } 4300 }
4290 4301
4291 if (ModelTransformerFactory::getInstance()->haveRunningTransformers()) { 4302 if (ModelTransformerFactory::getInstance()->haveRunningTransformers()) {
4292 SVDEBUG << "MainWindowBase::pollOSC: " 4303 SVDEBUG << "MainWindowBase::pollOSC: "
4293 << "waiting for running transforms to complete" 4304 << "waiting for running transforms to complete"
4294 << endl; 4305 << endl;
4306 m_handlingOSC = false;
4295 return; 4307 return;
4296 } 4308 }
4297 4309
4298 SVDEBUG << "MainWindowBase::pollOSC: have " 4310 SVDEBUG << "MainWindowBase::pollOSC: have "
4299 << m_oscQueue->getMessagesAvailable() 4311 << m_oscQueue->getMessagesAvailable()
4302 OSCMessage message = m_oscQueue->readMessage(); 4314 OSCMessage message = m_oscQueue->readMessage();
4303 4315
4304 if (message.getTarget() != 0) { 4316 if (message.getTarget() != 0) {
4305 SVCERR << "MainWindowBase::pollOSC: ignoring message with target " 4317 SVCERR << "MainWindowBase::pollOSC: ignoring message with target "
4306 << message.getTarget() << " (we are target 0)" << endl; 4318 << message.getTarget() << " (we are target 0)" << endl;
4319 m_handlingOSC = false;
4307 continue; 4320 continue;
4308 } 4321 }
4309 4322
4310 handleOSCMessage(message); 4323 handleOSCMessage(message);
4311 4324
4312 disconnect(m_oscQueue, SIGNAL(messagesAvailable()), 4325 disconnect(m_oscQueue, SIGNAL(messagesAvailable()),
4313 this, SLOT(pollOSC())); 4326 this, SLOT(pollOSC()));
4314 4327
4315 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents | 4328 QApplication::processEvents(QEventLoop::ExcludeUserInputEvents |
4316 QEventLoop::ExcludeSocketNotifiers); 4329 QEventLoop::ExcludeSocketNotifiers);
4317 4330 }
4318 connect(m_oscQueue, SIGNAL(messagesAvailable()), 4331
4319 this, SLOT(pollOSC())); 4332 m_handlingOSC = false;
4320 } 4333
4334 connect(m_oscQueue, SIGNAL(messagesAvailable()),
4335 this, SLOT(pollOSC()));
4321 } 4336 }
4322 4337
4323 void 4338 void
4324 MainWindowBase::inProgressSelectionChanged() 4339 MainWindowBase::inProgressSelectionChanged()
4325 { 4340 {