diff options
author | Max Kellermann <max@duempel.org> | 2013-11-06 23:10:05 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-11-06 23:51:17 +0100 |
commit | 0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee (patch) | |
tree | 0e1a98376069ab299dbd701d7be40f8030da70f8 /src/DecoderControl.hxx | |
parent | 9802e74859219ae151cddb238f71016e3a2ef1ef (diff) | |
download | mpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.tar.gz mpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.tar.xz mpd-0be5a6ab2b9201e60f3ecb363fcc9342ecfa8aee.zip |
DecoderControl: reduce the number of PlayerThread wakeups
Wake up the PlayerThread only if it is really waiting for the decoder.
This greatly reduces the number of system calls in the DecoderThread.
Diffstat (limited to 'src/DecoderControl.hxx')
-rw-r--r-- | src/DecoderControl.hxx | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/DecoderControl.hxx b/src/DecoderControl.hxx index 23cb394ca..863398dca 100644 --- a/src/DecoderControl.hxx +++ b/src/DecoderControl.hxx @@ -97,6 +97,14 @@ struct DecoderControl { Error error; bool quit; + + /** + * Is the client currently waiting for the DecoderThread? If + * false, the DecoderThread may omit invoking Cond::signal(), + * reducing the number of system calls. + */ + bool client_is_waiting; + bool seek_error; bool seekable; double seek_where; @@ -193,10 +201,10 @@ struct DecoderControl { * Waits for a signal from the decoder thread. This object * must be locked prior to calling this function. This method * is only valid in the player thread. + * + * Caller must hold the lock. */ - void WaitForDecoder() { - client_cond.wait(mutex); - } + void WaitForDecoder(); bool IsIdle() const { return state == DecoderState::STOP || |