fix FLAC::Decoder::Stream::finish() to return a bool like its C cousin
authorJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 9 Nov 2006 06:55:21 +0000 (06:55 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Thu, 9 Nov 2006 06:55:21 +0000 (06:55 +0000)
include/FLAC++/decoder.h
src/libFLAC++/stream_decoder.cpp
src/test_libFLAC++/decoders.cpp

index 17b7aef..cb3d38c 100644 (file)
@@ -143,7 +143,7 @@ namespace FLAC {
                        virtual ::FLAC__StreamDecoderInitStatus init();      ///< Seek FLAC__stream_decoder_init_stream()
                        virtual ::FLAC__StreamDecoderInitStatus init_ogg();  ///< Seek FLAC__stream_decoder_init_ogg_stream()
 
-                       virtual void finish(); ///< See FLAC__stream_decoder_finish()
+                       virtual bool finish(); ///< See FLAC__stream_decoder_finish()
 
                        virtual bool flush(); ///< See FLAC__stream_decoder_flush()
                        virtual bool reset(); ///< See FLAC__stream_decoder_reset()
index bc1fa61..13f1281 100644 (file)
@@ -53,7 +53,7 @@ namespace FLAC {
                Stream::~Stream()
                {
                        if(0 != decoder_) {
-                               ::FLAC__stream_decoder_finish(decoder_);
+                               (void)::FLAC__stream_decoder_finish(decoder_);
                                ::FLAC__stream_decoder_delete(decoder_);
                        }
                }
@@ -171,10 +171,10 @@ namespace FLAC {
                        return ::FLAC__stream_decoder_init_ogg_stream(decoder_, read_callback_, seek_callback_, tell_callback_, length_callback_, eof_callback_, write_callback_, metadata_callback_, error_callback_, /*client_data=*/(void*)this);
                }
 
-               void Stream::finish()
+               bool Stream::finish()
                {
                        FLAC__ASSERT(is_valid());
-                       ::FLAC__stream_decoder_finish(decoder_);
+                       return (bool)::FLAC__stream_decoder_finish(decoder_);
                }
 
                bool Stream::flush()
index 25925a8..9d9e313 100644 (file)
@@ -332,7 +332,11 @@ bool StreamDecoder::test_respond(bool is_ogg)
        printf("OK\n");
 
        printf("testing finish()... ");
-       finish();
+       if(!finish()) {
+               State state = get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        return true;
@@ -414,7 +418,11 @@ bool FileDecoder::test_respond(bool is_ogg)
        printf("OK\n");
 
        printf("testing finish()... ");
-       finish();
+       if(!finish()) {
+               State state = get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        return true;
@@ -714,7 +722,11 @@ static bool test_stream_decoder(Layer layer, bool is_ogg)
        }
 
        printf("testing finish()... ");
-       decoder->finish();
+       if(!decoder->finish()) {
+               FLAC::Decoder::Stream::State state = decoder->get_state();
+               printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
+               return false;
+       }
        printf("OK\n");
 
        /*