diff options
author | Max Kellermann <max@musicpd.org> | 2016-12-14 13:01:17 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-12-14 13:01:17 +0100 |
commit | baa2bc0c3836fcf5f2953ee3edfb5fa62590fe1f (patch) | |
tree | 3c9433420c698faa42a6cc10efe93f72ef16b7b6 /src/player | |
parent | 7e1b53480ef9a3f0a495c7af434d2df9b2a19ca6 (diff) |
player/Control: add method LockSetOutputError()
Diffstat (limited to 'src/player')
-rw-r--r-- | src/player/Control.hxx | 16 | ||||
-rw-r--r-- | src/player/Thread.cxx | 12 |
2 files changed, 18 insertions, 10 deletions
diff --git a/src/player/Control.hxx b/src/player/Control.hxx index 798aeacce..0db6698dd 100644 --- a/src/player/Control.hxx +++ b/src/player/Control.hxx @@ -370,6 +370,22 @@ public: void SetError(PlayerError type, std::exception_ptr &&_error); /** + * Set the error and set state to PlayerState::PAUSE. + */ + void SetOutputError(std::exception_ptr &&_error) { + SetError(PlayerError::OUTPUT, std::move(_error)); + + /* pause: the user may resume playback as soon as an + audio output becomes available */ + state = PlayerState::PAUSE; + } + + void LockSetOutputError(std::exception_ptr &&_error) { + const ScopeLock lock(mutex); + SetOutputError(std::move(_error)); + } + + /** * Checks whether an error has occurred, and if so, rethrows * it. * diff --git a/src/player/Thread.cxx b/src/player/Thread.cxx index 320f12859..e1144a55c 100644 --- a/src/player/Thread.cxx +++ b/src/player/Thread.cxx @@ -461,10 +461,7 @@ Player::OpenOutput() audio output becomes available */ paused = true; - pc.Lock(); - pc.SetError(PlayerError::OUTPUT, std::current_exception()); - pc.state = PlayerState::PAUSE; - pc.Unlock(); + pc.LockSetOutputError(std::current_exception()); idle_add(IDLE_PLAYER); @@ -911,16 +908,11 @@ Player::PlayNextChunk() buffer.Return(chunk); - pc.Lock(); - - pc.SetError(PlayerError::OUTPUT, std::current_exception()); - /* pause: the user may resume playback as soon as an audio output becomes available */ - pc.state = PlayerState::PAUSE; paused = true; - pc.Unlock(); + pc.LockSetOutputError(std::current_exception()); idle_add(IDLE_PLAYER); |