diff options
author | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:04 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-08-26 08:27:04 +0200 |
commit | 8d3942e0c3b4108e8968e914da75bf7c6c43f408 (patch) | |
tree | 69d7eba9eb5f0273a61698169088e0ee70cdb297 /src/inputPlugins/flac_plugin.c | |
parent | 180d78a8e631cb4d48ef468709099a8c43d7ef51 (diff) | |
download | mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.gz mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.tar.xz mpd-8d3942e0c3b4108e8968e914da75bf7c6c43f408.zip |
merged start, stop, seek into DecoderControl.command
Much of the existing code queries all three variables sequentially.
Since only one of them can be set at a time, this can be optimized and
unified by merging all of them into one enum variable. Later, the
"command" checks can be expressed in a "switch" statement.
Diffstat (limited to 'src/inputPlugins/flac_plugin.c')
-rw-r--r-- | src/inputPlugins/flac_plugin.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c index 37adae810..43242d2d6 100644 --- a/src/inputPlugins/flac_plugin.c +++ b/src/inputPlugins/flac_plugin.c @@ -35,14 +35,15 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec, while (1) { r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes); - if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop) + if (r == 0 && !inputStreamAtEOF(data->inStream) && + dc.command != DECODE_COMMAND_STOP) my_usleep(10000); else break; } *bytes = r; - if (r == 0 && !dc.stop) { + if (r == 0 && dc.command != DECODE_COMMAND_STOP) { if (inputStreamAtEOF(data->inStream)) return flac_read_status_eof; else @@ -285,7 +286,7 @@ static FLAC__StreamDecoderWriteStatus flacWrite(const flac_decoder *dec, FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } data->chunk_length = 0; - if (dc.seek) { + if (dc.command == DECODE_COMMAND_SEEK) { return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; } @@ -420,7 +421,7 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg) break; if (flac_get_state(flacDec) == flac_decoder_eof) break; - if (dc.seek) { + if (dc.command == DECODE_COMMAND_SEEK) { FLAC__uint64 sampleToSeek = dc.seekWhere * dc.audioFormat.sampleRate + 0.5; if (flac_seek_absolute(flacDec, sampleToSeek)) { @@ -430,16 +431,16 @@ static int flac_decode_internal(InputStream * inStream, int is_ogg) data.position = 0; } else dc.seekError = 1; - dc.seek = 0; + dc.command = DECODE_COMMAND_NONE; decoder_wakeup_player(); } } - if (!dc.stop) { + if (dc.command != DECODE_COMMAND_STOP) { flacPrintErroredState(flac_get_state(flacDec)); flac_finish(flacDec); } /* send last little bit */ - if (data.chunk_length > 0 && !dc.stop) { + if (data.chunk_length > 0 && dc.command != DECODE_COMMAND_STOP) { flacSendChunk(&data); ob_flush(); } |