From d29db0111c1548da3dd8c5cdeba4173938f32da1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 28 Feb 2009 19:28:38 +0100 Subject: audiofile: removed duplicate decoder_get_command() calls decoder_data() returns a decoder_command, no need to call decoder_get_command() twice after decoder_command(). --- src/decoder/audiofile_plugin.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) (limited to 'src/decoder/audiofile_plugin.c') diff --git a/src/decoder/audiofile_plugin.c b/src/decoder/audiofile_plugin.c index 71c2cf0fa..bc517d49c 100644 --- a/src/decoder/audiofile_plugin.c +++ b/src/decoder/audiofile_plugin.c @@ -112,6 +112,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is) uint16_t bit_rate; int ret, current = 0; char chunk[CHUNK_SIZE]; + enum decoder_command cmd; if (!is->seekable) { g_warning("not seekable"); @@ -154,24 +155,27 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is) decoder_initialized(decoder, &audio_format, true, total_time); do { - if (decoder_get_command(decoder) == DECODE_COMMAND_SEEK) { - current = decoder_seek_where(decoder) * - audio_format.sample_rate; - afSeekFrame(af_fp, AF_DEFAULT_TRACK, current); - decoder_command_finished(decoder); - } - ret = afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk, CHUNK_SIZE / fs); if (ret <= 0) break; current += ret; - decoder_data(decoder, NULL, - chunk, ret * fs, - (float)current / (float)audio_format.sample_rate, - bit_rate, NULL); - } while (decoder_get_command(decoder) != DECODE_COMMAND_STOP); + cmd = decoder_data(decoder, NULL, + chunk, ret * fs, + (float)current / + (float)audio_format.sample_rate, + bit_rate, NULL); + + if (cmd == DECODE_COMMAND_SEEK) { + current = decoder_seek_where(decoder) * + audio_format.sample_rate; + afSeekFrame(af_fp, AF_DEFAULT_TRACK, current); + + decoder_command_finished(decoder); + cmd = DECODE_COMMAND_NONE; + } + } while (cmd == DECODE_COMMAND_NONE); afCloseFile(af_fp); } -- cgit v1.2.3