History

Ensure audio devices are made on the right thread

Atlante45 committed 8 years ago

Commit 29ff47c1 parent 9ace80c2 files · +13 −2Browse files

Showing the changes to libraries/script-engine/src/AudioScriptingInterface.cpp (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/AudioScriptingInterface.cpp+8−1
@@ -63,8 +63,15 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound · 62 unmodified lines
6363 bool AudioScriptingInterface::setStereoInput(bool stereo) {
6464 bool stereoInputChanged = false;
6565 if (_localAudioInterface) {
66− stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
66+ if (QThread::currentThread() != _localAudioInterface->thread()) {
67+ // TODO: This can block the main thread which is not ideal, make this function and the UI calling it async
68+ BLOCKING_INVOKE_METHOD(_localAudioInterface, "setIsStereoInput", Q_RETURN_ARG(bool, stereoInputChanged),
69+ Q_ARG(bool, stereo));
70+ } else {
71+ stereoInputChanged = _localAudioInterface->setIsStereoInput(stereo);
72+ }
6773 }
74+
6875 return stereoInputChanged;
6976 }
7077