revamp decoder process calls
This commit is contained in:
parent
ebece62ea1
commit
cfdfc82801
@ -524,7 +524,7 @@ FLAC__FileDecoderState FLAC__file_decoder_init(FLAC__FileDecoder *decoder);
|
||||
FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__SeekableStreamDecoder; see
|
||||
* FLAC__seekable_stream_decoder_process_whole_stream().
|
||||
* FLAC__seekable_stream_decoder_process_single().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -532,10 +532,10 @@ FLAC__bool FLAC__file_decoder_finish(FLAC__FileDecoder *decoder);
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
|
||||
FLAC__bool FLAC__file_decoder_process_single(FLAC__FileDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__SeekableStreamDecoder; see
|
||||
* FLAC__seekable_stream_decoder_process_metadata().
|
||||
* FLAC__seekable_stream_decoder_process_until_end_of_metadata().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -543,10 +543,10 @@ FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder);
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
|
||||
FLAC__bool FLAC__file_decoder_process_until_end_of_metadata(FLAC__FileDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__SeekableStreamDecoder; see
|
||||
* FLAC__seekable_stream_decoder_process_one_frame().
|
||||
* FLAC__seekable_stream_decoder_process_until_end_of_stream().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -554,7 +554,7 @@ FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder);
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder);
|
||||
FLAC__bool FLAC__file_decoder_process_until_end_of_file(FLAC__FileDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__SeekableStreamDecoder; see
|
||||
* FLAC__seekable_stream_decoder_process_remaining_frames().
|
||||
|
@ -732,7 +732,7 @@ FLAC__bool FLAC__seekable_stream_decoder_flush(FLAC__SeekableStreamDecoder *deco
|
||||
FLAC__bool FLAC__seekable_stream_decoder_reset(FLAC__SeekableStreamDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__StreamDecoder; see
|
||||
* FLAC__stream_decoder_process_whole_stream().
|
||||
* FLAC__stream_decoder_process_single().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -740,10 +740,10 @@ FLAC__bool FLAC__seekable_stream_decoder_reset(FLAC__SeekableStreamDecoder *deco
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_whole_stream(FLAC__SeekableStreamDecoder *decoder);
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_single(FLAC__SeekableStreamDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__StreamDecoder; see
|
||||
* FLAC__stream_decoder_process_metadata().
|
||||
* FLAC__stream_decoder_process_until_end_of_metadata().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -751,10 +751,10 @@ FLAC__bool FLAC__seekable_stream_decoder_process_whole_stream(FLAC__SeekableStre
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_metadata(FLAC__SeekableStreamDecoder *decoder);
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_metadata(FLAC__SeekableStreamDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__StreamDecoder; see
|
||||
* FLAC__stream_decoder_process_one_frame().
|
||||
* FLAC__stream_decoder_process_until_end_of_stream().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
@ -762,18 +762,7 @@ FLAC__bool FLAC__seekable_stream_decoder_process_metadata(FLAC__SeekableStreamDe
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_one_frame(FLAC__SeekableStreamDecoder *decoder);
|
||||
|
||||
/** This is inherited from FLAC__StreamDecoder; see
|
||||
* FLAC__stream_decoder_process_remaining_frames().
|
||||
*
|
||||
* \param decoder A decoder instance.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \retval FLAC__bool
|
||||
* See above.
|
||||
*/
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_remaining_frames(FLAC__SeekableStreamDecoder *decoder);
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_stream(FLAC__SeekableStreamDecoder *decoder);
|
||||
|
||||
/** Flush the input and seek to an absolute sample.
|
||||
* Decoding will resume at the given sample. Note that because of
|
||||
|
@ -117,19 +117,20 @@ extern "C" {
|
||||
* Once the decoder is initialized, your program will call one of several
|
||||
* functions to start the decoding process:
|
||||
*
|
||||
* - FLAC__stream_decoder_process_whole_stream() - Tells the decoder to
|
||||
* start and continue processing the stream until the read callback
|
||||
* - FLAC__stream_decoder_process_single() - Tells the decoder to process at
|
||||
* most one metadata block or audio frame and return, calling either the
|
||||
* metadata callback or write callback, respectively, once. If the decoder
|
||||
* loses sync it will return with only the error callback being called.
|
||||
* - FLAC__stream_decoder_process_until_end_of_metadata() - Tells the decoder
|
||||
* to process the stream from the current location and stop upon reaching
|
||||
* the first audio frame. The user will get one metadata, write, or error
|
||||
* callback per metadata block, audio frame, or sync error, respectively.
|
||||
* - FLAC__stream_decoder_process_until_end_of_stream() - Tells the decoder
|
||||
* to process the stream from the current location until the read callback
|
||||
* returns FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM or
|
||||
* FLAC__STREAM_DECODER_READ_STATUS_ABORT.
|
||||
* - FLAC__stream_decoder_process_metadata() - Tells the decoder to start
|
||||
* processing the stream and stop upon reaching the first audio frame.
|
||||
* - FLAC__stream_decoder_process_one_frame() - Tells the decoder to
|
||||
* process one audio frame and return. The decoder must have processed
|
||||
* all metadata first before calling this function.
|
||||
* - FLAC__stream_decoder_process_remaining_frames() - Tells the decoder to
|
||||
* process all remaining frames. The decoder must have processed all
|
||||
* metadata first but may also have processed frames with
|
||||
* FLAC__stream_decoder_process_one_frame().
|
||||
* FLAC__STREAM_DECODER_READ_STATUS_ABORT. The user will get one metadata,
|
||||
* write, or error callback per metadata block, audio frame, or sync error,
|
||||
* respectively.
|
||||
*
|
||||
* When the decoder has finished decoding (normally or through an abort),
|
||||
* the instance is finished by calling FLAC__stream_decoder_finish(), which
|
||||
@ -662,38 +663,42 @@ FLAC__bool FLAC__stream_decoder_flush(FLAC__StreamDecoder *decoder);
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Decode the entire stream.
|
||||
* This version instructs the decoder to start and continue decoding
|
||||
* the entire stream until the callbacks return a fatal error or the
|
||||
* read callback returns \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
|
||||
*
|
||||
* As the decoder needs more input it will call the read callback.
|
||||
* As each metadata block and frame is decoded, the metadata or write
|
||||
* callback will be called with the decoded metadata or frame.
|
||||
*
|
||||
* \param decoder An initialized decoder instance in the state
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \code FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA \endcode
|
||||
* \retval FLAC__bool
|
||||
* \c false if any read or write error occurred (except
|
||||
* \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC), else \c false;
|
||||
* in any case, check the decoder state with
|
||||
* FLAC__stream_decoder_get_state() to see what went wrong or to
|
||||
* check for lost synchronization (a sign of stream corruption).
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Decode just the metadata.
|
||||
* This version instructs the decoder to start decoding and stop after
|
||||
* all the metadata has been read, or until the callbacks return a fatal
|
||||
/** Decode one metadata block or audio frame.
|
||||
* This version instructs the decoder to decode a either a single metadata
|
||||
* block or a single frame and stop, unless the callbacks return a fatal
|
||||
* error or the read callback returns
|
||||
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
|
||||
*
|
||||
* As the decoder needs more input it will call the read callback.
|
||||
* Depending on what was decoded, the metadata or write callback will be
|
||||
* called with the decoded metadata block or audio frame, unless an error
|
||||
* occurred. If the decoder loses sync it will call the error callback
|
||||
* instead.
|
||||
*
|
||||
* \param decoder An initialized decoder instance in the state
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \code FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC \endcode
|
||||
* \retval FLAC__bool
|
||||
* \c false if any read or write error occurred (except
|
||||
* \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC), else \c false;
|
||||
* in any case, check the decoder state with
|
||||
* FLAC__stream_decoder_get_state() to see what went wrong or to
|
||||
* check for lost synchronization (a sign of stream corruption).
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Decode until the end of the metadata.
|
||||
* This version instructs the decoder to decode from the current position
|
||||
* and continue until all the metadata has been read, or until the
|
||||
* callbacks return a fatal error or the read callback returns
|
||||
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
|
||||
*
|
||||
* As the decoder needs more input it will call the read callback.
|
||||
* As each metadata block is decoded, the metadata callback will be called
|
||||
* with the decoded metadata.
|
||||
* with the decoded metadata. If the decoder loses sync it will call the
|
||||
* error callback.
|
||||
*
|
||||
* \param decoder An initialized decoder instance in the state
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA.
|
||||
@ -707,21 +712,24 @@ FLAC__bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decode
|
||||
* FLAC__stream_decoder_get_state() to see what went wrong or to
|
||||
* check for lost synchronization (a sign of stream corruption).
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Decode one frame.
|
||||
* This version instructs the decoder to decode a single frame and stop,
|
||||
* or until the callbacks return a fatal error or the read callback returns
|
||||
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
|
||||
/** Decode until the end of the stream.
|
||||
* This version instructs the decoder to decode from the current position
|
||||
* and continue until the end of stream (the read callback returns
|
||||
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM), or until the
|
||||
* callbacks return a fatal error.
|
||||
*
|
||||
* As the decoder needs more input it will call the read callback.
|
||||
* The write callback will be called with the decoded frame.
|
||||
* As each metadata block and frame is decoded, the metadata or write
|
||||
* callback will be called with the decoded metadata or frame. If the
|
||||
* decoder loses sync it will call the error callback.
|
||||
*
|
||||
* \param decoder An initialized decoder instance in the state
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC.
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_METADATA.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \code FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC \endcode
|
||||
* \code FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA \endcode
|
||||
* \retval FLAC__bool
|
||||
* \c false if any read or write error occurred (except
|
||||
* \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC), else \c false;
|
||||
@ -729,30 +737,7 @@ FLAC__bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder);
|
||||
* FLAC__stream_decoder_get_state() to see what went wrong or to
|
||||
* check for lost synchronization (a sign of stream corruption).
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/** Decode the remaining frames until end of stream.
|
||||
* This version instructs the decoder to decode all remaining frames,
|
||||
* until the callbacks return a fatal error or the read callback returns
|
||||
* \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM.
|
||||
*
|
||||
* As the decoder needs more input it will call the read callback.
|
||||
* As each frame is decoded, the write callback will be called with the
|
||||
* decoded frame.
|
||||
*
|
||||
* \param decoder An initialized decoder instance in the state
|
||||
* \c FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC.
|
||||
* \assert
|
||||
* \code decoder != NULL \endcode
|
||||
* \code FLAC__stream_decoder_get_state(decoder) == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC \endcode
|
||||
* \retval FLAC__bool
|
||||
* \c false if any read or write error occurred (except
|
||||
* \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC), else \c false;
|
||||
* in any case, check the decoder state with
|
||||
* FLAC__stream_decoder_get_state() to see what went wrong or to
|
||||
* check for lost synchronization (a sign of stream corruption).
|
||||
*/
|
||||
FLAC__bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder);
|
||||
FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder);
|
||||
|
||||
/* \} */
|
||||
|
||||
|
@ -164,7 +164,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
|
||||
goto wav_abort_;
|
||||
}
|
||||
#endif
|
||||
if(!FLAC__file_decoder_process_metadata(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_metadata(stream_info.decoder.file)) {
|
||||
fprintf(stderr, "%s: ERROR while decoding metadata, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto wav_abort_;
|
||||
}
|
||||
@ -174,7 +174,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
|
||||
fprintf(stderr, "%s: ERROR seeking while skipping bytes, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto wav_abort_;
|
||||
}
|
||||
if(!FLAC__file_decoder_process_remaining_frames(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(stream_info.decoder.file)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding frames, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto wav_abort_;
|
||||
@ -188,7 +188,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
|
||||
else {
|
||||
#ifdef FLAC__HAS_OGG
|
||||
if(stream_info.is_ogg) {
|
||||
if(!FLAC__stream_decoder_process_whole_stream(stream_info.decoder.stream)) {
|
||||
if(!FLAC__stream_decoder_process_until_end_of_stream(stream_info.decoder.stream)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding data, state=%d:%s\n", stream_info.inbasefilename, FLAC__stream_decoder_get_state(stream_info.decoder.stream), FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(stream_info.decoder.stream)]);
|
||||
goto wav_abort_;
|
||||
@ -202,7 +202,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(!FLAC__file_decoder_process_whole_file(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(stream_info.decoder.file)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding data, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto wav_abort_;
|
||||
@ -352,7 +352,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
|
||||
goto raw_abort_;
|
||||
}
|
||||
#endif
|
||||
if(!FLAC__file_decoder_process_metadata(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_metadata(stream_info.decoder.file)) {
|
||||
fprintf(stderr, "%s: ERROR while decoding metadata, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto raw_abort_;
|
||||
}
|
||||
@ -362,7 +362,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
|
||||
fprintf(stderr, "%s: ERROR seeking while skipping bytes, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto raw_abort_;
|
||||
}
|
||||
if(!FLAC__file_decoder_process_remaining_frames(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(stream_info.decoder.file)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding frames, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto raw_abort_;
|
||||
@ -376,7 +376,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
|
||||
else {
|
||||
#ifdef FLAC__HAS_OGG
|
||||
if(stream_info.is_ogg) {
|
||||
if(!FLAC__stream_decoder_process_whole_stream(stream_info.decoder.stream)) {
|
||||
if(!FLAC__stream_decoder_process_until_end_of_stream(stream_info.decoder.stream)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding data, state=%d:%s\n", stream_info.inbasefilename, FLAC__stream_decoder_get_state(stream_info.decoder.stream), FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(stream_info.decoder.stream)]);
|
||||
goto raw_abort_;
|
||||
@ -390,7 +390,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if(!FLAC__file_decoder_process_whole_file(stream_info.decoder.file)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(stream_info.decoder.file)) {
|
||||
if(stream_info.verbose) fprintf(stderr, "\n");
|
||||
fprintf(stderr, "%s: ERROR while decoding data, state=%d:%s\n", stream_info.inbasefilename, FLAC__file_decoder_get_state(stream_info.decoder.file), FLAC__FileDecoderStateString[FLAC__file_decoder_get_state(stream_info.decoder.file)]);
|
||||
goto raw_abort_;
|
||||
|
@ -94,6 +94,18 @@ namespace FLAC {
|
||||
return State(::FLAC__file_decoder_get_state(decoder_));
|
||||
}
|
||||
|
||||
SeekableStream::State File::get_seekable_stream_decoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return SeekableStream::State(::FLAC__file_decoder_get_seekable_stream_decoder_state(decoder_));
|
||||
}
|
||||
|
||||
Stream::State File::get_stream_decoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return Stream::State(::FLAC__file_decoder_get_stream_decoder_state(decoder_));
|
||||
}
|
||||
|
||||
bool File::get_md5_checking() const
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
@ -146,28 +158,22 @@ namespace FLAC {
|
||||
return (bool)::FLAC__file_decoder_finish(decoder_);
|
||||
}
|
||||
|
||||
bool File::process_whole_file()
|
||||
bool File::process_single()
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_whole_file(decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_single(decoder_);
|
||||
}
|
||||
|
||||
bool File::process_metadata()
|
||||
bool File::process_until_end_of_metadata()
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_metadata(decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_until_end_of_metadata(decoder_);
|
||||
}
|
||||
|
||||
bool File::process_one_frame()
|
||||
bool File::process_until_end_of_file()
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_one_frame(decoder_);
|
||||
}
|
||||
|
||||
bool File::process_remaining_frames()
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_remaining_frames(decoder_);
|
||||
return (bool)::FLAC__file_decoder_process_until_end_of_file(decoder_);
|
||||
}
|
||||
|
||||
bool File::seek_absolute(FLAC__uint64 sample)
|
||||
|
@ -88,6 +88,12 @@ namespace FLAC {
|
||||
return State(::FLAC__seekable_stream_decoder_get_state(decoder_));
|
||||
}
|
||||
|
||||
Stream::State SeekableStream::get_stream_decoder_state() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return Stream::State(::FLAC__seekable_stream_decoder_get_stream_decoder_state(decoder_));
|
||||
}
|
||||
|
||||
bool SeekableStream::get_md5_checking() const
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
@ -157,28 +163,22 @@ namespace FLAC {
|
||||
return (bool)::FLAC__seekable_stream_decoder_reset(decoder_);
|
||||
}
|
||||
|
||||
bool SeekableStream::process_whole_stream()
|
||||
bool SeekableStream::process_single()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_whole_stream(decoder_);
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_single(decoder_);
|
||||
}
|
||||
|
||||
bool SeekableStream::process_metadata()
|
||||
bool SeekableStream::process_until_end_of_metadata()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_metadata(decoder_);
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder_);
|
||||
}
|
||||
|
||||
bool SeekableStream::process_one_frame()
|
||||
bool SeekableStream::process_until_end_of_stream()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_one_frame(decoder_);
|
||||
}
|
||||
|
||||
bool SeekableStream::process_remaining_frames()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_remaining_frames(decoder_);
|
||||
return (bool)::FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder_);
|
||||
}
|
||||
|
||||
bool SeekableStream::seek_absolute(FLAC__uint64 sample)
|
||||
|
@ -141,28 +141,22 @@ namespace FLAC {
|
||||
return (bool)::FLAC__stream_decoder_reset(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_whole_stream()
|
||||
bool Stream::process_single()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_whole_stream(decoder_);
|
||||
return (bool)::FLAC__stream_decoder_process_single(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_metadata()
|
||||
bool Stream::process_until_end_of_metadata()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_metadata(decoder_);
|
||||
return (bool)::FLAC__stream_decoder_process_until_end_of_metadata(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_one_frame()
|
||||
bool Stream::process_until_end_of_stream()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_one_frame(decoder_);
|
||||
}
|
||||
|
||||
bool Stream::process_remaining_frames()
|
||||
{
|
||||
FLAC__ASSERT(is_valid());
|
||||
return (bool)::FLAC__stream_decoder_process_remaining_frames(decoder_);
|
||||
return (bool)::FLAC__stream_decoder_process_until_end_of_stream(decoder_);
|
||||
}
|
||||
|
||||
::FLAC__StreamDecoderReadStatus Stream::read_callback_(const ::FLAC__StreamDecoder *decoder, FLAC__byte buffer[], unsigned *bytes, void *client_data)
|
||||
|
@ -418,7 +418,7 @@ unsigned FLAC__file_decoder_get_blocksize(const FLAC__FileDecoder *decoder)
|
||||
return FLAC__seekable_stream_decoder_get_blocksize(decoder->private_->seekable_stream_decoder);
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder)
|
||||
FLAC__bool FLAC__file_decoder_process_single(FLAC__FileDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -431,14 +431,14 @@ FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder)
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
|
||||
|
||||
ret = FLAC__seekable_stream_decoder_process_whole_stream(decoder->private_->seekable_stream_decoder);
|
||||
ret = FLAC__seekable_stream_decoder_process_single(decoder->private_->seekable_stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder)
|
||||
FLAC__bool FLAC__file_decoder_process_until_end_of_metadata(FLAC__FileDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -451,14 +451,14 @@ FLAC__bool FLAC__file_decoder_process_metadata(FLAC__FileDecoder *decoder)
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
|
||||
|
||||
ret = FLAC__seekable_stream_decoder_process_metadata(decoder->private_->seekable_stream_decoder);
|
||||
ret = FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder->private_->seekable_stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder)
|
||||
FLAC__bool FLAC__file_decoder_process_until_end_of_file(FLAC__FileDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -471,27 +471,7 @@ FLAC__bool FLAC__file_decoder_process_one_frame(FLAC__FileDecoder *decoder)
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
|
||||
|
||||
ret = FLAC__seekable_stream_decoder_process_one_frame(decoder->private_->seekable_stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__file_decoder_process_remaining_frames(FLAC__FileDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->private_->seekable_stream_decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
|
||||
decoder->protected_->state = FLAC__FILE_DECODER_END_OF_FILE;
|
||||
|
||||
if(decoder->protected_->state == FLAC__FILE_DECODER_END_OF_FILE)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__FILE_DECODER_OK);
|
||||
|
||||
ret = FLAC__seekable_stream_decoder_process_remaining_frames(decoder->private_->seekable_stream_decoder);
|
||||
ret = FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder->private_->seekable_stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR;
|
||||
|
||||
|
@ -545,7 +545,7 @@ FLAC__bool FLAC__seekable_stream_decoder_reset(FLAC__SeekableStreamDecoder *deco
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_whole_stream(FLAC__SeekableStreamDecoder *decoder)
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_single(FLAC__SeekableStreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -558,14 +558,14 @@ FLAC__bool FLAC__seekable_stream_decoder_process_whole_stream(FLAC__SeekableStre
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK);
|
||||
|
||||
ret = FLAC__stream_decoder_process_whole_stream(decoder->private_->stream_decoder);
|
||||
ret = FLAC__stream_decoder_process_single(decoder->private_->stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_metadata(FLAC__SeekableStreamDecoder *decoder)
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_metadata(FLAC__SeekableStreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -578,14 +578,14 @@ FLAC__bool FLAC__seekable_stream_decoder_process_metadata(FLAC__SeekableStreamDe
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK);
|
||||
|
||||
ret = FLAC__stream_decoder_process_metadata(decoder->private_->stream_decoder);
|
||||
ret = FLAC__stream_decoder_process_until_end_of_metadata(decoder->private_->stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_one_frame(FLAC__SeekableStreamDecoder *decoder)
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_until_end_of_stream(FLAC__SeekableStreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
@ -598,27 +598,7 @@ FLAC__bool FLAC__seekable_stream_decoder_process_one_frame(FLAC__SeekableStreamD
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK);
|
||||
|
||||
ret = FLAC__stream_decoder_process_one_frame(decoder->private_->stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__seekable_stream_decoder_process_remaining_frames(FLAC__SeekableStreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool ret;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->private_->stream_decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM;
|
||||
|
||||
if(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_END_OF_STREAM)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__SEEKABLE_STREAM_DECODER_OK);
|
||||
|
||||
ret = FLAC__stream_decoder_process_remaining_frames(decoder->private_->stream_decoder);
|
||||
ret = FLAC__stream_decoder_process_until_end_of_stream(decoder->private_->stream_decoder);
|
||||
if(!ret)
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR;
|
||||
|
||||
@ -651,7 +631,7 @@ FLAC__bool FLAC__seekable_stream_decoder_seek_absolute(FLAC__SeekableStreamDecod
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
if(!FLAC__stream_decoder_process_metadata(decoder->private_->stream_decoder)) {
|
||||
if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder->private_->stream_decoder)) {
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR;
|
||||
return false;
|
||||
}
|
||||
@ -961,7 +941,7 @@ FLAC__bool seek_to_absolute_sample_(FLAC__SeekableStreamDecoder *decoder, FLAC__
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(!FLAC__stream_decoder_process_one_frame(decoder->private_->stream_decoder)) {
|
||||
if(!FLAC__stream_decoder_process_single(decoder->private_->stream_decoder)) {
|
||||
decoder->protected_->state = FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
@ -258,7 +258,10 @@ FLAC__StreamDecoderState FLAC__stream_decoder_init(FLAC__StreamDecoder *decoder)
|
||||
}
|
||||
#endif
|
||||
|
||||
return decoder->protected_->state = FLAC__STREAM_DECODER_SEARCH_FOR_METADATA;
|
||||
if(!FLAC__stream_decoder_reset(decoder))
|
||||
return decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
|
||||
return decoder->protected_->state;
|
||||
}
|
||||
|
||||
void FLAC__stream_decoder_finish(FLAC__StreamDecoder *decoder)
|
||||
@ -528,95 +531,23 @@ FLAC__bool FLAC__stream_decoder_reset(FLAC__StreamDecoder *decoder)
|
||||
return true;
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_decoder_process_whole_stream(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool dummy;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
|
||||
|
||||
if(!FLAC__stream_decoder_reset(decoder)) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
switch(decoder->protected_->state) {
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
if(!find_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
if(!read_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
if(!frame_sync_(decoder))
|
||||
return true; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_FRAME:
|
||||
if(!read_frame_(decoder, &dummy))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_END_OF_STREAM:
|
||||
case FLAC__STREAM_DECODER_ABORTED:
|
||||
return true;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_decoder_process_metadata(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_METADATA);
|
||||
|
||||
if(!FLAC__stream_decoder_reset(decoder)) {
|
||||
decoder->protected_->state = FLAC__STREAM_DECODER_MEMORY_ALLOCATION_ERROR;
|
||||
return false;
|
||||
}
|
||||
|
||||
while(1) {
|
||||
switch(decoder->protected_->state) {
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
if(!find_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
if(!read_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
case FLAC__STREAM_DECODER_READ_FRAME:
|
||||
case FLAC__STREAM_DECODER_END_OF_STREAM:
|
||||
case FLAC__STREAM_DECODER_ABORTED:
|
||||
return true;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder)
|
||||
FLAC__bool FLAC__stream_decoder_process_single(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool got_a_frame;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
||||
while(1) {
|
||||
switch(decoder->protected_->state) {
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
if(!find_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
if(!read_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
else
|
||||
return true;
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
if(!frame_sync_(decoder))
|
||||
return true; /* above function sets the status for us */
|
||||
@ -632,22 +563,54 @@ FLAC__bool FLAC__stream_decoder_process_one_frame(FLAC__StreamDecoder *decoder)
|
||||
return true;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *decoder)
|
||||
FLAC__bool FLAC__stream_decoder_process_until_end_of_metadata(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool dummy;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
|
||||
if(decoder->protected_->state == FLAC__STREAM_DECODER_END_OF_STREAM)
|
||||
return true;
|
||||
|
||||
FLAC__ASSERT(decoder->protected_->state == FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
||||
while(1) {
|
||||
switch(decoder->protected_->state) {
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
if(!find_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
if(!read_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
case FLAC__STREAM_DECODER_READ_FRAME:
|
||||
case FLAC__STREAM_DECODER_END_OF_STREAM:
|
||||
case FLAC__STREAM_DECODER_ABORTED:
|
||||
return true;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FLAC__bool FLAC__stream_decoder_process_until_end_of_stream(FLAC__StreamDecoder *decoder)
|
||||
{
|
||||
FLAC__bool dummy;
|
||||
FLAC__ASSERT(0 != decoder);
|
||||
FLAC__ASSERT(0 != decoder->protected_);
|
||||
|
||||
while(1) {
|
||||
switch(decoder->protected_->state) {
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_METADATA:
|
||||
if(!find_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_READ_METADATA:
|
||||
if(!read_metadata_(decoder))
|
||||
return false; /* above function sets the status for us */
|
||||
break;
|
||||
case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
|
||||
if(!frame_sync_(decoder))
|
||||
return true; /* above function sets the status for us */
|
||||
@ -661,6 +624,7 @@ FLAC__bool FLAC__stream_decoder_process_remaining_frames(FLAC__StreamDecoder *de
|
||||
return true;
|
||||
default:
|
||||
FLAC__ASSERT(0);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -292,8 +292,8 @@ bool StreamDecoder::test_respond()
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("testing process_whole_stream()... ");
|
||||
if(!process_whole_stream()) {
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!process_until_end_of_stream()) {
|
||||
State state = get_state();
|
||||
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
|
||||
return false;
|
||||
@ -404,13 +404,13 @@ static bool test_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_metadata()... ");
|
||||
if(!decoder->process_metadata())
|
||||
printf("testing process_until_end_of_metadata()... ");
|
||||
if(!decoder->process_until_end_of_metadata())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_one_frame()... ");
|
||||
if(!decoder->process_one_frame())
|
||||
printf("testing process_single()... ");
|
||||
if(!decoder->process_single())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -420,14 +420,14 @@ static bool test_stream_decoder()
|
||||
printf("OK\n");
|
||||
|
||||
decoder->ignore_errors_ = true;
|
||||
printf("testing process_one_frame()... ");
|
||||
if(!decoder->process_one_frame())
|
||||
printf("testing process_single()... ");
|
||||
if(!decoder->process_single())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
decoder->ignore_errors_ = false;
|
||||
|
||||
printf("testing process_remaining_frames()... ");
|
||||
if(!decoder->process_remaining_frames())
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!decoder->process_until_end_of_stream())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -488,8 +488,8 @@ static bool test_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_whole_stream()... ");
|
||||
if(!decoder->process_whole_stream())
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!decoder->process_until_end_of_stream())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -971,8 +971,8 @@ bool SeekableStreamDecoder::test_respond()
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("testing process_whole_stream()... ");
|
||||
if(!process_whole_stream()) {
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!process_until_end_of_stream()) {
|
||||
State state = get_state();
|
||||
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state), state.as_cstring());
|
||||
return false;
|
||||
@ -1078,6 +1078,10 @@ static bool test_seekable_stream_decoder()
|
||||
FLAC::Decoder::SeekableStream::State state = decoder->get_state();
|
||||
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state), state.as_cstring());
|
||||
|
||||
printf("testing get_stream_decoder_state()... ");
|
||||
FLAC::Decoder::Stream::State state_ = decoder->get_stream_decoder_state();
|
||||
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamDecoderState)state_), state_.as_cstring());
|
||||
|
||||
decoder->current_metadata_number_ = 0;
|
||||
decoder->ignore_errors_ = false;
|
||||
decoder->error_occurred_ = false;
|
||||
@ -1097,13 +1101,13 @@ static bool test_seekable_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_metadata()... ");
|
||||
if(!decoder->process_metadata())
|
||||
printf("testing process_until_end_of_metadata()... ");
|
||||
if(!decoder->process_until_end_of_metadata())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_one_frame()... ");
|
||||
if(!decoder->process_one_frame())
|
||||
printf("testing process_single()... ");
|
||||
if(!decoder->process_single())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -1113,8 +1117,8 @@ static bool test_seekable_stream_decoder()
|
||||
printf("OK\n");
|
||||
|
||||
decoder->ignore_errors_ = true;
|
||||
printf("testing process_one_frame()... ");
|
||||
if(!decoder->process_one_frame())
|
||||
printf("testing process_single()... ");
|
||||
if(!decoder->process_single())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
decoder->ignore_errors_ = false;
|
||||
@ -1124,8 +1128,8 @@ static bool test_seekable_stream_decoder()
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_remaining_frames()... ");
|
||||
if(!decoder->process_remaining_frames())
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!decoder->process_until_end_of_stream())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -1186,8 +1190,8 @@ static bool test_seekable_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_whole_stream()... ");
|
||||
if(!decoder->process_whole_stream())
|
||||
printf("testing process_until_end_of_stream()... ");
|
||||
if(!decoder->process_until_end_of_stream())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -1603,8 +1607,8 @@ bool FileDecoder::test_respond()
|
||||
|
||||
current_metadata_number_ = 0;
|
||||
|
||||
printf("testing process_whole_file()... ");
|
||||
if(!process_whole_file()) {
|
||||
printf("testing process_until_end_of_file()... ");
|
||||
if(!process_until_end_of_file()) {
|
||||
State state = get_state();
|
||||
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__FileDecoderState)state), state.as_cstring());
|
||||
return false;
|
||||
@ -1717,6 +1721,14 @@ static bool test_file_decoder()
|
||||
FLAC::Decoder::File::State state = decoder->get_state();
|
||||
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__FileDecoderState)state), state.as_cstring());
|
||||
|
||||
printf("testing get_seekable_stream_decoder_state()... ");
|
||||
FLAC::Decoder::SeekableStream::State state_ = decoder->get_seekable_stream_decoder_state();
|
||||
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state_), state_.as_cstring());
|
||||
|
||||
printf("testing get_stream_decoder_state()... ");
|
||||
FLAC::Decoder::Stream::State state__ = decoder->get_stream_decoder_state();
|
||||
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamDecoderState)state__), state__.as_cstring());
|
||||
|
||||
decoder->current_metadata_number_ = 0;
|
||||
decoder->ignore_errors_ = false;
|
||||
decoder->error_occurred_ = false;
|
||||
@ -1728,13 +1740,13 @@ static bool test_file_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_metadata()... ");
|
||||
if(!decoder->process_metadata())
|
||||
printf("testing process_until_end_of_metadata()... ");
|
||||
if(!decoder->process_until_end_of_metadata())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_one_frame()... ");
|
||||
if(!decoder->process_one_frame())
|
||||
printf("testing process_single()... ");
|
||||
if(!decoder->process_single())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
@ -1743,8 +1755,8 @@ static bool test_file_decoder()
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing process_remaining_frames()... ");
|
||||
if(!decoder->process_remaining_frames())
|
||||
printf("testing process_until_end_of_file()... ");
|
||||
if(!decoder->process_until_end_of_file())
|
||||
return decoder->die("returned false");
|
||||
printf("OK\n");
|
||||
|
||||
|
@ -314,7 +314,7 @@ static bool test_file_(const char *filename, bool ignore_metadata)
|
||||
decoder.finish();
|
||||
return die_("initializing decoder\n");
|
||||
}
|
||||
if(!decoder.process_whole_file()) {
|
||||
if(!decoder.process_until_end_of_file()) {
|
||||
decoder.finish();
|
||||
return die_("decoding file\n");
|
||||
}
|
||||
|
@ -55,9 +55,11 @@ static FLAC__bool die_s_(const char *msg, const FLAC__StreamDecoder *decoder)
|
||||
FLAC__StreamDecoderState state = FLAC__stream_decoder_get_state(decoder);
|
||||
|
||||
if(msg)
|
||||
printf("FAILED, %s, state = %u (%s)\n", msg, (unsigned)state, FLAC__StreamDecoderStateString[state]);
|
||||
printf("FAILED, %s", msg);
|
||||
else
|
||||
printf("FAILED, state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state]);
|
||||
printf("FAILED");
|
||||
|
||||
printf(", state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state]);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -67,9 +69,15 @@ static FLAC__bool die_ss_(const char *msg, const FLAC__SeekableStreamDecoder *de
|
||||
FLAC__SeekableStreamDecoderState state = FLAC__seekable_stream_decoder_get_state(decoder);
|
||||
|
||||
if(msg)
|
||||
printf("FAILED, %s, state = %u (%s)\n", msg, (unsigned)state, FLAC__SeekableStreamDecoderStateString[state]);
|
||||
printf("FAILED, %s", msg);
|
||||
else
|
||||
printf("FAILED, state = %u (%s)\n", (unsigned)state, FLAC__SeekableStreamDecoderStateString[state]);
|
||||
printf("FAILED");
|
||||
|
||||
printf(", state = %u (%s)\n", (unsigned)state, FLAC__SeekableStreamDecoderStateString[state]);
|
||||
if(state == FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
|
||||
FLAC__StreamDecoderState state_ = FLAC__seekable_stream_decoder_get_stream_decoder_state(decoder);
|
||||
printf(" stream decoder state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state_]);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -79,9 +87,19 @@ static FLAC__bool die_f_(const char *msg, const FLAC__FileDecoder *decoder)
|
||||
FLAC__FileDecoderState state = FLAC__file_decoder_get_state(decoder);
|
||||
|
||||
if(msg)
|
||||
printf("FAILED, %s, state = %u (%s)\n", msg, (unsigned)state, FLAC__FileDecoderStateString[state]);
|
||||
printf("FAILED, %s", msg);
|
||||
else
|
||||
printf("FAILED, state = %u (%s)\n", (unsigned)state, FLAC__FileDecoderStateString[state]);
|
||||
printf("FAILED");
|
||||
|
||||
printf(", state = %u (%s)\n", (unsigned)state, FLAC__FileDecoderStateString[state]);
|
||||
if(state == FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) {
|
||||
FLAC__SeekableStreamDecoderState state_ = FLAC__file_decoder_get_seekable_stream_decoder_state(decoder);
|
||||
printf(" seekable stream decoder state = %u (%s)\n", (unsigned)state, FLAC__SeekableStreamDecoderStateString[state_]);
|
||||
if(state_ == FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
|
||||
FLAC__StreamDecoderState state__ = FLAC__file_decoder_get_stream_decoder_state(decoder);
|
||||
printf(" stream decoder state = %u (%s)\n", (unsigned)state, FLAC__StreamDecoderStateString[state__]);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -324,8 +342,8 @@ static FLAC__bool stream_decoder_test_respond_(FLAC__StreamDecoder *decoder, str
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("testing FLAC__stream_decoder_process_whole_stream()... ");
|
||||
if(!FLAC__stream_decoder_process_whole_stream(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -430,13 +448,13 @@ static FLAC__bool test_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__stream_decoder_process_metadata()... ");
|
||||
if(!FLAC__stream_decoder_process_metadata(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_until_end_of_metadata()... ");
|
||||
if(!FLAC__stream_decoder_process_until_end_of_metadata(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__stream_decoder_process_one_frame()... ");
|
||||
if(!FLAC__stream_decoder_process_one_frame(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_single()... ");
|
||||
if(!FLAC__stream_decoder_process_single(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -446,14 +464,14 @@ static FLAC__bool test_stream_decoder()
|
||||
printf("OK\n");
|
||||
|
||||
decoder_client_data.ignore_errors = true;
|
||||
printf("testing FLAC__stream_decoder_process_one_frame()... ");
|
||||
if(!FLAC__stream_decoder_process_one_frame(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_single()... ");
|
||||
if(!FLAC__stream_decoder_process_single(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
decoder_client_data.ignore_errors = false;
|
||||
|
||||
printf("testing FLAC__stream_decoder_process_remaining_frames()... ");
|
||||
if(!FLAC__stream_decoder_process_remaining_frames(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -517,8 +535,8 @@ static FLAC__bool test_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__stream_decoder_process_whole_stream()... ");
|
||||
if(!FLAC__stream_decoder_process_whole_stream(decoder))
|
||||
printf("testing FLAC__stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_s_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -980,8 +998,8 @@ static FLAC__bool seekable_stream_decoder_test_respond_(FLAC__SeekableStreamDeco
|
||||
return false;
|
||||
}
|
||||
|
||||
printf("testing FLAC__seekable_stream_decoder_process_whole_stream()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_whole_stream(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1123,13 +1141,13 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__seekable_stream_decoder_process_metadata()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_metadata(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_until_end_of_metadata()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_until_end_of_metadata(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__seekable_stream_decoder_process_one_frame()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_one_frame(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_single()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_single(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1139,8 +1157,8 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
printf("OK\n");
|
||||
|
||||
decoder_client_data.ignore_errors = true;
|
||||
printf("testing FLAC__seekable_stream_decoder_process_one_frame()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_one_frame(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_single()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_single(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
decoder_client_data.ignore_errors = false;
|
||||
@ -1150,8 +1168,8 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__seekable_stream_decoder_process_remaining_frames()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_remaining_frames(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1212,8 +1230,8 @@ static FLAC__bool test_seekable_stream_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__seekable_stream_decoder_process_whole_stream()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_whole_stream(decoder))
|
||||
printf("testing FLAC__seekable_stream_decoder_process_until_end_of_stream()... ");
|
||||
if(!FLAC__seekable_stream_decoder_process_until_end_of_stream(decoder))
|
||||
return die_ss_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1560,8 +1578,8 @@ static FLAC__bool file_decoder_test_respond_(FLAC__FileDecoder *decoder, file_de
|
||||
|
||||
dcd->current_metadata_number = 0;
|
||||
|
||||
printf("testing FLAC__file_decoder_process_whole_file()... ");
|
||||
if(!FLAC__file_decoder_process_whole_file(decoder))
|
||||
printf("testing FLAC__file_decoder_process_until_end_of_file()... ");
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(decoder))
|
||||
return die_f_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1680,13 +1698,13 @@ static FLAC__bool test_file_decoder()
|
||||
}
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__file_decoder_process_metadata()... ");
|
||||
if(!FLAC__file_decoder_process_metadata(decoder))
|
||||
printf("testing FLAC__file_decoder_process_until_end_of_metadata()... ");
|
||||
if(!FLAC__file_decoder_process_until_end_of_metadata(decoder))
|
||||
return die_f_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__file_decoder_process_one_frame()... ");
|
||||
if(!FLAC__file_decoder_process_one_frame(decoder))
|
||||
printf("testing FLAC__file_decoder_process_single()... ");
|
||||
if(!FLAC__file_decoder_process_single(decoder))
|
||||
return die_f_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
@ -1695,8 +1713,8 @@ static FLAC__bool test_file_decoder()
|
||||
return die_f_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
printf("testing FLAC__file_decoder_process_remaining_frames()... ");
|
||||
if(!FLAC__file_decoder_process_remaining_frames(decoder))
|
||||
printf("testing FLAC__file_decoder_process_until_end_of_file()... ");
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(decoder))
|
||||
return die_f_("returned false", decoder);
|
||||
printf("OK\n");
|
||||
|
||||
|
@ -327,7 +327,7 @@ static FLAC__bool test_file_(const char *filename, void (*metadata_callback)(con
|
||||
FLAC__file_decoder_delete(decoder);
|
||||
return die_("initializing decoder\n");
|
||||
}
|
||||
if(!FLAC__file_decoder_process_whole_file(decoder)) {
|
||||
if(!FLAC__file_decoder_process_until_end_of_file(decoder)) {
|
||||
FLAC__file_decoder_finish(decoder);
|
||||
FLAC__file_decoder_delete(decoder);
|
||||
return die_("decoding file\n");
|
||||
|
Loading…
Reference in New Issue
Block a user