From 8d3942e0c3b4108e8968e914da75bf7c6c43f408 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:04 +0200 Subject: 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. --- src/inputPlugins/flac_plugin.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/inputPlugins/flac_plugin.c') 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(); } -- cgit v1.2.3