audiofile: removed duplicate decoder_get_command() calls
decoder_data() returns a decoder_command, no need to call decoder_get_command() twice after decoder_command().
This commit is contained in:
parent
0813092c63
commit
d29db0111c
@ -112,6 +112,7 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is)
|
|||||||
uint16_t bit_rate;
|
uint16_t bit_rate;
|
||||||
int ret, current = 0;
|
int ret, current = 0;
|
||||||
char chunk[CHUNK_SIZE];
|
char chunk[CHUNK_SIZE];
|
||||||
|
enum decoder_command cmd;
|
||||||
|
|
||||||
if (!is->seekable) {
|
if (!is->seekable) {
|
||||||
g_warning("not 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);
|
decoder_initialized(decoder, &audio_format, true, total_time);
|
||||||
|
|
||||||
do {
|
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,
|
ret = afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk,
|
||||||
CHUNK_SIZE / fs);
|
CHUNK_SIZE / fs);
|
||||||
if (ret <= 0)
|
if (ret <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
current += ret;
|
current += ret;
|
||||||
decoder_data(decoder, NULL,
|
cmd = decoder_data(decoder, NULL,
|
||||||
chunk, ret * fs,
|
chunk, ret * fs,
|
||||||
(float)current / (float)audio_format.sample_rate,
|
(float)current /
|
||||||
bit_rate, NULL);
|
(float)audio_format.sample_rate,
|
||||||
} while (decoder_get_command(decoder) != DECODE_COMMAND_STOP);
|
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);
|
afCloseFile(af_fp);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user