aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder_api.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-25 19:47:33 +0100
committerMax Kellermann <max@duempel.org>2009-12-26 03:01:43 +0100
commitbad350bc18ab81661253bf42245b9e3fa175d026 (patch)
tree47a1dd5d4b81520eb9ae1ce407d2fea84d71736f /src/decoder_api.c
parent870436a592b081c4630b9ecc36ff8daecf6496cc (diff)
downloadmpd-bad350bc18ab81661253bf42245b9e3fa175d026.tar.gz
mpd-bad350bc18ab81661253bf42245b9e3fa175d026.tar.xz
mpd-bad350bc18ab81661253bf42245b9e3fa175d026.zip
decoder_api: added function decoder_timestamp()
Remove the data_time parameter from decoder_data(). This patch eliminates the timestamp counting in most decoder plugins, because the MPD core will do it automatically by default.
Diffstat (limited to '')
-rw-r--r--src/decoder_api.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/decoder_api.c b/src/decoder_api.c
index ae2c6687b..dde27727b 100644
--- a/src/decoder_api.c
+++ b/src/decoder_api.c
@@ -95,7 +95,8 @@ enum decoder_command decoder_get_command(G_GNUC_UNUSED struct decoder * decoder)
return dc->command;
}
-void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
+void
+decoder_command_finished(struct decoder *decoder)
{
struct decoder_control *dc = decoder->dc;
@@ -115,6 +116,8 @@ void decoder_command_finished(G_GNUC_UNUSED struct decoder * decoder)
}
music_pipe_clear(dc->pipe, dc->buffer);
+
+ decoder->timestamp = dc->seek_where;
}
dc->command = DECODE_COMMAND_NONE;
@@ -192,6 +195,15 @@ size_t decoder_read(struct decoder *decoder,
}
}
+void
+decoder_timestamp(struct decoder *decoder, double t)
+{
+ assert(decoder != NULL);
+ assert(t >= 0);
+
+ decoder->timestamp = t;
+}
+
/**
* Sends a #tag as-is to the music pipe. Flushes the current chunk
* (decoder.chunk) if there is one.
@@ -250,7 +262,7 @@ enum decoder_command
decoder_data(struct decoder *decoder,
struct input_stream *is,
const void *_data, size_t length,
- float data_time, uint16_t bitRate,
+ uint16_t kbit_rate,
struct replay_gain_info *replay_gain_info)
{
struct decoder_control *dc = decoder->dc;
@@ -316,7 +328,8 @@ decoder_data(struct decoder *decoder,
}
dest = music_chunk_write(chunk, &dc->out_audio_format,
- data_time, bitRate, &nbytes);
+ decoder->timestamp, kbit_rate,
+ &nbytes);
if (dest == NULL) {
/* the chunk is full, flush it */
decoder_flush_chunk(decoder);
@@ -350,6 +363,9 @@ decoder_data(struct decoder *decoder,
data += nbytes;
length -= nbytes;
+
+ decoder->timestamp += (double)nbytes /
+ audio_format_time_to_size(&dc->in_audio_format);
}
return DECODE_COMMAND_NONE;