aboutsummaryrefslogtreecommitdiffstats
path: root/src/player/Control.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-11-11 17:41:48 +0100
committerMax Kellermann <max@duempel.org>2015-11-11 17:43:56 +0100
commitc6d1d360a3b7034c661bb348fda732177192390f (patch)
tree3866095e64f74a438a3fd7877e1f0105db312676 /src/player/Control.cxx
parentafc1236b066480656cd7285364a9d79dae01f763 (diff)
downloadmpd-c6d1d360a3b7034c661bb348fda732177192390f.tar.gz
mpd-c6d1d360a3b7034c661bb348fda732177192390f.tar.xz
mpd-c6d1d360a3b7034c661bb348fda732177192390f.zip
player/Control: use class ScopeLock
Diffstat (limited to 'src/player/Control.cxx')
-rw-r--r--src/player/Control.cxx34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/player/Control.cxx b/src/player/Control.cxx
index 290f61af8..4c30159ba 100644
--- a/src/player/Control.cxx
+++ b/src/player/Control.cxx
@@ -54,7 +54,7 @@ PlayerControl::Play(DetachedSong *song)
{
assert(song != nullptr);
- Lock();
+ const ScopeLock protect(mutex);
if (state != PlayerState::STOP)
SynchronousCommand(PlayerCommand::STOP);
@@ -64,8 +64,6 @@ PlayerControl::Play(DetachedSong *song)
EnqueueSongLocked(song);
assert(next_song == nullptr);
-
- Unlock();
}
void
@@ -113,15 +111,14 @@ PlayerControl::PauseLocked()
void
PlayerControl::LockPause()
{
- Lock();
+ const ScopeLock protect(mutex);
PauseLocked();
- Unlock();
}
void
PlayerControl::LockSetPause(bool pause_flag)
{
- Lock();
+ const ScopeLock protect(mutex);
switch (state) {
case PlayerState::STOP:
@@ -137,16 +134,13 @@ PlayerControl::LockSetPause(bool pause_flag)
PauseLocked();
break;
}
-
- Unlock();
}
void
PlayerControl::LockSetBorderPause(bool _border_pause)
{
- Lock();
+ const ScopeLock protect(mutex);
border_pause = _border_pause;
- Unlock();
}
player_status
@@ -154,7 +148,7 @@ PlayerControl::LockGetStatus()
{
player_status status;
- Lock();
+ const ScopeLock protect(mutex);
SynchronousCommand(PlayerCommand::REFRESH);
status.state = state;
@@ -166,8 +160,6 @@ PlayerControl::LockGetStatus()
status.elapsed_time = elapsed_time;
}
- Unlock();
-
return status;
}
@@ -184,18 +176,16 @@ PlayerControl::SetError(PlayerError type, Error &&_error)
void
PlayerControl::LockClearError()
{
- Lock();
+ const ScopeLock protect(mutex);
ClearError();
- Unlock();
}
void
PlayerControl::LockSetTaggedSong(const DetachedSong &song)
{
- Lock();
+ const ScopeLock protect(mutex);
delete tagged_song;
tagged_song = new DetachedSong(song);
- Unlock();
}
void
@@ -210,9 +200,8 @@ PlayerControl::LockEnqueueSong(DetachedSong *song)
{
assert(song != nullptr);
- Lock();
+ const ScopeLock protect(mutex);
EnqueueSongLocked(song);
- Unlock();
}
void
@@ -237,9 +226,10 @@ PlayerControl::LockSeek(DetachedSong *song, SongTime t)
{
assert(song != nullptr);
- Lock();
- SeekLocked(song, t);
- Unlock();
+ {
+ const ScopeLock protect(mutex);
+ SeekLocked(song, t);
+ }
idle_add(IDLE_PLAYER);