aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_api.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_api.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 '')
-rw-r--r--src/decoder_api.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index 88864befa..0992eac9a 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -23,6 +23,7 @@
#include "player_control.h"
#include "audio.h"
#include "song.h"
+#include "buffer.h"
#include "normalize.h"
#include "pipe.h"
@@ -90,11 +91,11 @@ void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
/* delete frames from the old song position */
if (decoder->chunk != NULL) {
- music_pipe_cancel(decoder->chunk);
+ music_buffer_return(dc.buffer, decoder->chunk);
decoder->chunk = NULL;
}
- music_pipe_clear();
+ music_pipe_clear(dc.pipe, dc.buffer);
}
dc.command = DECODE_COMMAND_NONE;
@@ -167,15 +168,18 @@ do_send_tag(struct decoder *decoder, struct input_stream *is,
if (decoder->chunk != NULL) {
/* there is a partial chunk - flush it, we want the
tag in a new chunk */
- enum decoder_command cmd =
- decoder_flush_chunk(decoder, is);
- if (cmd != DECODE_COMMAND_NONE)
- return cmd;
+ decoder_flush_chunk(decoder);
+ notify_signal(&pc.notify);
}
assert(decoder->chunk == NULL);
- chunk = decoder_get_chunk(decoder);
+ chunk = decoder_get_chunk(decoder, is);
+ if (chunk == NULL) {
+ assert(dc.command != DECODE_COMMAND_NONE);
+ return dc.command;
+ }
+
chunk->tag = tag_dup(tag);
return DECODE_COMMAND_NONE;
}
@@ -256,15 +260,18 @@ decoder_data(struct decoder *decoder,
size_t nbytes;
bool full;
- chunk = decoder_get_chunk(decoder);
+ chunk = decoder_get_chunk(decoder, is);
+ if (chunk == NULL) {
+ assert(dc.command != DECODE_COMMAND_NONE);
+ return dc.command;
+ }
+
dest = music_chunk_write(chunk, &dc.out_audio_format,
data_time, bitRate, &nbytes);
if (dest == NULL) {
/* the chunk is full, flush it */
- enum decoder_command cmd =
- decoder_flush_chunk(decoder, is);
- if (cmd != DECODE_COMMAND_NONE)
- return cmd;
+ decoder_flush_chunk(decoder);
+ notify_signal(&pc.notify);
continue;
}
@@ -291,10 +298,8 @@ decoder_data(struct decoder *decoder,
full = music_chunk_expand(chunk, &dc.out_audio_format, nbytes);
if (full) {
/* the chunk is full, flush it */
- enum decoder_command cmd =
- decoder_flush_chunk(decoder, is);
- if (cmd != DECODE_COMMAND_NONE)
- return cmd;
+ decoder_flush_chunk(decoder);
+ notify_signal(&pc.notify);
}
data += nbytes;