Commit d86e03bc authored by Josh Coalson's avatar Josh Coalson
Browse files

add verify mode to all encoders

parent bf3f8b16
......@@ -23,6 +23,7 @@
#include "FLAC/file_encoder.h"
#include "FLAC/seekable_stream_encoder.h"
#include "FLAC/stream_encoder.h"
#include "decoder.h"
// ===============================================================
//
......@@ -97,6 +98,7 @@ namespace FLAC {
bool is_valid() const;
inline operator bool() const { return is_valid(); }
bool set_verify(bool value);
bool set_streamable_subset(bool value);
bool set_do_mid_side_stereo(bool value);
bool set_loose_mid_side_stereo(bool value);
......@@ -116,6 +118,8 @@ namespace FLAC {
bool set_metadata(::FLAC__StreamMetadata **metadata, unsigned num_blocks);
State get_state() const;
Decoder::Stream::State get_verify_decoder_state() const;
bool get_verify() const;
bool get_streamable_subset() const;
bool get_do_mid_side_stereo() const;
bool get_loose_mid_side_stereo() const;
......@@ -187,6 +191,7 @@ namespace FLAC {
bool is_valid() const;
inline operator bool() const { return is_valid(); }
bool set_verify(bool value);
bool set_streamable_subset(bool value);
bool set_do_mid_side_stereo(bool value);
bool set_loose_mid_side_stereo(bool value);
......@@ -207,6 +212,8 @@ namespace FLAC {
State get_state() const;
Stream::State get_stream_encoder_state() const;
Decoder::Stream::State get_verify_decoder_state() const;
bool get_verify() const;
bool get_streamable_subset() const;
bool get_do_mid_side_stereo() const;
bool get_loose_mid_side_stereo() const;
......@@ -278,6 +285,7 @@ namespace FLAC {
bool is_valid() const;
inline operator bool() const { return is_valid(); }
bool set_verify(bool value);
bool set_streamable_subset(bool value);
bool set_do_mid_side_stereo(bool value);
bool set_loose_mid_side_stereo(bool value);
......@@ -300,6 +308,8 @@ namespace FLAC {
State get_state() const;
SeekableStream::State get_seekable_stream_encoder_state() const;
Stream::State get_stream_encoder_state() const;
Decoder::Stream::State get_verify_decoder_state() const;
bool get_verify() const;
bool get_streamable_subset() const;
bool get_do_mid_side_stereo() const;
bool get_loose_mid_side_stereo() const;
......
......@@ -183,6 +183,19 @@ void FLAC__file_encoder_delete(FLAC__FileEncoder *encoder);
*
***********************************************************************/
/** This is inherited from FLAC__SeekableStreamEncoder; see
* FLAC__seekable_stream_encoder_set_verify().
*
* \default \c true
* \param encoder An encoder instance to set.
* \param value See above.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* \c false if the encoder is already initialized, else \c true.
*/
FLAC__bool FLAC__file_encoder_set_verify(FLAC__FileEncoder *encoder, FLAC__bool value);
/** This is inherited from FLAC__SeekableStreamEncoder; see
* FLAC__seekable_stream_encoder_set_streamable_subset().
*
......@@ -504,6 +517,32 @@ FLAC__SeekableStreamEncoderState FLAC__file_encoder_get_seekable_stream_encoder_
*/
FLAC__StreamEncoderState FLAC__file_encoder_get_stream_encoder_state(const FLAC__FileEncoder *encoder);
/** Get the state of the underlying stream encoder's verify decoder.
* Useful when the file encoder state is
* \c FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR and the seekable stream
* encoder state is \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and
* the stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__StreamEncoderState
* The stream encoder state.
*/
FLAC__StreamDecoderState FLAC__file_encoder_get_verify_decoder_state(const FLAC__FileEncoder *encoder);
/** Get the "verify" flag.
* This is inherited from FLAC__SeekableStreamEncoder; see
* FLAC__seekable_stream_encoder_get_verify().
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* See FLAC__file_encoder_set_verify().
*/
FLAC__bool FLAC__file_encoder_get_verify(const FLAC__FileEncoder *encoder);
/** Get the "streamable subset" flag.
* This is inherited from FLAC__SeekableStreamEncoder; see
* FLAC__seekable_stream_encoder_get_streamable_subset().
......
......@@ -195,6 +195,19 @@ void FLAC__seekable_stream_encoder_delete(FLAC__SeekableStreamEncoder *encoder);
*
***********************************************************************/
/** This is inherited from FLAC__StreamEncoder; see
* FLAC__stream_encoder_set_verify().
*
* \default \c true
* \param encoder An encoder instance to set.
* \param value See above.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* \c false if the encoder is already initialized, else \c true.
*/
FLAC__bool FLAC__seekable_stream_encoder_set_verify(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value);
/** This is inherited from FLAC__StreamEncoder; see
* FLAC__stream_encoder_set_streamable_subset().
*
......@@ -504,6 +517,31 @@ FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const F
*/
FLAC__StreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder);
/** Get the state of the underlying stream encoder's verify decoder.
* Useful when the seekable stream encoder state is
* \c FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR and the
* stream encoder state is \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__StreamEncoderState
* The stream encoder state.
*/
FLAC__StreamDecoderState FLAC__seekable_stream_encoder_get_verify_decoder_state(const FLAC__SeekableStreamEncoder *encoder);
/** Get the "verify" flag.
* This is inherited from FLAC__StreamEncoder; see
* FLAC__stream_encoder_get_verify().
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* See FLAC__seekable_stream_encoder_set_verify().
*/
FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder);
/** Get the "streamable subset" flag.
* This is inherited from FLAC__StreamEncoder; see
* FLAC__stream_encoder_get_streamable_subset().
......
......@@ -21,6 +21,7 @@
#define FLAC__STREAM_ENCODER_H
#include "format.h"
#include "stream_decoder.h"
#ifdef __cplusplus
extern "C" {
......@@ -176,6 +177,16 @@ typedef enum {
FLAC__STREAM_ENCODER_OK = 0,
/**< The encoder is in the normal OK state. */
FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR,
/**< An error occurred in the underlying verify stream decoder;
* check FLAC__stream_encoder_get_verify_decoder_state().
*/
FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA,
/**< The verify decoder detected a mismatch between the original
* audio signal and the decoded audio signal.
*/
FLAC__STREAM_ENCODER_INVALID_CALLBACK,
/**< The encoder was initialized before setting all the required callbacks. */
......@@ -316,6 +327,22 @@ void FLAC__stream_encoder_delete(FLAC__StreamEncoder *encoder);
*
***********************************************************************/
/** Set the "verify" flag. If \c true, the encoder will verify it's own
* encoded output by feeding it through an internal decoder and comparing
* the original signal against the decoded signal. If a mismatch occurs,
* the process call will return \c false. Note that this will slow the
* encoding process by the extra time required for decoding and comparison.
*
* \default \c false
* \param encoder An encoder instance to set.
* \param value Flag value (see above).
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* \c false if the encoder is already initialized, else \c true.
*/
FLAC__bool FLAC__stream_encoder_set_verify(FLAC__StreamEncoder *encoder, FLAC__bool value);
/** Set the "streamable subset" flag. If \c true, the encoder will comply
* with the subset (see the format specification) and will check the
* settings during FLAC__stream_encoder_init() to see if all settings
......@@ -652,6 +679,28 @@ FLAC__bool FLAC__stream_encoder_set_client_data(FLAC__StreamEncoder *encoder, vo
*/
FLAC__StreamEncoderState FLAC__stream_encoder_get_state(const FLAC__StreamEncoder *encoder);
/** Get the state of the verify stream decoder.
* Useful when the stream encoder state is
* \c FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR.
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__StreamDecoderState
* The verify stream decoder state.
*/
FLAC__StreamDecoderState FLAC__stream_encoder_get_verify_decoder_state(const FLAC__StreamEncoder *encoder);
/** Get the "verify" flag.
*
* \param encoder An encoder instance to query.
* \assert
* \code encoder != NULL \endcode
* \retval FLAC__bool
* See FLAC__stream_encoder_set_verify().
*/
FLAC__bool FLAC__stream_encoder_get_verify(const FLAC__StreamEncoder *encoder);
/** Get the "streamable subset" flag.
*
* \param encoder An encoder instance to query.
......
......@@ -40,6 +40,12 @@ namespace FLAC {
return 0 != encoder_;
}
bool File::set_verify(bool value)
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__file_encoder_set_verify(encoder_, value);
}
bool File::set_streamable_subset(bool value)
{
FLAC__ASSERT(is_valid());
......@@ -166,6 +172,18 @@ namespace FLAC {
return Stream::State(::FLAC__file_encoder_get_stream_encoder_state(encoder_));
}
Decoder::Stream::State File::get_verify_decoder_state() const
{
FLAC__ASSERT(is_valid());
return Decoder::Stream::State(::FLAC__file_encoder_get_verify_decoder_state(encoder_));
}
bool File::get_verify() const
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__file_encoder_get_verify(encoder_);
}
bool File::get_streamable_subset() const
{
FLAC__ASSERT(is_valid());
......
......@@ -40,6 +40,12 @@ namespace FLAC {
return 0 != encoder_;
}
bool SeekableStream::set_verify(bool value)
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__seekable_stream_encoder_set_verify(encoder_, value);
}
bool SeekableStream::set_streamable_subset(bool value)
{
FLAC__ASSERT(is_valid());
......@@ -154,6 +160,18 @@ namespace FLAC {
return Stream::State(::FLAC__seekable_stream_encoder_get_stream_encoder_state(encoder_));
}
Decoder::Stream::State SeekableStream::get_verify_decoder_state() const
{
FLAC__ASSERT(is_valid());
return Decoder::Stream::State(::FLAC__seekable_stream_encoder_get_verify_decoder_state(encoder_));
}
bool SeekableStream::get_verify() const
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__seekable_stream_encoder_get_verify(encoder_);
}
bool SeekableStream::get_streamable_subset() const
{
FLAC__ASSERT(is_valid());
......
......@@ -40,6 +40,12 @@ namespace FLAC {
return 0 != encoder_;
}
bool Stream::set_verify(bool value)
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__stream_encoder_set_verify(encoder_, value);
}
bool Stream::set_streamable_subset(bool value)
{
FLAC__ASSERT(is_valid());
......@@ -148,6 +154,18 @@ namespace FLAC {
return State(::FLAC__stream_encoder_get_state(encoder_));
}
Decoder::Stream::State Stream::get_verify_decoder_state() const
{
FLAC__ASSERT(is_valid());
return Decoder::Stream::State(::FLAC__stream_encoder_get_verify_decoder_state(encoder_));
}
bool Stream::get_verify() const
{
FLAC__ASSERT(is_valid());
return (bool)::FLAC__stream_encoder_get_verify(encoder_);
}
bool Stream::get_streamable_subset() const
{
FLAC__ASSERT(is_valid());
......
......@@ -83,20 +83,24 @@ FLAC__FileEncoder *FLAC__file_encoder_new()
if(encoder == 0) {
return 0;
}
memset(encoder, 0, sizeof(FLAC__FileEncoder));
encoder->protected_ = (FLAC__FileEncoderProtected*)malloc(sizeof(FLAC__FileEncoderProtected));
if(encoder->protected_ == 0) {
free(encoder);
return 0;
}
memset(encoder->protected_, 0, sizeof(FLAC__FileEncoderProtected));
encoder->private_ = (FLAC__FileEncoderPrivate*)malloc(sizeof(FLAC__FileEncoderPrivate));
if(encoder->private_ == 0) {
free(encoder->protected_);
free(encoder);
return 0;
}
memset(encoder->private_, 0, sizeof(FLAC__FileEncoderPrivate));
encoder->private_->seekable_stream_encoder = FLAC__seekable_stream_encoder_new();
if(0 == encoder->private_->seekable_stream_encoder) {
free(encoder->private_);
free(encoder->protected_);
......@@ -195,6 +199,17 @@ void FLAC__file_encoder_finish(FLAC__FileEncoder *encoder)
encoder->protected_->state = FLAC__FILE_ENCODER_UNINITIALIZED;
}
FLAC__bool FLAC__file_encoder_set_verify(FLAC__FileEncoder *encoder, FLAC__bool value)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
FLAC__ASSERT(0 != encoder->protected_);
FLAC__ASSERT(0 != encoder->private_->seekable_stream_encoder);
if(encoder->protected_->state != FLAC__FILE_ENCODER_UNINITIALIZED)
return false;
return FLAC__seekable_stream_encoder_set_verify(encoder->private_->seekable_stream_encoder, value);
}
FLAC__bool FLAC__file_encoder_set_streamable_subset(FLAC__FileEncoder *encoder, FLAC__bool value)
{
FLAC__ASSERT(0 != encoder);
......@@ -445,6 +460,20 @@ FLAC__StreamEncoderState FLAC__file_encoder_get_stream_encoder_state(const FLAC_
return FLAC__seekable_stream_encoder_get_stream_encoder_state(encoder->private_->seekable_stream_encoder);
}
FLAC__StreamDecoderState FLAC__file_encoder_get_verify_decoder_state(const FLAC__FileEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__seekable_stream_encoder_get_verify_decoder_state(encoder->private_->seekable_stream_encoder);
}
FLAC__bool FLAC__file_encoder_get_verify(const FLAC__FileEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__seekable_stream_encoder_get_verify(encoder->private_->seekable_stream_encoder);
}
FLAC__bool FLAC__file_encoder_get_streamable_subset(const FLAC__FileEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
......@@ -561,7 +590,12 @@ FLAC__bool FLAC__file_encoder_process(FLAC__FileEncoder *encoder, const FLAC__in
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__seekable_stream_encoder_process(encoder->private_->seekable_stream_encoder, buffer, samples);
if(!FLAC__seekable_stream_encoder_process(encoder->private_->seekable_stream_encoder, buffer, samples)) {
encoder->protected_->state = FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR;
return false;
}
else
return true;
}
/* 'samples' is channel-wide samples, e.g. for 1 second at 44100Hz, 'samples' = 44100 regardless of the number of channels */
......@@ -569,7 +603,12 @@ FLAC__bool FLAC__file_encoder_process_interleaved(FLAC__FileEncoder *encoder, co
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__seekable_stream_encoder_process_interleaved(encoder->private_->seekable_stream_encoder, buffer, samples);
if(!FLAC__seekable_stream_encoder_process_interleaved(encoder->private_->seekable_stream_encoder, buffer, samples)) {
encoder->protected_->state = FLAC__FILE_ENCODER_SEEKABLE_STREAM_ENCODER_ERROR;
return false;
}
else
return true;
}
......
......@@ -24,6 +24,7 @@
typedef struct FLAC__StreamEncoderProtected {
FLAC__StreamEncoderState state;
FLAC__bool verify;
FLAC__bool streamable_subset;
FLAC__bool do_mid_side_stereo;
FLAC__bool loose_mid_side_stereo;
......
......@@ -98,20 +98,24 @@ FLAC__SeekableStreamEncoder *FLAC__seekable_stream_encoder_new()
if(encoder == 0) {
return 0;
}
memset(encoder, 0, sizeof(FLAC__SeekableStreamEncoder));
encoder->protected_ = (FLAC__SeekableStreamEncoderProtected*)malloc(sizeof(FLAC__SeekableStreamEncoderProtected));
if(encoder->protected_ == 0) {
free(encoder);
return 0;
}
memset(encoder->protected_, 0, sizeof(FLAC__SeekableStreamEncoderProtected));
encoder->private_ = (FLAC__SeekableStreamEncoderPrivate*)malloc(sizeof(FLAC__SeekableStreamEncoderPrivate));
if(encoder->private_ == 0) {
free(encoder->protected_);
free(encoder);
return 0;
}
memset(encoder->private_, 0, sizeof(FLAC__SeekableStreamEncoderPrivate));
encoder->private_->stream_encoder = FLAC__stream_encoder_new();
if(0 == encoder->private_->stream_encoder) {
free(encoder->private_);
free(encoder->protected_);
......@@ -204,6 +208,17 @@ void FLAC__seekable_stream_encoder_finish(FLAC__SeekableStreamEncoder *encoder)
encoder->protected_->state = FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED;
}
FLAC__bool FLAC__seekable_stream_encoder_set_verify(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
FLAC__ASSERT(0 != encoder->protected_);
FLAC__ASSERT(0 != encoder->private_->stream_encoder);
if(encoder->protected_->state != FLAC__SEEKABLE_STREAM_ENCODER_UNINITIALIZED)
return false;
return FLAC__stream_encoder_set_verify(encoder->private_->stream_encoder, value);
}
FLAC__bool FLAC__seekable_stream_encoder_set_streamable_subset(FLAC__SeekableStreamEncoder *encoder, FLAC__bool value)
{
FLAC__ASSERT(0 != encoder);
......@@ -440,13 +455,27 @@ FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_state(const F
return encoder->protected_->state;
}
FLAC__SeekableStreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder)
FLAC__StreamEncoderState FLAC__seekable_stream_encoder_get_stream_encoder_state(const FLAC__SeekableStreamEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__stream_encoder_get_state(encoder->private_->stream_encoder);
}
FLAC__StreamDecoderState FLAC__seekable_stream_encoder_get_verify_decoder_state(const FLAC__SeekableStreamEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__stream_encoder_get_verify_decoder_state(encoder->private_->stream_encoder);
}
FLAC__bool FLAC__seekable_stream_encoder_get_verify(const FLAC__SeekableStreamEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__stream_encoder_get_verify(encoder->private_->stream_encoder);
}
FLAC__bool FLAC__seekable_stream_encoder_get_streamable_subset(const FLAC__SeekableStreamEncoder *encoder)
{
FLAC__ASSERT(0 != encoder);
......@@ -563,7 +592,12 @@ FLAC__bool FLAC__seekable_stream_encoder_process(FLAC__SeekableStreamEncoder *en
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__stream_encoder_process(encoder->private_->stream_encoder, buffer, samples);
if(!FLAC__stream_encoder_process(encoder->private_->stream_encoder, buffer, samples)) {
encoder->protected_->state = FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR;
return false;
}
else
return true;
}
/* 'samples' is channel-wide samples, e.g. for 1 second at 44100Hz, 'samples' = 44100 regardless of the number of channels */
......@@ -571,7 +605,12 @@ FLAC__bool FLAC__seekable_stream_encoder_process_interleaved(FLAC__SeekableStrea
{
FLAC__ASSERT(0 != encoder);
FLAC__ASSERT(0 != encoder->private_);
return FLAC__stream_encoder_process_interleaved(encoder->private_->stream_encoder, buffer, samples);
if(!FLAC__stream_encoder_process_interleaved(encoder->private_->stream_encoder, buffer, samples)) {
encoder->protected_->state = FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR;
return false;
}
else
return true;
}
/***********************************************************************
......
This diff is collapsed.
......@@ -180,6 +180,11 @@ static bool test_stream_encoder()
}
printf("OK\n");
printf("testing set_verify()... ");
if(!encoder->set_verify(true))
return encoder->die("returned false");
printf("OK\n");
printf("testing set_streamable_subset()... ");
if(!encoder->set_streamable_subset(true))
return encoder->die("returned false");
......@@ -274,6 +279,13 @@ static bool test_stream_encoder()
FLAC::Encoder::Stream::State state = encoder->get_state();
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamEncoderState)state), state.as_cstring());
printf("testing get_verify()... ");
if(encoder->get_verify() != true) {
printf("FAILED, expected true, got false\n");
return false;
}
printf("OK\n");
printf("testing get_streamable_subset()... ");
if(encoder->get_streamable_subset() != true) {
printf("FAILED, expected true, got false\n");
......@@ -450,6 +462,10 @@ bool SeekableStreamEncoder::die(const char *msg) const
if(state == ::FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR) {
FLAC::Encoder::Stream::State state_ = get_stream_encoder_state();
printf(" stream encoder state = %u (%s)\n", (unsigned)((::FLAC__StreamEncoderState)state_), state_.as_cstring());
if(state_ == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) {
FLAC::Decoder::Stream::State dstate = get_verify_decoder_state();
printf(" verify decoder state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring());
}
}
return false;
......@@ -479,6 +495,11 @@ static bool test_seekable_stream_encoder()
}
printf("OK\n");
printf("testing set_verify()... ");
if(!encoder->set_verify(true))
return encoder->die("returned false");
printf("OK\n");
printf("testing set_streamable_subset()... ");
if(!encoder->set_streamable_subset(true))
return encoder->die("returned false");
......@@ -577,6 +598,17 @@ static bool test_seekable_stream_encoder()
FLAC::Encoder::Stream::State state_ = encoder->get_stream_encoder_state();
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamEncoderState)state_), state_.as_cstring());
printf("testing get_verify_decoder_state()... ");
FLAC::Decoder::Stream::State dstate = encoder->get_verify_decoder_state();
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring());
printf("testing get_verify()... ");
if(encoder->get_verify() != true) {
printf("FAILED, expected true, got false\n");
return false;
}
printf("OK\n");
printf("testing get_streamable_subset()... ");
if(encoder->get_streamable_subset() != true) {
printf("FAILED, expected true, got false\n");
......@@ -746,6 +778,10 @@ bool FileEncoder::die(const char *msg) const
if(state_ == ::FLAC__SEEKABLE_STREAM_ENCODER_STREAM_ENCODER_ERROR) {
FLAC::Encoder::Stream::State state__ = get_stream_encoder_state();
printf(" stream encoder state = %u (%s)\n", (unsigned)((::FLAC__StreamEncoderState)state__), state__.as_cstring());
if(state__ == ::FLAC__STREAM_ENCODER_VERIFY_DECODER_ERROR) {
FLAC::Decoder::Stream::State dstate = get_verify_decoder_state();
printf(" verify decoder state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)dstate), dstate.as_cstring());
}
}
}
......@@ -776,6 +812,11 @@ static bool test_file_encoder()
}
printf("OK\n");
printf("testing set_verify()... ");
if(!encoder->set_verify(true))
return encoder->die("returned false");
printf("OK\n");