Showing the changes to libraries/script-engine/src/AudioScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -23,6 +23,21 @@ void registerAudioMetaTypes(QScriptEngine* engine) { · 22 unmodified lines | |||
| 23 | qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue); | 23 | qScriptRegisterMetaType(engine, soundSharedPointerToScriptValue, soundSharedPointerFromScriptValue); |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | |||
| 27 | void AudioScriptingInterface::setLocalAudioInterface(AbstractAudioInterface* audioInterface) { | ||
| 28 | if (_localAudioInterface) { | ||
| 29 | disconnect(_localAudioInterface, &AbstractAudioInterface::isStereoInputChanged, | ||
| 30 | this, &AudioScriptingInterface::isStereoInputChanged); | ||
| 31 | } | ||
| 32 | |||
| 33 | _localAudioInterface = audioInterface; | ||
| 34 | |||
| 35 | if (_localAudioInterface) { | ||
| 36 | connect(_localAudioInterface, &AbstractAudioInterface::isStereoInputChanged, | ||
| 37 | this, &AudioScriptingInterface::isStereoInputChanged); | ||
| 38 | } | ||
| 39 | } | ||
| 40 | |||
| 26 | ScriptAudioInjector* AudioScriptingInterface::playSystemSound(SharedSoundPointer sound, const QVector3D& position) { | 41 | ScriptAudioInjector* AudioScriptingInterface::playSystemSound(SharedSoundPointer sound, const QVector3D& position) { |
| 27 | AudioInjectorOptions options; | 42 | AudioInjectorOptions options; |
| 28 | options.position = glm::vec3(position.x(), position.y(), position.z()); | 43 | options.position = glm::vec3(position.x(), position.y(), position.z()); |
| @@ -60,19 +75,10 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(SharedSoundPointer sound · 31 unmodified lines | |||
| 60 | } | 75 | } |
| 61 | } | 76 | } |
| 62 | 77 | ||
| 63 | bool AudioScriptingInterface::setStereoInput(bool stereo) { | 78 | void AudioScriptingInterface::setStereoInput(bool stereo) { |
| 64 | bool stereoInputChanged = false; | ||
| 65 | if (_localAudioInterface) { | 79 | if (_localAudioInterface) { |
| 66 | if (QThread::currentThread() != _localAudioInterface->thread()) { | 80 | QMetaObject::invokeMethod(_localAudioInterface, "setIsStereoInput", Q_ARG(bool, stereo)); |
| 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 | } | ||
| 73 | } | 81 | } |
| 74 | |||
| 75 | return stereoInputChanged; | ||
| 76 | } | 82 | } |
| 77 | 83 | ||
| 78 | bool AudioScriptingInterface::isStereoInput() { | 84 | bool AudioScriptingInterface::isStereoInput() { |