Commit 2860b1b6 authored by Max Kellermann's avatar Max Kellermann

decoder: wait for the player only if the music pipe is full

Prevent superfluous wakeups and a deadlock condition.
parent 1a3945b5
...@@ -159,13 +159,13 @@ tag_add_stream_tags(const struct tag *src_tag, const struct input_stream *is) ...@@ -159,13 +159,13 @@ tag_add_stream_tags(const struct tag *src_tag, const struct input_stream *is)
* one. * one.
*/ */
static enum decoder_command static enum decoder_command
need_chunks(struct input_stream *is) need_chunks(struct input_stream *is, bool wait)
{ {
if (dc.command == DECODE_COMMAND_STOP || if (dc.command == DECODE_COMMAND_STOP ||
dc.command == DECODE_COMMAND_SEEK) dc.command == DECODE_COMMAND_SEEK)
return dc.command; 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_wait(&dc.notify);
notify_signal(&pc.notify); notify_signal(&pc.notify);
} }
...@@ -255,7 +255,8 @@ decoder_data(struct decoder *decoder, ...@@ -255,7 +255,8 @@ decoder_data(struct decoder *decoder,
data += nbytes; data += nbytes;
if (length > 0) { if (length > 0) {
enum decoder_command cmd = need_chunks(is); enum decoder_command cmd =
need_chunks(is, nbytes == 0);
if (cmd != DECODE_COMMAND_NONE) if (cmd != DECODE_COMMAND_NONE)
return cmd; return cmd;
} }
...@@ -276,7 +277,7 @@ decoder_tag(mpd_unused struct decoder *decoder, struct input_stream *is, ...@@ -276,7 +277,7 @@ decoder_tag(mpd_unused struct decoder *decoder, struct input_stream *is,
tag = tag2; tag = tag2;
while (!music_pipe_tag(tag)) { 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) if (cmd != DECODE_COMMAND_NONE)
return cmd; return cmd;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment