From 38bf3e6ca9fa103e5ce2bc8ee922d6e36e457298 Mon Sep 17 00:00:00 2001 From: Josh Coalson Date: Thu, 9 Nov 2006 06:55:21 +0000 Subject: [PATCH] fix FLAC::Decoder::Stream::finish() to return a bool like its C cousin --- include/FLAC++/decoder.h | 2 +- src/libFLAC++/stream_decoder.cpp | 6 +++--- src/test_libFLAC++/decoders.cpp | 18 +++++++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/include/FLAC++/decoder.h b/include/FLAC++/decoder.h index 17b7aefa..cb3d38c1 100644 --- a/include/FLAC++/decoder.h +++ b/include/FLAC++/decoder.h @@ -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() diff --git a/src/libFLAC++/stream_decoder.cpp b/src/libFLAC++/stream_decoder.cpp index bc1fa611..13f12814 100644 --- a/src/libFLAC++/stream_decoder.cpp +++ b/src/libFLAC++/stream_decoder.cpp @@ -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() diff --git a/src/test_libFLAC++/decoders.cpp b/src/test_libFLAC++/decoders.cpp index 25925a8a..9d9e3137 100644 --- a/src/test_libFLAC++/decoders.cpp +++ b/src/test_libFLAC++/decoders.cpp @@ -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"); /*