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/oggflac_plugin.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/inputPlugins/oggflac_plugin.c') diff --git a/src/inputPlugins/oggflac_plugin.c b/src/inputPlugins/oggflac_plugin.c index 7fce1551b..71c45aab8 100644 --- a/src/inputPlugins/oggflac_plugin.c +++ b/src/inputPlugins/oggflac_plugin.c @@ -50,14 +50,15 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const while (1) { r = readFromInputStream(data->inStream, (void *)buf, 1, *bytes); if (r == 0 && !inputStreamAtEOF(data->inStream) && - !dc.stop) + dc.command != DECODE_COMMAND_STOP) my_usleep(10000); else break; } *bytes = r; - if (r == 0 && !inputStreamAtEOF(data->inStream) && !dc.stop) + if (r == 0 && !inputStreamAtEOF(data->inStream) && + dc.command != DECODE_COMMAND_STOP) return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; @@ -194,7 +195,7 @@ static FLAC__StreamDecoderWriteStatus oggflacWrite(const 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; } @@ -351,7 +352,7 @@ static int oggflac_decode(InputStream * inStream) OggFLAC__SEEKABLE_STREAM_DECODER_OK) { break; } - if (dc.seek) { + if (dc.command == DECODE_COMMAND_SEEK) { FLAC__uint64 sampleToSeek = dc.seekWhere * dc.audioFormat.sampleRate + 0.5; if (OggFLAC__seekable_stream_decoder_seek_absolute @@ -362,18 +363,18 @@ static int oggflac_decode(InputStream * inStream) 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) { oggflacPrintErroredState (OggFLAC__seekable_stream_decoder_get_state(decoder)); OggFLAC__seekable_stream_decoder_finish(decoder); } /* 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