Showing the changes to libraries/script-engine/src/AudioScriptingInterface.cpp (1 of 7 files). Show all
Unified · Split
| @@ -11,6 +11,7 @@ · 10 unmodified lines | |||
| 11 | 11 | ||
| 12 | #include "AudioScriptingInterface.h" | 12 | #include "AudioScriptingInterface.h" |
| 13 | 13 | ||
| 14 | #include "AudioClient.h" | ||
| 14 | #include "ScriptAudioInjector.h" | 15 | #include "ScriptAudioInjector.h" |
| 15 | #include "ScriptEngineLogging.h" | 16 | #include "ScriptEngineLogging.h" |
| 16 | 17 | ||
| @@ -46,24 +47,7 @@ ScriptAudioInjector* AudioScriptingInterface::playSound(Sound* sound, const Audi · 29 unmodified lines | |||
| 46 | AudioInjectorOptions optionsCopy = injectorOptions; | 47 | AudioInjectorOptions optionsCopy = injectorOptions; |
| 47 | optionsCopy.stereo = sound->isStereo(); | 48 | optionsCopy.stereo = sound->isStereo(); |
| 48 | 49 | ||
| 49 | QThread* injectorThread = new QThread(); | 50 | return new ScriptAudioInjector(DependencyManager::get<AudioClient>()->playSound(sound->getByteArray(), optionsCopy)); |
| 50 | injectorThread->setObjectName("Audio Injector Thread"); | ||
| 51 | |||
| 52 | AudioInjector* injector = new AudioInjector(sound, optionsCopy); | ||
| 53 | injector->setLocalAudioInterface(_localAudioInterface); | ||
| 54 | |||
| 55 | injector->moveToThread(injectorThread); | ||
| 56 | |||
| 57 | // start injecting when the injector thread starts | ||
| 58 | connect(injectorThread, &QThread::started, injector, &AudioInjector::injectAudio); | ||
| 59 | |||
| 60 | // connect the right slots and signals for AudioInjector and thread cleanup | ||
| 61 | connect(injector, &AudioInjector::destroyed, injectorThread, &QThread::quit); | ||
| 62 | connect(injectorThread, &QThread::finished, injectorThread, &QThread::deleteLater); | ||
| 63 | |||
| 64 | injectorThread->start(); | ||
| 65 | |||
| 66 | return new ScriptAudioInjector(injector); | ||
| 67 | 51 | ||
| 68 | } else { | 52 | } else { |
| 69 | qCDebug(scriptengine) << "AudioScriptingInterface::playSound called with null Sound object."; | 53 | qCDebug(scriptengine) << "AudioScriptingInterface::playSound called with null Sound object."; |