From 7dc1f3117c966f0403fb19eaceb9f3bed65ead5f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 12 Apr 2008 04:21:00 +0000 Subject: 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 --- src/outputBuffer.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/outputBuffer.c') 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; } -- cgit v1.2.3