Commit e530181e authored by Max Kellermann's avatar Max Kellermann

check decoder_command!=NONE instead of decoder_command==STOP

The code said "decoder_command==STOP" because that was a conversion from the old "dc->stop" test. As we can now check for all commands in one test, we can simply rewrite that to decoder_command!=NONE.
parent 4515ac5e
...@@ -36,7 +36,7 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec, ...@@ -36,7 +36,7 @@ static flac_read_status flacRead(mpd_unused const flac_decoder * flacDec,
r = decoder_read(data->decoder, data->inStream, (void *)buf, *bytes); r = decoder_read(data->decoder, data->inStream, (void *)buf, *bytes);
*bytes = r; *bytes = r;
if (r == 0 && decoder_get_command(data->decoder) != DECODE_COMMAND_STOP) { if (r == 0 && decoder_get_command(data->decoder) == DECODE_COMMAND_NONE) {
if (inputStreamAtEOF(data->inStream)) if (inputStreamAtEOF(data->inStream))
return flac_read_status_eof; return flac_read_status_eof;
else else
......
...@@ -700,16 +700,16 @@ static int decodeFirstFrame(mp3DecodeData * data, ...@@ -700,16 +700,16 @@ static int decodeFirstFrame(mp3DecodeData * data,
while (1) { while (1) {
while ((ret = decodeNextFrameHeader(data, tag, replayGainInfo)) == DECODE_CONT && while ((ret = decodeNextFrameHeader(data, tag, replayGainInfo)) == DECODE_CONT &&
(!decoder || decoder_get_command(decoder) != DECODE_COMMAND_STOP)); (!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE));
if (ret == DECODE_BREAK || if (ret == DECODE_BREAK ||
(decoder && decoder_get_command(decoder) == DECODE_COMMAND_STOP)) (decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE))
return -1; return -1;
if (ret == DECODE_SKIP) continue; if (ret == DECODE_SKIP) continue;
while ((ret = decodeNextFrame(data)) == DECODE_CONT && while ((ret = decodeNextFrame(data)) == DECODE_CONT &&
(!decoder || decoder_get_command(decoder) != DECODE_COMMAND_STOP)); (!decoder || decoder_get_command(decoder) == DECODE_COMMAND_NONE));
if (ret == DECODE_BREAK || if (ret == DECODE_BREAK ||
(decoder && decoder_get_command(decoder) == DECODE_COMMAND_STOP)) (decoder && decoder_get_command(decoder) != DECODE_COMMAND_NONE))
return -1; return -1;
if (ret == DECODE_OK) break; if (ret == DECODE_OK) break;
} }
...@@ -990,7 +990,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo) ...@@ -990,7 +990,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
while ((ret = while ((ret =
decodeNextFrameHeader(data, NULL, decodeNextFrameHeader(data, NULL,
replayGainInfo)) == DECODE_CONT replayGainInfo)) == DECODE_CONT
&& decoder_get_command(decoder) != DECODE_COMMAND_STOP) ; && decoder_get_command(decoder) == DECODE_COMMAND_NONE) ;
if (ret == DECODE_BREAK || decoder_get_command(decoder) != DECODE_COMMAND_NONE) if (ret == DECODE_BREAK || decoder_get_command(decoder) != DECODE_COMMAND_NONE)
break; break;
else if (ret == DECODE_SKIP) else if (ret == DECODE_SKIP)
...@@ -1006,7 +1006,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo) ...@@ -1006,7 +1006,7 @@ mp3Read(mp3DecodeData * data, ReplayGainInfo ** replayGainInfo)
break; break;
} }
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) if (decoder_get_command(decoder) != DECODE_COMMAND_NONE)
return DECODE_BREAK; return DECODE_BREAK;
return ret; return ret;
...@@ -1029,7 +1029,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream) ...@@ -1029,7 +1029,7 @@ static int mp3_decode(struct decoder * decoder, InputStream * inStream)
if (openMp3FromInputStream(inStream, &data, decoder, if (openMp3FromInputStream(inStream, &data, decoder,
&tag, &replayGainInfo) < 0) { &tag, &replayGainInfo) < 0) {
if (decoder_get_command(decoder) != DECODE_COMMAND_STOP) { if (decoder_get_command(decoder) == DECODE_COMMAND_NONE) {
ERROR ERROR
("Input does not appear to be a mp3 bit stream.\n"); ("Input does not appear to be a mp3 bit stream.\n");
return -1; return -1;
......
...@@ -51,7 +51,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const ...@@ -51,7 +51,7 @@ static OggFLAC__SeekableStreamDecoderReadStatus of_read_cb(const
*bytes = r; *bytes = r;
if (r == 0 && !inputStreamAtEOF(data->inStream) && if (r == 0 && !inputStreamAtEOF(data->inStream) &&
decoder_get_command(data->decoder) != DECODE_COMMAND_STOP) decoder_get_command(data->decoder) == DECODE_COMMAND_NONE)
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR; return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK; return OggFLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
...@@ -365,14 +365,14 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream) ...@@ -365,14 +365,14 @@ static int oggflac_decode(struct decoder * mpd_decoder, InputStream * inStream)
} }
} }
if (decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) { if (decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
oggflacPrintErroredState oggflacPrintErroredState
(OggFLAC__seekable_stream_decoder_get_state(decoder)); (OggFLAC__seekable_stream_decoder_get_state(decoder));
OggFLAC__seekable_stream_decoder_finish(decoder); OggFLAC__seekable_stream_decoder_finish(decoder);
} }
/* send last little bit */ /* send last little bit */
if (data.chunk_length > 0 && if (data.chunk_length > 0 &&
decoder_get_command(mpd_decoder) != DECODE_COMMAND_STOP) { decoder_get_command(mpd_decoder) == DECODE_COMMAND_NONE) {
flacSendChunk(&data); flacSendChunk(&data);
decoder_flush(mpd_decoder); decoder_flush(mpd_decoder);
} }
......
...@@ -319,7 +319,8 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream) ...@@ -319,7 +319,8 @@ static int oggvorbis_decode(struct decoder * decoder, InputStream * inStream)
} }
} }
if (decoder_get_command(decoder) != DECODE_COMMAND_STOP && chunkpos > 0) { if (decoder_get_command(decoder) == DECODE_COMMAND_NONE &&
chunkpos > 0) {
decoder_data(decoder, NULL, inStream->seekable, decoder_data(decoder, NULL, inStream->seekable,
chunk, chunkpos, chunk, chunkpos,
ov_time_tell(&vf), bitRate, ov_time_tell(&vf), bitRate,
......
...@@ -487,7 +487,7 @@ static int wavpack_open_wvc(struct decoder *decoder, ...@@ -487,7 +487,7 @@ static int wavpack_open_wvc(struct decoder *decoder,
if (bufferInputStream(is_wvc) >= 0) if (bufferInputStream(is_wvc) >= 0)
return 1; return 1;
if (decoder_get_command(decoder) == DECODE_COMMAND_STOP) { if (decoder_get_command(decoder) != DECODE_COMMAND_NONE) {
closeInputStream(is_wvc); closeInputStream(is_wvc);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment