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.
---

 src/inputPlugins/flac_plugin.c    |   14 ++++++--------
 src/inputPlugins/oggflac_plugin.c |    6 +++---
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/src/inputPlugins/flac_plugin.c b/src/inputPlugins/flac_plugin.c
index c90ff21..4d9f8e8 100644
--- a/src/inputPlugins/flac_plugin.c
+++ b/src/inputPlugins/flac_plugin.c
@@ -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);
        *bytes = r;
 
-       if (r == 0 && decoder_get_command(data->decoder) == 
DECODE_COMMAND_NONE) {
-               if (inputStreamAtEOF(data->inStream))
+       if (r == 0) {
+               if (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE ||
+                   inputStreamAtEOF(data->inStream))
                        return flac_read_status_eof;
                else
                        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;
 }
 
@@ -88,9 +86,9 @@ static FLAC__bool flacEOF(mpd_unused const flac_decoder * 
flacDec, void *fdata)
 {
        FlacData *data = (FlacData *) fdata;
 
-       if (inputStreamAtEOF(data->inStream) == 1)
-               return true;
-       return false;
+       return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
+               decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
+               inputStreamAtEOF(data->inStream);
 }
 
 static void flacError(mpd_unused const flac_decoder *dec,
diff --git a/src/inputPlugins/oggflac_plugin.c 
b/src/inputPlugins/oggflac_plugin.c
index 2adbaed..e0527f7 100644
--- a/src/inputPlugins/oggflac_plugin.c
+++ b/src/inputPlugins/oggflac_plugin.c
@@ -104,9 +104,9 @@ static FLAC__bool of_EOF_cb(const 
OggFLAC__SeekableStreamDecoder * decoder,
 {
        FlacData *data = (FlacData *) fdata;
 
-       if (inputStreamAtEOF(data->inStream) == 1)
-               return true;
-       return false;
+       return (decoder_get_command(data->decoder) != DECODE_COMMAND_NONE &&
+               decoder_get_command(data->decoder) != DECODE_COMMAND_SEEK) ||
+               inputStreamAtEOF(data->inStream);
 }
 
 static void of_error_cb(const OggFLAC__SeekableStreamDecoder * decoder,


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to