diff options
author | Max Kellermann <max@musicpd.org> | 2017-01-03 07:11:57 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2017-01-03 07:11:57 +0100 |
commit | 2e182e84c35c73f8d5b4f135ffa3550b7e70f66f (patch) | |
tree | 806ec01525f834132c46e6392714900ec75eada2 /src/player | |
parent | a42021655c3218c64272b648438197247ec7f6a9 (diff) |
thread/Mutex: remove ScopeLock, use std::lock_guard directly
Diffstat (limited to 'src/player')
-rw-r--r-- | src/player/Control.cxx | 18 | ||||
-rw-r--r-- | src/player/Control.hxx | 18 | ||||
-rw-r--r-- | src/player/Thread.cxx | 12 |
3 files changed, 24 insertions, 24 deletions
diff --git a/src/player/Control.cxx b/src/player/Control.cxx index 87620fc90..4d426266a 100644 --- a/src/player/Control.cxx +++ b/src/player/Control.cxx @@ -64,7 +64,7 @@ PlayerControl::Play(DetachedSong *song) { assert(song != nullptr); - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); SeekLocked(song, SongTime::zero()); if (state == PlayerState::PAUSE) @@ -118,14 +118,14 @@ PlayerControl::PauseLocked() void PlayerControl::LockPause() { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); PauseLocked(); } void PlayerControl::LockSetPause(bool pause_flag) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); switch (state) { case PlayerState::STOP: @@ -146,7 +146,7 @@ PlayerControl::LockSetPause(bool pause_flag) void PlayerControl::LockSetBorderPause(bool _border_pause) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); border_pause = _border_pause; } @@ -155,7 +155,7 @@ PlayerControl::LockGetStatus() { player_status status; - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); SynchronousCommand(PlayerCommand::REFRESH); status.state = state; @@ -183,14 +183,14 @@ PlayerControl::SetError(PlayerError type, std::exception_ptr &&_error) void PlayerControl::LockClearError() { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); ClearError(); } void PlayerControl::LockSetTaggedSong(const DetachedSong &song) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); delete tagged_song; tagged_song = new DetachedSong(song); } @@ -207,7 +207,7 @@ PlayerControl::LockEnqueueSong(DetachedSong *song) { assert(song != nullptr); - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); EnqueueSongLocked(song); } @@ -246,7 +246,7 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t) assert(song != nullptr); { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); SeekLocked(song, t); } diff --git a/src/player/Control.hxx b/src/player/Control.hxx index 6d3e70647..608351306 100644 --- a/src/player/Control.hxx +++ b/src/player/Control.hxx @@ -224,7 +224,7 @@ struct PlayerControl final : AudioOutputClient { * this function. */ void LockSignal() { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); Signal(); } @@ -277,7 +277,7 @@ struct PlayerControl final : AudioOutputClient { } void LockCommandFinished() { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); CommandFinished(); } @@ -294,7 +294,7 @@ struct PlayerControl final : AudioOutputClient { bool WaitOutputConsumed(unsigned threshold); bool LockWaitOutputConsumed(unsigned threshold) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); return WaitOutputConsumed(threshold); } @@ -333,7 +333,7 @@ private: * object. */ void LockSynchronousCommand(PlayerCommand cmd) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); SynchronousCommand(cmd); } @@ -376,7 +376,7 @@ public: } bool LockApplyBorderPause() { - const ScopeLock lock(mutex); + const std::lock_guard<Mutex> lock(mutex); return ApplyBorderPause(); } @@ -410,7 +410,7 @@ public: } void LockSetOutputError(std::exception_ptr &&_error) { - const ScopeLock lock(mutex); + const std::lock_guard<Mutex> lock(mutex); SetOutputError(std::move(_error)); } @@ -429,7 +429,7 @@ public: * Like CheckRethrowError(), but locks and unlocks the object. */ void LockCheckRethrowError() const { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); CheckRethrowError(); } @@ -462,7 +462,7 @@ public: * Like ReadTaggedSong(), but locks and unlocks the object. */ DetachedSong *LockReadTaggedSong() { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); return ReadTaggedSong(); } @@ -521,7 +521,7 @@ public: } void LockSetReplayGainMode(ReplayGainMode _mode) { - const ScopeLock protect(mutex); + const std::lock_guard<Mutex> protect(mutex); replay_gain_mode = _mode; } diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 6d927df41..1426c98f4 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -213,7 +213,7 @@ private: * allowed to be used while a command is being handled. */ bool WaitDecoderStartup() { - const ScopeLock lock(pc.mutex); + const std::lock_guard<Mutex> lock(pc.mutex); while (decoder_starting) { if (!CheckDecoderStartup()) { @@ -351,7 +351,7 @@ Player::StartDecoder(MusicPipe &_pipe) { /* copy ReplayGain parameters to the decoder */ - const ScopeLock protect(pc.mutex); + const std::lock_guard<Mutex> protect(pc.mutex); dc.replay_gain_mode = pc.replay_gain_mode; } @@ -406,7 +406,7 @@ Player::ActivateDecoder() queued = false; { - const ScopeLock lock(pc.mutex); + const std::lock_guard<Mutex> lock(pc.mutex); pc.ClearTaggedSong(); @@ -787,7 +787,7 @@ play_chunk(PlayerControl &pc, } { - const ScopeLock lock(pc.mutex); + const std::lock_guard<Mutex> lock(pc.mutex); pc.bit_rate = chunk->bit_rate; } @@ -863,7 +863,7 @@ Player::PlayNextChunk() } else { /* there are not enough decoded chunks yet */ - const ScopeLock lock(pc.mutex); + const std::lock_guard<Mutex> lock(pc.mutex); if (dc.IsIdle()) { /* the decoder isn't running, abort @@ -911,7 +911,7 @@ Player::PlayNextChunk() return false; } - const ScopeLock lock(pc.mutex); + const std::lock_guard<Mutex> lock(pc.mutex); /* this formula should prevent that the decoder gets woken up with each chunk; it is more efficient to make it decode a |