From 8d1ffb16843696d7df6c25a3006d7536b25c3c5c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 12 Nov 2008 07:07:12 +0100 Subject: mpc: get decoder command from decoder_data() Removed 3 superfluous decoder_get_command() invocations. --- src/decoder/mpc_plugin.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/decoder/mpc_plugin.c b/src/decoder/mpc_plugin.c index f3e54f4d2..34400f153 100644 --- a/src/decoder/mpc_plugin.c +++ b/src/decoder/mpc_plugin.c @@ -123,6 +123,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) mpc_uint32_t vbrUpdateBits; float total_time; struct replay_gain_info *replayGainInfo = NULL; + enum decoder_command cmd = DECODE_COMMAND_NONE; data.inStream = inStream; data.decoder = mpd_decoder; @@ -164,8 +165,8 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) inStream->seekable, mpc_streaminfo_get_length(&info)); - while (true) { - if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_SEEK) { + do { + if (cmd == DECODE_COMMAND_SEEK) { samplePos = decoder_seek_where(mpd_decoder) * audio_format.sample_rate; if (mpc_decoder_seek_sample(&decoder, samplePos)) @@ -178,8 +179,7 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) vbrUpdateBits = 0; ret = mpc_decoder_decode(&decoder, sample_buffer, &vbrUpdateAcc, &vbrUpdateBits); - - if (ret <= 0 || decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) + if (ret <= 0) break; samplePos += ret; @@ -193,14 +193,11 @@ mpc_decode(struct decoder *mpd_decoder, struct input_stream *inStream) bitRate = vbrUpdateBits * audio_format.sample_rate / 1152 / 1000; - decoder_data(mpd_decoder, inStream, - chunk, ret * sizeof(chunk[0]), - total_time, - bitRate, replayGainInfo); - - if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_STOP) - break; - } + cmd = decoder_data(mpd_decoder, inStream, + chunk, ret * sizeof(chunk[0]), + total_time, + bitRate, replayGainInfo); + } while (cmd != DECODE_COMMAND_STOP); replay_gain_info_free(replayGainInfo); } -- cgit v1.2.3