aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-02-28 19:28:38 +0100
committerMax Kellermann <max@duempel.org>2009-02-28 19:28:38 +0100
commitd29db0111c1548da3dd8c5cdeba4173938f32da1 (patch)
tree478545a9513b1351014519d6540ff06602d9a029 /src
parent0813092c637121a161721f75c854128c9a921304 (diff)
downloadmpd-d29db0111c1548da3dd8c5cdeba4173938f32da1.tar.gz
mpd-d29db0111c1548da3dd8c5cdeba4173938f32da1.tar.xz
mpd-d29db0111c1548da3dd8c5cdeba4173938f32da1.zip
audiofile: removed duplicate decoder_get_command() calls
decoder_data() returns a decoder_command, no need to call decoder_get_command() twice after decoder_command().
Diffstat (limited to '')
-rw-r--r--src/decoder/audiofile_plugin.c28
1 files changed, 16 insertions, 12 deletions
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);
}