Add missing threading checks to Recording API methods

This commit is contained in:
David Rowe 2019-10-16 09:17:29 +13:00
parent e708cb98bb
commit 185d6990eb

View file

@ -64,6 +64,11 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader,
}
void RecordingScriptingInterface::loadRecording(const QString& url, QScriptValue callback) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "loadRecording", Q_ARG(const QString&, url), Q_ARG(QScriptValue, callback));
return;
}
auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url);
if (clipLoader->isLoaded()) {
@ -117,6 +122,11 @@ void RecordingScriptingInterface::startPlaying() {
}
void RecordingScriptingInterface::setPlayerVolume(float volume) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "setPlayerVolume", Q_ARG(float, volume));
return;
}
_player->setVolume(std::min(std::max(volume, 0.0f), 1.0f));
}
@ -137,6 +147,11 @@ void RecordingScriptingInterface::setPlayFromCurrentLocation(bool playFromCurren
}
void RecordingScriptingInterface::setPlayerLoop(bool loop) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "setPlayerLoop", Q_ARG(bool, loop));
return;
}
_player->loop(loop);
}
@ -200,6 +215,11 @@ void RecordingScriptingInterface::stopRecording() {
return;
}
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "stopRecording");
return;
}
_recorder->stop();
_lastClip = _recorder->getClip();
_lastClip->seek(0);