new funcs for getting underlying decoder layer states

This commit is contained in:
Josh Coalson 2002-08-01 07:28:03 +00:00
parent a5c12467d9
commit cad97be8de
5 changed files with 112 additions and 34 deletions

View File

@ -20,7 +20,7 @@
#ifndef FLAC__FILE_DECODER_H
#define FLAC__FILE_DECODER_H
#include "stream_decoder.h"
#include "seekable_stream_decoder.h"
#ifdef __cplusplus
extern "C" {
@ -389,6 +389,31 @@ FLAC__bool FLAC__file_decoder_set_metadata_ignore_all(FLAC__FileDecoder *decoder
*/
FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *decoder);
/** Get the state of the underlying seekable stream decoder.
* Useful when the file decoder state is
* \c FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR.
*
* \param decoder An decoder instance to query.
* \assert
* \code decoder != NULL \endcode
* \retval FLAC__SeekableStreamDecoderState
* The seekable stream decoder state.
*/
FLAC__SeekableStreamDecoderState FLAC__file_decoder_get_seekable_stream_decoder_state(const FLAC__FileDecoder *decoder);
/** Get the state of the underlying stream decoder.
* Useful when the file decoder state is
* \c FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR and the seekable stream
* decoder state is \c FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR.
*
* \param decoder An decoder instance to query.
* \assert
* \code decoder != NULL \endcode
* \retval FLAC__SeekableStreamDecoderState
* The seekable stream decoder state.
*/
FLAC__StreamDecoderState FLAC__file_decoder_get_stream_decoder_state(const FLAC__FileDecoder *decoder);
/** Get the "MD5 signature checking" flag.
* This is inherited from FLAC__SeekableStreamDecoder; see
* FLAC__seekable_stream_decoder_get_md5_checking().

View File

@ -570,6 +570,18 @@ FLAC__bool FLAC__seekable_stream_decoder_set_metadata_ignore_all(FLAC__SeekableS
*/
FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_state(const FLAC__SeekableStreamDecoder *decoder);
/** Get the state of the underlying stream decoder.
* Useful when the seekable stream decoder state is
* \c FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR.
*
* \param decoder An decoder instance to query.
* \assert
* \code decoder != NULL \endcode
* \retval FLAC__StreamDecoderState
* The stream decoder state.
*/
FLAC__StreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder);
/** Get the "MD5 signature checking" flag.
* This is the value of the setting, not whether or not the decoder is
* currently checking the MD5 (remember, it can be turned off automatically

View File

@ -362,6 +362,20 @@ FLAC__FileDecoderState FLAC__file_decoder_get_state(const FLAC__FileDecoder *dec
return decoder->protected_->state;
}
FLAC__SeekableStreamDecoderState FLAC__file_decoder_get_seekable_stream_decoder_state(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_state(decoder->private_->seekable_stream_decoder);
}
FLAC__StreamDecoderState FLAC__file_decoder_get_stream_decoder_state(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_stream_decoder_state(decoder->private_->seekable_stream_decoder);
}
FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
@ -371,37 +385,37 @@ FLAC__bool FLAC__file_decoder_get_md5_checking(const FLAC__FileDecoder *decoder)
unsigned FLAC__file_decoder_get_channels(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_channels(decoder->private_->seekable_stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_channels(decoder->private_->seekable_stream_decoder);
}
FLAC__ChannelAssignment FLAC__file_decoder_get_channel_assignment(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_channel_assignment(decoder->private_->seekable_stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_channel_assignment(decoder->private_->seekable_stream_decoder);
}
unsigned FLAC__file_decoder_get_bits_per_sample(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_bits_per_sample(decoder->private_->seekable_stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_bits_per_sample(decoder->private_->seekable_stream_decoder);
}
unsigned FLAC__file_decoder_get_sample_rate(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_sample_rate(decoder->private_->seekable_stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_sample_rate(decoder->private_->seekable_stream_decoder);
}
unsigned FLAC__file_decoder_get_blocksize(const FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_blocksize(decoder->private_->seekable_stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__seekable_stream_decoder_get_blocksize(decoder->private_->seekable_stream_decoder);
}
FLAC__bool FLAC__file_decoder_process_whole_file(FLAC__FileDecoder *decoder)
@ -504,6 +518,7 @@ FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__ui
}
}
/***********************************************************************
*
* Private class methods
@ -512,6 +527,9 @@ FLAC__bool FLAC__file_decoder_seek_absolute(FLAC__FileDecoder *decoder, FLAC__ui
void set_defaults_(FLAC__FileDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
decoder->private_->filename = 0;
decoder->private_->write_callback = 0;
decoder->private_->metadata_callback = 0;

View File

@ -83,9 +83,9 @@ const char * const FLAC__SeekableStreamDecoderStateString[] = {
"FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR",
"FLAC__SEEKABLE_STREAM_DECODER_READ_ERROR",
"FLAC__SEEKABLE_STREAM_DECODER_SEEK_ERROR",
"FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED",
"FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK",
"FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED"
"FLAC__SEEKABLE_STREAM_DECODER_ALREADY_INITIALIZED",
"FLAC__SEEKABLE_STREAM_DECODER_INVALID_CALLBACK",
"FLAC__SEEKABLE_STREAM_DECODER_UNINITIALIZED"
};
const char * const FLAC__SeekableStreamDecoderReadStatusString[] = {
@ -108,6 +108,7 @@ const char * const FLAC__SeekableStreamDecoderLengthStatusString[] = {
"FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR"
};
/***********************************************************************
*
* Class constructor/destructor
@ -444,6 +445,13 @@ FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_state(const F
return decoder->protected_->state;
}
FLAC__SeekableStreamDecoderState FLAC__seekable_stream_decoder_get_stream_decoder_state(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_state(decoder->private_->stream_decoder);
}
FLAC__bool FLAC__seekable_stream_decoder_get_md5_checking(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
@ -453,37 +461,37 @@ FLAC__bool FLAC__seekable_stream_decoder_get_md5_checking(const FLAC__SeekableSt
unsigned FLAC__seekable_stream_decoder_get_channels(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_channels(decoder->private_->stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_channels(decoder->private_->stream_decoder);
}
FLAC__ChannelAssignment FLAC__seekable_stream_decoder_get_channel_assignment(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_channel_assignment(decoder->private_->stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_channel_assignment(decoder->private_->stream_decoder);
}
unsigned FLAC__seekable_stream_decoder_get_bits_per_sample(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_bits_per_sample(decoder->private_->stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_bits_per_sample(decoder->private_->stream_decoder);
}
unsigned FLAC__seekable_stream_decoder_get_sample_rate(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_sample_rate(decoder->private_->stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_sample_rate(decoder->private_->stream_decoder);
}
unsigned FLAC__seekable_stream_decoder_get_blocksize(const FLAC__SeekableStreamDecoder *decoder)
{
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_blocksize(decoder->private_->stream_decoder);
FLAC__ASSERT(0 != decoder);
FLAC__ASSERT(0 != decoder->private_);
return FLAC__stream_decoder_get_blocksize(decoder->private_->stream_decoder);
}
FLAC__bool FLAC__seekable_stream_decoder_flush(FLAC__SeekableStreamDecoder *decoder)

View File

@ -996,6 +996,7 @@ static FLAC__bool test_seekable_stream_decoder()
{
FLAC__SeekableStreamDecoder *decoder;
FLAC__SeekableStreamDecoderState state;
FLAC__StreamDecoderState sstate;
seekable_stream_decoder_client_data_struct decoder_client_data;
printf("\n+++ libFLAC unit test: FLAC__SeekableStreamDecoder\n\n");
@ -1099,6 +1100,10 @@ static FLAC__bool test_seekable_stream_decoder()
state = FLAC__seekable_stream_decoder_get_state(decoder);
printf("returned state = %u (%s)... OK\n", state, FLAC__SeekableStreamDecoderStateString[state]);
printf("testing FLAC__seekable_stream_decoder_get_stream_decoder_state()... ");
sstate = FLAC__seekable_stream_decoder_get_stream_decoder_state(decoder);
printf("returned state = %u (%s)... OK\n", sstate, FLAC__StreamDecoderStateString[sstate]);
decoder_client_data.current_metadata_number = 0;
decoder_client_data.ignore_errors = false;
decoder_client_data.error_occurred = false;
@ -1571,6 +1576,8 @@ static FLAC__bool test_file_decoder()
{
FLAC__FileDecoder *decoder;
FLAC__FileDecoderState state;
FLAC__SeekableStreamDecoderState ssstate;
FLAC__StreamDecoderState sstate;
seekable_stream_decoder_client_data_struct decoder_client_data;
printf("\n+++ libFLAC unit test: FLAC__FileDecoder\n\n");
@ -1654,6 +1661,14 @@ static FLAC__bool test_file_decoder()
state = FLAC__file_decoder_get_state(decoder);
printf("returned state = %u (%s)... OK\n", state, FLAC__FileDecoderStateString[state]);
printf("testing FLAC__file_decoder_get_seekable_stream_decoder_state()... ");
ssstate = FLAC__file_decoder_get_seekable_stream_decoder_state(decoder);
printf("returned state = %u (%s)... OK\n", ssstate, FLAC__SeekableStreamDecoderStateString[ssstate]);
printf("testing FLAC__file_decoder_get_stream_decoder_state()... ");
sstate = FLAC__file_decoder_get_stream_decoder_state(decoder);
printf("returned state = %u (%s)... OK\n", sstate, FLAC__StreamDecoderStateString[sstate]);
decoder_client_data.current_metadata_number = 0;
decoder_client_data.ignore_errors = false;
decoder_client_data.error_occurred = false;