aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_internal.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-03-06 00:42:03 +0100
committerMax Kellermann <max@duempel.org>2009-03-06 00:42:03 +0100
commit01cf7feac7bef8b28605b98ef1e7438a995fc554 (patch)
treee1c4b7f5d0550d60d7fda8b4909353a47490fa4e /src/decoder_internal.c
parent000b2d4f3a9c4f761ab918aaff4705621bb8559f (diff)
downloadmpd-01cf7feac7bef8b28605b98ef1e7438a995fc554.tar.gz
mpd-01cf7feac7bef8b28605b98ef1e7438a995fc554.tar.xz
mpd-01cf7feac7bef8b28605b98ef1e7438a995fc554.zip
pipe: added music_buffer, rewrite music_pipe
Turn the music_pipe into a simple music_chunk queue. The music_chunk allocation code is moved to music_buffer, and is now managed with a linked list instead of a ring buffer. Two separate music_pipe objects are used by the decoder for the "current" and the "next" song, which greatly simplifies the cross-fading code.
Diffstat (limited to 'src/decoder_internal.c')
-rw-r--r--src/decoder_internal.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/decoder_internal.c b/src/decoder_internal.c
index 93ad80e5e..120115ed2 100644
--- a/src/decoder_internal.c
+++ b/src/decoder_internal.c
@@ -21,6 +21,7 @@
#include "player_control.h"
#include "pipe.h"
#include "input_stream.h"
+#include "buffer.h"
#include <assert.h>
@@ -46,35 +47,32 @@ need_chunks(struct input_stream *is, bool do_wait)
}
struct music_chunk *
-decoder_get_chunk(struct decoder *decoder)
+decoder_get_chunk(struct decoder *decoder, struct input_stream *is)
{
+ enum decoder_command cmd;
+
assert(decoder != NULL);
if (decoder->chunk != NULL)
return decoder->chunk;
- decoder->chunk = music_pipe_allocate();
- return decoder->chunk;
+ do {
+ decoder->chunk = music_buffer_allocate(dc.buffer);
+ if (decoder->chunk != NULL)
+ return decoder->chunk;
+
+ cmd = need_chunks(is, true);
+ } while (cmd == DECODE_COMMAND_NONE);
+
+ return NULL;
}
-enum decoder_command
-decoder_flush_chunk(struct decoder *decoder, struct input_stream *is)
+void
+decoder_flush_chunk(struct decoder *decoder)
{
- bool success;
- enum decoder_command cmd;
-
assert(decoder != NULL);
assert(decoder->chunk != NULL);
- while (true) {
- success = music_pipe_push(decoder->chunk);
- if (success) {
- decoder->chunk = NULL;
- return DECODE_COMMAND_NONE;
- }
-
- cmd = need_chunks(is, true);
- if (cmd != DECODE_COMMAND_NONE)
- return cmd;
- }
+ music_pipe_push(dc.pipe, decoder->chunk);
+ decoder->chunk = NULL;
}