thread/Mutex: remove ScopeLock, use std::lock_guard directly
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user