From bad350bc18ab81661253bf42245b9e3fa175d026 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 25 Dec 2009 19:47:33 +0100 Subject: 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. --- src/decoder/mpcdec_plugin.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/decoder/mpcdec_plugin.c') diff --git a/src/decoder/mpcdec_plugin.c b/src/decoder/mpcdec_plugin.c index bf27ec314..a186bc368 100644 --- a/src/decoder/mpcdec_plugin.c +++ b/src/decoder/mpcdec_plugin.c @@ -152,10 +152,8 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) mpc_uint32_t ret; int32_t chunk[G_N_ELEMENTS(sample_buffer)]; long bit_rate = 0; - unsigned long sample_pos = 0; mpc_uint32_t vbr_update_acc; mpc_uint32_t vbr_update_bits; - float total_time; struct replay_gain_info *replay_gain_info = NULL; enum decoder_command cmd = DECODE_COMMAND_NONE; @@ -219,16 +217,14 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) do { if (cmd == DECODE_COMMAND_SEEK) { - bool success; - - sample_pos = decoder_seek_where(mpd_decoder) * + mpc_int64_t where = decoder_seek_where(mpd_decoder) * audio_format.sample_rate; + bool success; #ifdef MPC_IS_OLD_API - success = mpc_decoder_seek_sample(&decoder, - sample_pos); + success = mpc_decoder_seek_sample(&decoder, where); #else - success = mpc_demux_seek_sample(demux, sample_pos) + success = mpc_demux_seek_sample(demux, where) == MPC_STATUS_OK; #endif if (success) @@ -259,19 +255,15 @@ mpcdec_decode(struct decoder *mpd_decoder, struct input_stream *is) ret = frame.samples; #endif - sample_pos += ret; - ret *= info.channels; mpc_to_mpd_buffer(chunk, sample_buffer, ret); - total_time = ((float)sample_pos) / audio_format.sample_rate; bit_rate = vbr_update_bits * audio_format.sample_rate / 1152 / 1000; cmd = decoder_data(mpd_decoder, is, chunk, ret * sizeof(chunk[0]), - total_time, bit_rate, replay_gain_info); } while (cmd != DECODE_COMMAND_STOP); -- cgit v1.2.3