fix locker issue

This commit is contained in:
HifiExperiments 2024-06-06 11:31:50 -07:00
parent 2ae2f29b29
commit 444d52070a
2 changed files with 19 additions and 19 deletions

View file

@ -38,33 +38,33 @@ using namespace recording;
static const QString HFR_EXTENSION = "hfr"; static const QString HFR_EXTENSION = "hfr";
RecordingScriptingInterface::RecordingScriptingInterface() { RecordingScriptingInterface::RecordingScriptingInterface() {
Locker(_mutex); Locker lock(_mutex);
_player = DependencyManager::get<Deck>(); _player = DependencyManager::get<Deck>();
_recorder = DependencyManager::get<Recorder>(); _recorder = DependencyManager::get<Recorder>();
} }
bool RecordingScriptingInterface::isPlaying() const { bool RecordingScriptingInterface::isPlaying() const {
Locker(_mutex); Locker lock(_mutex);
return _player->isPlaying(); return _player->isPlaying();
} }
bool RecordingScriptingInterface::isPaused() const { bool RecordingScriptingInterface::isPaused() const {
Locker(_mutex); Locker lock(_mutex);
return _player->isPaused(); return _player->isPaused();
} }
float RecordingScriptingInterface::playerElapsed() const { float RecordingScriptingInterface::playerElapsed() const {
Locker(_mutex); Locker lock(_mutex);
return _player->position(); return _player->position();
} }
float RecordingScriptingInterface::playerLength() const { float RecordingScriptingInterface::playerLength() const {
Locker(_mutex); Locker lock(_mutex);
return _player->length(); return _player->length();
} }
void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, const QString& url, const ScriptValue& callback) { void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader, const QString& url, const ScriptValue& callback) {
Locker(_mutex); Locker lock(_mutex);
_player->queueClip(clipLoader->getClip()); _player->queueClip(clipLoader->getClip());
if (callback.isFunction()) { if (callback.isFunction()) {
@ -75,7 +75,7 @@ void RecordingScriptingInterface::playClip(NetworkClipLoaderPointer clipLoader,
} }
void RecordingScriptingInterface::loadRecording(const QString& url, const ScriptValue& callback) { void RecordingScriptingInterface::loadRecording(const QString& url, const ScriptValue& callback) {
Locker(_mutex); Locker lock(_mutex);
auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url); auto clipLoader = DependencyManager::get<recording::ClipCache>()->getClipLoader(url);
@ -134,12 +134,12 @@ void RecordingScriptingInterface::startPlaying() {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
_player->play(); _player->play();
} }
void RecordingScriptingInterface::setPlayerVolume(float volume) { void RecordingScriptingInterface::setPlayerVolume(float volume) {
Locker(_mutex); Locker lock(_mutex);
_player->setVolume(std::min(std::max(volume, 0.0f), 1.0f)); _player->setVolume(std::min(std::max(volume, 0.0f), 1.0f));
} }
@ -153,7 +153,7 @@ void RecordingScriptingInterface::setPlayerTime(float time) {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
_player->seek(time); _player->seek(time);
} }
@ -162,7 +162,7 @@ void RecordingScriptingInterface::setPlayFromCurrentLocation(bool playFromCurren
} }
void RecordingScriptingInterface::setPlayerLoop(bool loop) { void RecordingScriptingInterface::setPlayerLoop(bool loop) {
Locker(_mutex); Locker lock(_mutex);
_player->loop(loop); _player->loop(loop);
} }
@ -183,7 +183,7 @@ void RecordingScriptingInterface::setPlayerUseSkeletonModel(bool useSkeletonMode
} }
void RecordingScriptingInterface::pausePlayer() { void RecordingScriptingInterface::pausePlayer() {
Locker(_mutex); Locker lock(_mutex);
_player->pause(); _player->pause();
} }
@ -193,7 +193,7 @@ void RecordingScriptingInterface::stopPlaying() {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
_player->stop(); _player->stop();
} }
@ -211,7 +211,7 @@ void RecordingScriptingInterface::startRecording() {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
_recorder->start(); _recorder->start();
} }
@ -221,7 +221,7 @@ void RecordingScriptingInterface::stopRecording() {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
_recorder->stop(); _recorder->stop();
_lastClip = _recorder->getClip(); _lastClip = _recorder->getClip();
_lastClip->seek(0); _lastClip->seek(0);
@ -236,7 +236,7 @@ QString RecordingScriptingInterface::getDefaultRecordingSaveDirectory() {
} }
void RecordingScriptingInterface::saveRecording(const QString& filename) { void RecordingScriptingInterface::saveRecording(const QString& filename) {
Locker(_mutex); Locker lock(_mutex);
if (!_lastClip) { if (!_lastClip) {
qWarning() << "There is no recording to save"; qWarning() << "There is no recording to save";
return; return;
@ -251,7 +251,7 @@ bool RecordingScriptingInterface::saveRecordingToAsset(const ScriptValue& getCli
return false; return false;
} }
Locker(_mutex); Locker lock(_mutex);
if (!_lastClip) { if (!_lastClip) {
qWarning() << "There is no recording to save"; qWarning() << "There is no recording to save";
return false; return false;
@ -293,7 +293,7 @@ void RecordingScriptingInterface::loadLastRecording() {
return; return;
} }
Locker(_mutex); Locker lock(_mutex);
if (!_lastClip) { if (!_lastClip) {
qCDebug(scriptengine) << "There is no recording to load"; qCDebug(scriptengine) << "There is no recording to load";

View file

@ -357,7 +357,7 @@ protected:
using Locker = std::unique_lock<Mutex>; using Locker = std::unique_lock<Mutex>;
using Flag = std::atomic<bool>; using Flag = std::atomic<bool>;
Mutex _mutex; mutable Mutex _mutex;
QSharedPointer<recording::Deck> _player; QSharedPointer<recording::Deck> _player;
QSharedPointer<recording::Recorder> _recorder; QSharedPointer<recording::Recorder> _recorder;