aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-13 02:54:56 +0100
committerMax Kellermann <max@duempel.org>2008-11-13 02:54:56 +0100
commit2860b1b60fdb99c714bf4041797982c4c32b594e (patch)
tree5a94afe989446ed49845d730e42946b4c68ecd86
parent1a3945b56331fc899c8c1a5e1e39af348fd9b4eb (diff)
downloadmpd-2860b1b60fdb99c714bf4041797982c4c32b594e.tar.gz
mpd-2860b1b60fdb99c714bf4041797982c4c32b594e.tar.xz
mpd-2860b1b60fdb99c714bf4041797982c4c32b594e.zip
decoder: wait for the player only if the music pipe is full
Prevent superfluous wakeups and a deadlock condition.
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index c8a13709c..ab8a5f961 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -159,13 +159,13 @@ tag_add_stream_tags(const struct tag *src_tag, const struct input_stream *is)
* one.
*/
static enum decoder_command
-need_chunks(struct input_stream *is)
+need_chunks(struct input_stream *is, bool wait)
{
if (dc.command == DECODE_COMMAND_STOP ||
dc.command == DECODE_COMMAND_SEEK)
return dc.command;
- if (is == NULL || input_stream_buffer(is) <= 0) {
+ if ((is == NULL || input_stream_buffer(is) <= 0) && wait) {
notify_wait(&dc.notify);
notify_signal(&pc.notify);
}
@@ -255,7 +255,8 @@ decoder_data(struct decoder *decoder,
data += nbytes;
if (length > 0) {
- enum decoder_command cmd = need_chunks(is);
+ enum decoder_command cmd =
+ need_chunks(is, nbytes == 0);
if (cmd != DECODE_COMMAND_NONE)
return cmd;
}
@@ -276,7 +277,7 @@ decoder_tag(mpd_unused struct decoder *decoder, struct input_stream *is,
tag = tag2;
while (!music_pipe_tag(tag)) {
- enum decoder_command cmd = need_chunks(is);
+ enum decoder_command cmd = need_chunks(is, true);
if (cmd != DECODE_COMMAND_NONE)
return cmd;
}