flac: decoder command means EOF

It was possible for the decoder thread to go into an endless loop
(flac and oggflac decoders): when a "STOP" command arrived, the Read()
callback would return 0, but the EOF() callback returned false.  Fix:
when decoder_get_command()!=NONE, return EOF==true.
This commit is contained in:
Max Kellermann 2008-08-26 08:27:16 +02:00
parent 8a5109483d
commit 6df980a996
2 changed files with 9 additions and 11 deletions

View File

@ -36,16 +36,14 @@ 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_NONE) { if (r == 0) {
if (inputStreamAtEOF(data->inStream)) if (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE ||
inputStreamAtEOF(data->inStream))
return flac_read_status_eof; return flac_read_status_eof;
else else
return flac_read_status_abort; return flac_read_status_abort;
} }
if (r == 0 && decoder_get_command(data->decoder) == DECODE_COMMAND_SEEK)
return flac_read_status_eof;
return flac_read_status_continue; return flac_read_status_continue;
} }
@ -88,9 +86,9 @@ static FLAC__bool flacEOF(mpd_unused const flac_decoder * flacDec, void *fdata)
{ {
FlacData *data = (FlacData *) fdata; FlacData *data = (FlacData *) fdata;
if (inputStreamAtEOF(data->inStream) == 1) return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
return true; decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
return false; inputStreamAtEOF(data->inStream);
} }
static void flacError(mpd_unused const flac_decoder *dec, static void flacError(mpd_unused const flac_decoder *dec,

View File

@ -104,9 +104,9 @@ static FLAC__bool of_EOF_cb(const OggFLAC__SeekableStreamDecoder * decoder,
{ {
FlacData *data = (FlacData *) fdata; FlacData *data = (FlacData *) fdata;
if (inputStreamAtEOF(data->inStream) == 1) return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
return true; decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
return false; inputStreamAtEOF(data->inStream);
} }
static void of_error_cb(const OggFLAC__SeekableStreamDecoder * decoder, static void of_error_cb(const OggFLAC__SeekableStreamDecoder * decoder,