diff options
author | Max Kellermann <max@duempel.org> | 2008-04-12 04:21:00 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:21:00 +0000 |
commit | 7dc1f3117c966f0403fb19eaceb9f3bed65ead5f (patch) | |
tree | 3bd43cb54529d44e24a9ae6c775176b7151ce256 /src/outputBuffer.c | |
parent | 91b43b481dfab06de99a715c2e69f4c14c780abc (diff) | |
download | mpd-7dc1f3117c966f0403fb19eaceb9f3bed65ead5f.tar.gz mpd-7dc1f3117c966f0403fb19eaceb9f3bed65ead5f.tar.xz mpd-7dc1f3117c966f0403fb19eaceb9f3bed65ead5f.zip |
wake up player on demand
The decoder should not wake up the player when it did not produce a
flushed chunk. Move the decoder_wakeup_player() call to
flushOutputBuffer() and invoke it only if the buffer was previously
empty.
git-svn-id: https://svn.musicpd.org/mpd/trunk@7336 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/outputBuffer.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/outputBuffer.c b/src/outputBuffer.c index 006496453..a2cfed48e 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -55,8 +55,17 @@ static inline unsigned successor(const OutputBuffer * cb, unsigned i) void flushOutputBuffer(OutputBuffer * cb) { if (cb->currentChunk == (int)cb->end) { + int was_empty = outputBufferEmpty(cb); + cb->end = successor(cb, cb->end); cb->currentChunk = -1; + + if (was_empty) + /* if the buffer was empty, the player thread + might be waiting for us; wake it up now + that another decoded buffer has become + available. */ + decoder_wakeup_player(); } } @@ -214,7 +223,6 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, flushOutputBuffer(cb); } } - decoder_wakeup_player(); return 0; } |