libFLAC: Set decoding status if write callback failed
authorErik de Castro Lopo <erikd@mega-nerd.com>
Wed, 13 Jul 2016 09:41:14 +0000 (19:41 +1000)
committerErik de Castro Lopo <erikd@mega-nerd.com>
Wed, 13 Jul 2016 09:42:25 +0000 (19:42 +1000)
Previously, it the write callback failed the error status
would be set to `FLAC__STREAM_DECODER_READ_FRAME`. Now it
gets set to `FLAC__STREAM_DECODER_WRITE_STATUS_ABORT`.

Patch-from: lvqcl <lvqcl.mail@gmail.com>

include/FLAC/stream_decoder.h
src/libFLAC/stream_decoder.c

index 9bfdd1f..27a61a1 100644 (file)
@@ -228,7 +228,7 @@ typedef enum {
         */
 
        FLAC__STREAM_DECODER_ABORTED,
-       /**< The decoder was aborted by the read callback. */
+       /**< The decoder was aborted by the read or write callback. */
 
        FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR,
        /**< An error occurred allocating memory.  The decoder is in an invalid
index c3a903f..91535ac 100644 (file)
@@ -2147,8 +2147,10 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL
 
        /* write it */
        if(do_full_decode) {
-               if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE)
+               if(write_audio_frame_to_client_(decoder, &decoder->private_->frame, (const FLAC__int32 * const *)decoder->private_->output) != FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE) {
+                       decoder->protected_->state = FLAC__STREAM_DECODER_ABORTED;
                        return false;
+               }
        }
 
        decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC;