Remove blocking invoke calls from Recording API

This commit is contained in:
ksuprynowicz 2024-05-20 00:00:32 +02:00
parent fe6d76b935
commit 57864178c0

View file

@ -129,21 +129,11 @@ void RecordingScriptingInterface::loadRecording(const QString& url, const Script
} }
void RecordingScriptingInterface::startPlaying() { void RecordingScriptingInterface::startPlaying() {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "startPlaying");
return;
}
Locker(_mutex); Locker(_mutex);
_player->play(); _player->play();
} }
void RecordingScriptingInterface::setPlayerVolume(float volume) { void RecordingScriptingInterface::setPlayerVolume(float volume) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "setPlayerVolume", Q_ARG(float, volume));
return;
}
Locker(_mutex); Locker(_mutex);
_player->setVolume(std::min(std::max(volume, 0.0f), 1.0f)); _player->setVolume(std::min(std::max(volume, 0.0f), 1.0f));
} }
@ -153,10 +143,6 @@ void RecordingScriptingInterface::setPlayerAudioOffset(float audioOffset) {
} }
void RecordingScriptingInterface::setPlayerTime(float time) { void RecordingScriptingInterface::setPlayerTime(float time) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "setPlayerTime", Q_ARG(float, time));
return;
}
Locker(_mutex); Locker(_mutex);
_player->seek(time); _player->seek(time);
} }
@ -166,11 +152,6 @@ void RecordingScriptingInterface::setPlayFromCurrentLocation(bool playFromCurren
} }
void RecordingScriptingInterface::setPlayerLoop(bool loop) { void RecordingScriptingInterface::setPlayerLoop(bool loop) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "setPlayerLoop", Q_ARG(bool, loop));
return;
}
Locker(_mutex); Locker(_mutex);
_player->loop(loop); _player->loop(loop);
} }
@ -192,19 +173,11 @@ void RecordingScriptingInterface::setPlayerUseSkeletonModel(bool useSkeletonMode
} }
void RecordingScriptingInterface::pausePlayer() { void RecordingScriptingInterface::pausePlayer() {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "pausePlayer");
return;
}
Locker(_mutex); Locker(_mutex);
_player->pause(); _player->pause();
} }
void RecordingScriptingInterface::stopPlaying() { void RecordingScriptingInterface::stopPlaying() {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "stopPlaying");
return;
}
Locker(_mutex); Locker(_mutex);
_player->stop(); _player->stop();
} }
@ -223,11 +196,6 @@ void RecordingScriptingInterface::startRecording() {
return; return;
} }
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "startRecording");
return;
}
Locker(_mutex); Locker(_mutex);
_recorder->start(); _recorder->start();
} }
@ -238,11 +206,6 @@ void RecordingScriptingInterface::stopRecording() {
return; return;
} }
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "stopRecording");
return;
}
Locker(_mutex); Locker(_mutex);
_recorder->stop(); _recorder->stop();
_lastClip = _recorder->getClip(); _lastClip = _recorder->getClip();
@ -258,12 +221,6 @@ QString RecordingScriptingInterface::getDefaultRecordingSaveDirectory() {
} }
void RecordingScriptingInterface::saveRecording(const QString& filename) { void RecordingScriptingInterface::saveRecording(const QString& filename) {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "saveRecording",
Q_ARG(QString, filename));
return;
}
Locker(_mutex); Locker(_mutex);
if (!_lastClip) { if (!_lastClip) {
qWarning() << "There is no recording to save"; qWarning() << "There is no recording to save";
@ -316,11 +273,6 @@ bool RecordingScriptingInterface::saveRecordingToAsset(const ScriptValue& getCli
} }
void RecordingScriptingInterface::loadLastRecording() { void RecordingScriptingInterface::loadLastRecording() {
if (QThread::currentThread() != thread()) {
BLOCKING_INVOKE_METHOD(this, "loadLastRecording");
return;
}
Locker(_mutex); Locker(_mutex);
if (!_lastClip) { if (!_lastClip) {