Commit c344d63f authored by Max Kellermann's avatar Max Kellermann

decoder_internal: don't call input_stream_buffer()

This is not necessary since all relevant input plugins have been moved to the I/O thread, and there is no remaining useful buffer() implementation. This also fixes a busy loop when playing radio.
parent 62557f4d
...@@ -202,8 +202,7 @@ decoder_timestamp(struct decoder *decoder, double t) ...@@ -202,8 +202,7 @@ decoder_timestamp(struct decoder *decoder, double t)
* (decoder.chunk) if there is one. * (decoder.chunk) if there is one.
*/ */
static enum decoder_command static enum decoder_command
do_send_tag(struct decoder *decoder, struct input_stream *is, do_send_tag(struct decoder *decoder, const struct tag *tag)
const struct tag *tag)
{ {
struct music_chunk *chunk; struct music_chunk *chunk;
...@@ -216,7 +215,7 @@ do_send_tag(struct decoder *decoder, struct input_stream *is, ...@@ -216,7 +215,7 @@ do_send_tag(struct decoder *decoder, struct input_stream *is,
assert(decoder->chunk == NULL); assert(decoder->chunk == NULL);
chunk = decoder_get_chunk(decoder, is); chunk = decoder_get_chunk(decoder);
if (chunk == NULL) { if (chunk == NULL) {
assert(decoder->dc->command != DECODE_COMMAND_NONE); assert(decoder->dc->command != DECODE_COMMAND_NONE);
return decoder->dc->command; return decoder->dc->command;
...@@ -283,11 +282,11 @@ decoder_data(struct decoder *decoder, ...@@ -283,11 +282,11 @@ decoder_data(struct decoder *decoder,
tag = tag_merge(decoder->decoder_tag, tag = tag_merge(decoder->decoder_tag,
decoder->stream_tag); decoder->stream_tag);
cmd = do_send_tag(decoder, is, tag); cmd = do_send_tag(decoder, tag);
tag_free(tag); tag_free(tag);
} else } else
/* send only the stream tag */ /* send only the stream tag */
cmd = do_send_tag(decoder, is, decoder->stream_tag); cmd = do_send_tag(decoder, decoder->stream_tag);
if (cmd != DECODE_COMMAND_NONE) if (cmd != DECODE_COMMAND_NONE)
return cmd; return cmd;
...@@ -313,7 +312,7 @@ decoder_data(struct decoder *decoder, ...@@ -313,7 +312,7 @@ decoder_data(struct decoder *decoder,
size_t nbytes; size_t nbytes;
bool full; bool full;
chunk = decoder_get_chunk(decoder, is); chunk = decoder_get_chunk(decoder);
if (chunk == NULL) { if (chunk == NULL) {
assert(dc->command != DECODE_COMMAND_NONE); assert(dc->command != DECODE_COMMAND_NONE);
return dc->command; return dc->command;
...@@ -392,11 +391,11 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is, ...@@ -392,11 +391,11 @@ decoder_tag(G_GNUC_UNUSED struct decoder *decoder, struct input_stream *is,
struct tag *merged; struct tag *merged;
merged = tag_merge(decoder->stream_tag, decoder->decoder_tag); merged = tag_merge(decoder->stream_tag, decoder->decoder_tag);
cmd = do_send_tag(decoder, is, merged); cmd = do_send_tag(decoder, merged);
tag_free(merged); tag_free(merged);
} else } else
/* send only the decoder tag */ /* send only the decoder tag */
cmd = do_send_tag(decoder, is, tag); cmd = do_send_tag(decoder, tag);
return cmd; return cmd;
} }
......
...@@ -28,41 +28,17 @@ ...@@ -28,41 +28,17 @@
#include <assert.h> #include <assert.h>
/** /**
* This is a wrapper for input_stream_buffer(). It assumes that the
* decoder is currently locked, and temporarily unlocks it while
* calling input_stream_buffer(). We shouldn't hold the lock during a
* potentially blocking operation.
*/
static bool
decoder_input_buffer(struct decoder_control *dc, struct input_stream *is)
{
GError *error = NULL;
int ret;
decoder_unlock(dc);
ret = input_stream_buffer(is, &error);
if (ret < 0) {
g_warning("%s", error->message);
g_error_free(error);
}
decoder_lock(dc);
return ret > 0;
}
/**
* All chunks are full of decoded data; wait for the player to free * All chunks are full of decoded data; wait for the player to free
* one. * one.
*/ */
static enum decoder_command static enum decoder_command
need_chunks(struct decoder_control *dc, struct input_stream *is, bool do_wait) need_chunks(struct decoder_control *dc, bool do_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 || !decoder_input_buffer(dc, is)) && do_wait) { if (do_wait) {
decoder_wait(dc); decoder_wait(dc);
g_cond_signal(dc->client_cond); g_cond_signal(dc->client_cond);
...@@ -73,7 +49,7 @@ need_chunks(struct decoder_control *dc, struct input_stream *is, bool do_wait) ...@@ -73,7 +49,7 @@ need_chunks(struct decoder_control *dc, struct input_stream *is, bool do_wait)
} }
struct music_chunk * struct music_chunk *
decoder_get_chunk(struct decoder *decoder, struct input_stream *is) decoder_get_chunk(struct decoder *decoder)
{ {
struct decoder_control *dc = decoder->dc; struct decoder_control *dc = decoder->dc;
enum decoder_command cmd; enum decoder_command cmd;
...@@ -96,7 +72,7 @@ decoder_get_chunk(struct decoder *decoder, struct input_stream *is) ...@@ -96,7 +72,7 @@ decoder_get_chunk(struct decoder *decoder, struct input_stream *is)
} }
decoder_lock(dc); decoder_lock(dc);
cmd = need_chunks(dc, is, true); cmd = need_chunks(dc, true);
decoder_unlock(dc); decoder_unlock(dc);
} while (cmd == DECODE_COMMAND_NONE); } while (cmd == DECODE_COMMAND_NONE);
......
...@@ -70,7 +70,7 @@ struct decoder { ...@@ -70,7 +70,7 @@ struct decoder {
* @return the chunk, or NULL if we have received a decoder command * @return the chunk, or NULL if we have received a decoder command
*/ */
struct music_chunk * struct music_chunk *
decoder_get_chunk(struct decoder *decoder, struct input_stream *is); decoder_get_chunk(struct decoder *decoder);
/** /**
* Flushes the current chunk. * Flushes the current chunk.
......
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