2002-06-07 05:27:37 +00:00
|
|
|
/* test_libFLAC++ - Unit tester for libFLAC++
|
2006-04-25 06:59:33 +00:00
|
|
|
* Copyright (C) 2002,2003,2004,2005,2006 Josh Coalson
|
2002-06-07 05:27:37 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-05-24 04:41:36 +00:00
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#if defined _MSC_VER || defined __MINGW32__
|
|
|
|
|
//@@@ [2G limit] hacks for MSVC6
|
|
|
|
|
#define fseeko fseek
|
|
|
|
|
#define ftello ftell
|
|
|
|
|
#endif
|
2002-06-07 05:27:37 +00:00
|
|
|
#include "decoders.h"
|
|
|
|
|
extern "C" {
|
|
|
|
|
#include "file_utils.h"
|
2003-01-10 05:40:09 +00:00
|
|
|
#include "metadata_utils.h"
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
#include "FLAC/assert.h"
|
|
|
|
|
#include "FLAC/metadata.h" // for ::FLAC__metadata_object_is_equal()
|
|
|
|
|
#include "FLAC++/decoder.h"
|
2002-11-07 05:07:30 +00:00
|
|
|
#include "share/grabbag.h"
|
2002-06-07 05:27:37 +00:00
|
|
|
|
2004-07-23 05:11:06 +00:00
|
|
|
#ifdef _MSC_VER
|
|
|
|
|
// warning C4800: 'int' : forcing to bool 'true' or 'false' (performance warning)
|
|
|
|
|
#pragma warning ( disable : 4800 )
|
|
|
|
|
#endif
|
|
|
|
|
|
2003-01-10 08:15:35 +00:00
|
|
|
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
|
|
|
|
|
static ::FLAC__StreamMetadata *expected_metadata_sequence_[8];
|
2002-06-07 05:27:37 +00:00
|
|
|
static unsigned num_expected_;
|
|
|
|
|
static const char *flacfilename_ = "metadata.flac";
|
2006-05-24 04:41:36 +00:00
|
|
|
static off_t flacfilesize_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
static bool die_(const char *msg)
|
|
|
|
|
{
|
|
|
|
|
printf("ERROR: %s\n", msg);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void init_metadata_blocks_()
|
|
|
|
|
{
|
2003-01-10 08:15:35 +00:00
|
|
|
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void free_metadata_blocks_()
|
|
|
|
|
{
|
2003-01-10 08:15:35 +00:00
|
|
|
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool generate_file_()
|
|
|
|
|
{
|
|
|
|
|
printf("\n\ngenerating FLAC file for decoder tests...\n");
|
|
|
|
|
|
2003-01-10 05:40:09 +00:00
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!file_utils__generate_flacfile(flacfilename_, &flacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_))
|
2002-08-27 05:46:11 +00:00
|
|
|
return die_("creating the encoded file");
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class DecoderCommon {
|
|
|
|
|
public:
|
|
|
|
|
FILE *file_;
|
|
|
|
|
unsigned current_metadata_number_;
|
|
|
|
|
bool ignore_errors_;
|
|
|
|
|
bool error_occurred_;
|
|
|
|
|
|
|
|
|
|
DecoderCommon(): file_(0), current_metadata_number_(0), ignore_errors_(false), error_occurred_(false) { }
|
|
|
|
|
::FLAC__StreamDecoderReadStatus common_read_callback_(FLAC__byte buffer[], unsigned *bytes);
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus common_write_callback_(const ::FLAC__Frame *frame);
|
2002-06-08 04:53:42 +00:00
|
|
|
void common_metadata_callback_(const ::FLAC__StreamMetadata *metadata);
|
2002-06-07 05:27:37 +00:00
|
|
|
void common_error_callback_(::FLAC__StreamDecoderErrorStatus status);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderReadStatus DecoderCommon::common_read_callback_(FLAC__byte buffer[], unsigned *bytes)
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
|
|
|
|
|
|
|
|
|
if(feof(file_))
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
2002-08-27 05:46:11 +00:00
|
|
|
else if(*bytes > 0) {
|
|
|
|
|
unsigned bytes_read = ::fread(buffer, 1, *bytes, file_);
|
|
|
|
|
if(bytes_read == 0) {
|
|
|
|
|
if(feof(file_))
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
|
|
|
|
|
else
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
*bytes = bytes_read;
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return ::FLAC__STREAM_DECODER_READ_STATUS_ABORT; /* abort to avoid a deadlock */
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus DecoderCommon::common_write_callback_(const ::FLAC__Frame *frame)
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return ::FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
|
|
|
|
2002-08-27 05:46:11 +00:00
|
|
|
if(
|
|
|
|
|
(frame->header.number_type == ::FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER && frame->header.number.frame_number == 0) ||
|
|
|
|
|
(frame->header.number_type == ::FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER && frame->header.number.sample_number == 0)
|
|
|
|
|
) {
|
|
|
|
|
printf("content... ");
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
}
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
return ::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
void DecoderCommon::common_metadata_callback_(const ::FLAC__StreamMetadata *metadata)
|
2002-06-07 05:27:37 +00:00
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
printf("%d... ", current_metadata_number_);
|
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
|
|
if(current_metadata_number_ >= num_expected_) {
|
|
|
|
|
(void)die_("got more metadata blocks than expected");
|
|
|
|
|
error_occurred_ = true;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
if(!::FLAC__metadata_object_is_equal(expected_metadata_sequence_[current_metadata_number_], metadata)) {
|
|
|
|
|
(void)die_("metadata block mismatch");
|
|
|
|
|
error_occurred_ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
current_metadata_number_++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DecoderCommon::common_error_callback_(::FLAC__StreamDecoderErrorStatus status)
|
|
|
|
|
{
|
|
|
|
|
if(!ignore_errors_) {
|
|
|
|
|
printf("ERROR: got error callback: err = %u (%s)\n", (unsigned)status, ::FLAC__StreamDecoderErrorStatusString[status]);
|
|
|
|
|
error_occurred_ = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class StreamDecoder : public FLAC::Decoder::Stream, public DecoderCommon {
|
|
|
|
|
public:
|
|
|
|
|
StreamDecoder(): FLAC::Decoder::Stream(), DecoderCommon() { }
|
|
|
|
|
~StreamDecoder() { }
|
|
|
|
|
|
|
|
|
|
// from FLAC::Decoder::Stream
|
|
|
|
|
::FLAC__StreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
|
2002-06-08 04:53:42 +00:00
|
|
|
void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
2002-06-07 05:27:37 +00:00
|
|
|
void error_callback(::FLAC__StreamDecoderErrorStatus status);
|
|
|
|
|
|
|
|
|
|
bool die(const char *msg = 0) const;
|
|
|
|
|
|
|
|
|
|
bool test_respond();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderReadStatus StreamDecoder::read_callback(FLAC__byte buffer[], unsigned *bytes)
|
|
|
|
|
{
|
|
|
|
|
return common_read_callback_(buffer, bytes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus StreamDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
|
|
|
|
{
|
|
|
|
|
(void)buffer;
|
|
|
|
|
|
|
|
|
|
return common_write_callback_(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
void StreamDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
2002-06-07 05:27:37 +00:00
|
|
|
{
|
2002-06-11 06:15:28 +00:00
|
|
|
common_metadata_callback_(metadata);
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StreamDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
|
|
|
|
{
|
2002-06-11 06:15:28 +00:00
|
|
|
common_error_callback_(status);
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StreamDecoder::die(const char *msg) const
|
|
|
|
|
{
|
|
|
|
|
State state = get_state();
|
|
|
|
|
|
|
|
|
|
if(msg)
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED, %s", msg);
|
2002-06-07 05:27:37 +00:00
|
|
|
else
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED");
|
|
|
|
|
|
|
|
|
|
printf(", state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool StreamDecoder::test_respond()
|
|
|
|
|
{
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(init() != ::FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
|
|
|
|
|
return die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
current_metadata_number_ = 0;
|
|
|
|
|
|
2006-05-24 04:41:36 +00:00
|
|
|
if(fseeko(file_, 0, SEEK_SET) < 0) {
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("FAILED rewinding input, errno = %d\n", errno);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!process_until_end_of_stream()) {
|
2002-06-07 05:27:37 +00:00
|
|
|
State state = get_state();
|
|
|
|
|
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state), state.as_cstring());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool test_stream_decoder()
|
|
|
|
|
{
|
|
|
|
|
StreamDecoder *decoder;
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
printf("\n+++ libFLAC++ unit test: FLAC::Decoder::Stream\n\n");
|
2002-06-07 05:27:37 +00:00
|
|
|
|
2002-06-14 06:36:16 +00:00
|
|
|
//
|
|
|
|
|
// test new -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new StreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test new -> init -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new StreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(decoder->init() != ::FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
|
|
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test normal usage
|
|
|
|
|
//
|
2002-06-07 05:27:37 +00:00
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new StreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(decoder->init() != ::FLAC__STREAM_DECODER_SEARCH_FOR_METADATA)
|
|
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_state()... ");
|
|
|
|
|
FLAC::Decoder::Stream::State state = decoder->get_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;
|
|
|
|
|
|
|
|
|
|
printf("opening FLAC file... ");
|
|
|
|
|
decoder->file_ = ::fopen(flacfilename_, "rb");
|
|
|
|
|
if(0 == decoder->file_) {
|
2006-05-24 04:41:36 +00:00
|
|
|
printf("ERROR (%s)\n", strerror(errno));
|
2002-06-07 05:27:37 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_metadata()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_metadata())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_single()... ");
|
|
|
|
|
if(!decoder->process_single())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2004-07-16 00:53:38 +00:00
|
|
|
printf("testing skip_single_frame()... ");
|
|
|
|
|
if(!decoder->skip_single_frame())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("testing flush()... ");
|
|
|
|
|
if(!decoder->flush())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
decoder->ignore_errors_ = true;
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_single()... ");
|
|
|
|
|
if(!decoder->process_single())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
decoder->ignore_errors_ = false;
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_stream())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_channels()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned channels = decoder->get_channels();
|
|
|
|
|
if(channels != streaminfo_.data.stream_info.channels) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_bits_per_sample()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned bits_per_sample = decoder->get_bits_per_sample();
|
|
|
|
|
if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_sample_rate()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned sample_rate = decoder->get_sample_rate();
|
|
|
|
|
if(sample_rate != streaminfo_.data.stream_info.sample_rate) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_blocksize()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned blocksize = decoder->get_blocksize();
|
|
|
|
|
/* value could be anything since we're at the last block, so accept any answer */
|
|
|
|
|
printf("returned %u... OK\n", blocksize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing get_channel_assignment()... ");
|
|
|
|
|
{
|
|
|
|
|
::FLAC__ChannelAssignment ca = decoder->get_channel_assignment();
|
|
|
|
|
printf("returned %u (%s)... OK\n", (unsigned)ca, ::FLAC__ChannelAssignmentString[ca]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing reset()... ");
|
|
|
|
|
if(!decoder->reset())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
decoder->current_metadata_number_ = 0;
|
|
|
|
|
|
|
|
|
|
printf("rewinding input... ");
|
2006-05-24 04:41:36 +00:00
|
|
|
if(fseeko(decoder->file_, 0, SEEK_SET) < 0) {
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("FAILED, errno = %d\n", errno);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_stream())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
decoder->finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* done, now leave the sequence the way we found it... */
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
::fclose(decoder->file_);
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("\nPASSED!\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class SeekableStreamDecoder : public FLAC::Decoder::SeekableStream, public DecoderCommon {
|
|
|
|
|
public:
|
|
|
|
|
SeekableStreamDecoder(): FLAC::Decoder::SeekableStream(), DecoderCommon() { }
|
|
|
|
|
~SeekableStreamDecoder() { }
|
|
|
|
|
|
|
|
|
|
// from FLAC::Decoder::SeekableStream
|
|
|
|
|
::FLAC__SeekableStreamDecoderReadStatus read_callback(FLAC__byte buffer[], unsigned *bytes);
|
|
|
|
|
::FLAC__SeekableStreamDecoderSeekStatus seek_callback(FLAC__uint64 absolute_byte_offset);
|
|
|
|
|
::FLAC__SeekableStreamDecoderTellStatus tell_callback(FLAC__uint64 *absolute_byte_offset);
|
|
|
|
|
::FLAC__SeekableStreamDecoderLengthStatus length_callback(FLAC__uint64 *stream_length);
|
|
|
|
|
bool eof_callback();
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
|
2002-06-08 04:53:42 +00:00
|
|
|
void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
2002-06-07 05:27:37 +00:00
|
|
|
void error_callback(::FLAC__StreamDecoderErrorStatus status);
|
|
|
|
|
|
|
|
|
|
bool die(const char *msg = 0) const;
|
|
|
|
|
|
|
|
|
|
bool test_respond();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
::FLAC__SeekableStreamDecoderReadStatus SeekableStreamDecoder::read_callback(FLAC__byte buffer[], unsigned *bytes)
|
|
|
|
|
{
|
|
|
|
|
switch(common_read_callback_(buffer, bytes)) {
|
|
|
|
|
case ::FLAC__STREAM_DECODER_READ_STATUS_CONTINUE:
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_OK;
|
|
|
|
|
case ::FLAC__STREAM_DECODER_READ_STATUS_ABORT:
|
|
|
|
|
case ::FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM:
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
|
|
|
|
default:
|
|
|
|
|
FLAC__ASSERT(0);
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_READ_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__SeekableStreamDecoderSeekStatus SeekableStreamDecoder::seek_callback(FLAC__uint64 absolute_byte_offset)
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
|
|
|
|
|
2006-05-24 04:41:36 +00:00
|
|
|
if(fseeko(file_, (off_t)absolute_byte_offset, SEEK_SET) < 0) {
|
2002-06-07 05:27:37 +00:00
|
|
|
error_occurred_ = true;
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_SEEK_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__SeekableStreamDecoderTellStatus SeekableStreamDecoder::tell_callback(FLAC__uint64 *absolute_byte_offset)
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
|
|
|
|
|
2006-05-24 04:41:36 +00:00
|
|
|
off_t offset = ftello(file_);
|
2002-06-07 05:27:37 +00:00
|
|
|
*absolute_byte_offset = (FLAC__uint64)offset;
|
|
|
|
|
|
|
|
|
|
if(offset < 0) {
|
|
|
|
|
error_occurred_ = true;
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_TELL_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__SeekableStreamDecoderLengthStatus SeekableStreamDecoder::length_callback(FLAC__uint64 *stream_length)
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_ERROR;
|
|
|
|
|
|
|
|
|
|
*stream_length = (FLAC__uint64)flacfilesize_;
|
|
|
|
|
return ::FLAC__SEEKABLE_STREAM_DECODER_LENGTH_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SeekableStreamDecoder::eof_callback()
|
|
|
|
|
{
|
|
|
|
|
if(error_occurred_)
|
|
|
|
|
return true;
|
|
|
|
|
|
2002-06-11 06:15:28 +00:00
|
|
|
return (bool)feof(file_);
|
2002-06-07 05:27:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus SeekableStreamDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
|
|
|
|
{
|
|
|
|
|
(void)buffer;
|
|
|
|
|
|
|
|
|
|
return common_write_callback_(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
void SeekableStreamDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
2002-06-07 05:27:37 +00:00
|
|
|
{
|
|
|
|
|
common_metadata_callback_(metadata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void SeekableStreamDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
|
|
|
|
{
|
|
|
|
|
common_error_callback_(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SeekableStreamDecoder::die(const char *msg) const
|
|
|
|
|
{
|
|
|
|
|
State state = get_state();
|
|
|
|
|
|
|
|
|
|
if(msg)
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED, %s", msg);
|
2002-06-07 05:27:37 +00:00
|
|
|
else
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED");
|
|
|
|
|
|
|
|
|
|
printf(", state = %u (%s)\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state), state.as_cstring());
|
|
|
|
|
if(state == ::FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
|
|
|
|
|
FLAC::Decoder::Stream::State state_ = get_stream_decoder_state();
|
|
|
|
|
printf(" stream decoder state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state_), state_.as_cstring());
|
|
|
|
|
}
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool SeekableStreamDecoder::test_respond()
|
|
|
|
|
{
|
|
|
|
|
if(!set_md5_checking(true)) {
|
|
|
|
|
printf("FAILED at set_md5_checking(), returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(init() != ::FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
|
|
|
return die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
current_metadata_number_ = 0;
|
|
|
|
|
|
2006-05-24 04:41:36 +00:00
|
|
|
if(fseeko(file_, 0, SEEK_SET) < 0) {
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("FAILED rewinding input, errno = %d\n", errno);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!process_until_end_of_stream()) {
|
2002-06-07 05:27:37 +00:00
|
|
|
State state = get_state();
|
|
|
|
|
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state), state.as_cstring());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool test_seekable_stream_decoder()
|
|
|
|
|
{
|
|
|
|
|
SeekableStreamDecoder *decoder;
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
printf("\n+++ libFLAC++ unit test: FLAC::Decoder::SeekableStream\n\n");
|
2002-06-07 05:27:37 +00:00
|
|
|
|
2002-06-14 06:36:16 +00:00
|
|
|
//
|
|
|
|
|
// test new -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new SeekableStreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test new -> init -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new SeekableStreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(decoder->init() != ::FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test normal usage
|
|
|
|
|
//
|
2002-06-07 05:27:37 +00:00
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new SeekableStreamDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_md5_checking()... ");
|
|
|
|
|
if(!decoder->set_md5_checking(true)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(decoder->init() != ::FLAC__SEEKABLE_STREAM_DECODER_OK)
|
|
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_state()... ");
|
|
|
|
|
FLAC::Decoder::SeekableStream::State state = decoder->get_state();
|
|
|
|
|
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state), state.as_cstring());
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
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());
|
|
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
decoder->current_metadata_number_ = 0;
|
|
|
|
|
decoder->ignore_errors_ = false;
|
|
|
|
|
decoder->error_occurred_ = false;
|
|
|
|
|
|
|
|
|
|
printf("opening FLAC file... ");
|
|
|
|
|
decoder->file_ = ::fopen(flacfilename_, "rb");
|
|
|
|
|
if(0 == decoder->file_) {
|
2006-05-24 04:41:36 +00:00
|
|
|
printf("ERROR (%s)\n", strerror(errno));
|
2002-06-07 05:27:37 +00:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_md5_checking()... ");
|
|
|
|
|
if(!decoder->get_md5_checking()) {
|
|
|
|
|
printf("FAILED, returned false, expected true\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_metadata()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_metadata())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_single()... ");
|
|
|
|
|
if(!decoder->process_single())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2004-07-16 00:53:38 +00:00
|
|
|
printf("testing skip_single_frame()... ");
|
|
|
|
|
if(!decoder->skip_single_frame())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("testing flush()... ");
|
|
|
|
|
if(!decoder->flush())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
decoder->ignore_errors_ = true;
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_single()... ");
|
|
|
|
|
if(!decoder->process_single())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
decoder->ignore_errors_ = false;
|
|
|
|
|
|
|
|
|
|
printf("testing seek_absolute()... ");
|
|
|
|
|
if(!decoder->seek_absolute(0))
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_stream())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_channels()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned channels = decoder->get_channels();
|
|
|
|
|
if(channels != streaminfo_.data.stream_info.channels) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_bits_per_sample()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned bits_per_sample = decoder->get_bits_per_sample();
|
|
|
|
|
if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_sample_rate()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned sample_rate = decoder->get_sample_rate();
|
|
|
|
|
if(sample_rate != streaminfo_.data.stream_info.sample_rate) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_blocksize()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned blocksize = decoder->get_blocksize();
|
|
|
|
|
/* value could be anything since we're at the last block, so accept any answer */
|
|
|
|
|
printf("returned %u... OK\n", blocksize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing get_channel_assignment()... ");
|
|
|
|
|
{
|
|
|
|
|
::FLAC__ChannelAssignment ca = decoder->get_channel_assignment();
|
|
|
|
|
printf("returned %u (%s)... OK\n", (unsigned)ca, ::FLAC__ChannelAssignmentString[ca]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing reset()... ");
|
|
|
|
|
if(!decoder->reset())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
decoder->current_metadata_number_ = 0;
|
|
|
|
|
|
|
|
|
|
printf("rewinding input... ");
|
2006-05-24 04:41:36 +00:00
|
|
|
if(fseeko(decoder->file_, 0, SEEK_SET) < 0) {
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("FAILED, errno = %d\n", errno);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_stream()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_stream())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
decoder->finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* done, now leave the sequence the way we found it... */
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
::fclose(decoder->file_);
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("\nPASSED!\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class FileDecoder : public FLAC::Decoder::File, public DecoderCommon {
|
|
|
|
|
public:
|
|
|
|
|
FileDecoder(): FLAC::Decoder::File(), DecoderCommon() { }
|
|
|
|
|
~FileDecoder() { }
|
|
|
|
|
|
|
|
|
|
// from FLAC::Decoder::File
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[]);
|
2002-06-08 04:53:42 +00:00
|
|
|
void metadata_callback(const ::FLAC__StreamMetadata *metadata);
|
2002-06-07 05:27:37 +00:00
|
|
|
void error_callback(::FLAC__StreamDecoderErrorStatus status);
|
|
|
|
|
|
|
|
|
|
bool die(const char *msg = 0) const;
|
|
|
|
|
|
|
|
|
|
bool test_respond();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
::FLAC__StreamDecoderWriteStatus FileDecoder::write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const buffer[])
|
|
|
|
|
{
|
|
|
|
|
(void)buffer;
|
|
|
|
|
return common_write_callback_(frame);
|
|
|
|
|
}
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
void FileDecoder::metadata_callback(const ::FLAC__StreamMetadata *metadata)
|
2002-06-07 05:27:37 +00:00
|
|
|
{
|
|
|
|
|
common_metadata_callback_(metadata);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FileDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
|
|
|
|
{
|
|
|
|
|
common_error_callback_(status);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FileDecoder::die(const char *msg) const
|
|
|
|
|
{
|
|
|
|
|
State state = get_state();
|
|
|
|
|
|
|
|
|
|
if(msg)
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED, %s", msg);
|
2002-06-07 05:27:37 +00:00
|
|
|
else
|
2002-08-03 22:01:35 +00:00
|
|
|
printf("FAILED");
|
|
|
|
|
|
|
|
|
|
printf(", state = %u (%s)\n", (unsigned)((::FLAC__FileDecoderState)state), state.as_cstring());
|
|
|
|
|
if(state == ::FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) {
|
|
|
|
|
FLAC::Decoder::SeekableStream::State state_ = get_seekable_stream_decoder_state();
|
|
|
|
|
printf(" seekable stream decoder state = %u (%s)\n", (unsigned)((::FLAC__SeekableStreamDecoderState)state_), state_.as_cstring());
|
|
|
|
|
if(state_ == ::FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
|
|
|
|
|
FLAC::Decoder::Stream::State state__ = get_stream_decoder_state();
|
|
|
|
|
printf(" stream decoder state = %u (%s)\n", (unsigned)((::FLAC__StreamDecoderState)state__), state__.as_cstring());
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FileDecoder::test_respond()
|
|
|
|
|
{
|
|
|
|
|
if(!set_filename(flacfilename_)) {
|
|
|
|
|
printf("FAILED at set_filename(), returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!set_md5_checking(true)) {
|
|
|
|
|
printf("FAILED at set_md5_checking(), returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(init() != ::FLAC__FILE_DECODER_OK)
|
|
|
|
|
return die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
current_metadata_number_ = 0;
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_file()... ");
|
|
|
|
|
if(!process_until_end_of_file()) {
|
2002-06-07 05:27:37 +00:00
|
|
|
State state = get_state();
|
|
|
|
|
printf("FAILED, returned false, state = %u (%s)\n", (unsigned)((::FLAC__FileDecoderState)state), state.as_cstring());
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool test_file_decoder()
|
|
|
|
|
{
|
|
|
|
|
FileDecoder *decoder;
|
|
|
|
|
|
2002-06-08 04:53:42 +00:00
|
|
|
printf("\n+++ libFLAC++ unit test: FLAC::Decoder::File\n\n");
|
2002-06-07 05:27:37 +00:00
|
|
|
|
2002-06-14 06:36:16 +00:00
|
|
|
//
|
|
|
|
|
// test new -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new FileDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test new -> init -> delete
|
|
|
|
|
//
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new FileDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
2003-09-26 01:46:21 +00:00
|
|
|
if(decoder->init() != ::FLAC__FILE_DECODER_OK)
|
2002-06-14 06:36:16 +00:00
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// test normal usage
|
|
|
|
|
//
|
2002-06-07 05:27:37 +00:00
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
|
|
|
|
|
printf("allocating decoder instance... ");
|
|
|
|
|
decoder = new FileDecoder();
|
|
|
|
|
if(0 == decoder) {
|
|
|
|
|
printf("FAILED, new returned NULL\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing is_valid()... ");
|
|
|
|
|
if(!decoder->is_valid()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_filename()... ");
|
|
|
|
|
if(!decoder->set_filename(flacfilename_)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_md5_checking()... ");
|
|
|
|
|
if(!decoder->set_md5_checking(true)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing init()... ");
|
|
|
|
|
if(decoder->init() != ::FLAC__FILE_DECODER_OK)
|
|
|
|
|
return decoder->die();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_state()... ");
|
|
|
|
|
FLAC::Decoder::File::State state = decoder->get_state();
|
|
|
|
|
printf("returned state = %u (%s)... OK\n", (unsigned)((::FLAC__FileDecoderState)state), state.as_cstring());
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
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());
|
|
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
decoder->current_metadata_number_ = 0;
|
|
|
|
|
decoder->ignore_errors_ = false;
|
|
|
|
|
decoder->error_occurred_ = false;
|
|
|
|
|
|
|
|
|
|
printf("testing get_md5_checking()... ");
|
|
|
|
|
if(!decoder->get_md5_checking()) {
|
|
|
|
|
printf("FAILED, returned false, expected true\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_metadata()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_metadata())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_single()... ");
|
|
|
|
|
if(!decoder->process_single())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2004-07-16 00:53:38 +00:00
|
|
|
printf("testing skip_single_frame()... ");
|
|
|
|
|
if(!decoder->skip_single_frame())
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
printf("testing seek_absolute()... ");
|
|
|
|
|
if(!decoder->seek_absolute(0))
|
|
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
2002-08-02 06:12:36 +00:00
|
|
|
printf("testing process_until_end_of_file()... ");
|
|
|
|
|
if(!decoder->process_until_end_of_file())
|
2002-06-07 05:27:37 +00:00
|
|
|
return decoder->die("returned false");
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_channels()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned channels = decoder->get_channels();
|
|
|
|
|
if(channels != streaminfo_.data.stream_info.channels) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", channels, streaminfo_.data.stream_info.channels);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_bits_per_sample()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned bits_per_sample = decoder->get_bits_per_sample();
|
|
|
|
|
if(bits_per_sample != streaminfo_.data.stream_info.bits_per_sample) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", bits_per_sample, streaminfo_.data.stream_info.bits_per_sample);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_sample_rate()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned sample_rate = decoder->get_sample_rate();
|
|
|
|
|
if(sample_rate != streaminfo_.data.stream_info.sample_rate) {
|
|
|
|
|
printf("FAILED, returned %u, expected %u\n", sample_rate, streaminfo_.data.stream_info.sample_rate);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing get_blocksize()... ");
|
|
|
|
|
{
|
|
|
|
|
unsigned blocksize = decoder->get_blocksize();
|
|
|
|
|
/* value could be anything since we're at the last block, so accept any answer */
|
|
|
|
|
printf("returned %u... OK\n", blocksize);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing get_channel_assignment()... ");
|
|
|
|
|
{
|
|
|
|
|
::FLAC__ChannelAssignment ca = decoder->get_channel_assignment();
|
|
|
|
|
printf("returned %u (%s)... OK\n", (unsigned)ca, ::FLAC__ChannelAssignmentString[ca]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("testing finish()... ");
|
|
|
|
|
decoder->finish();
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond VORBIS_COMMENT
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(VORBIS_COMMENT)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION id of app#1 & app#2
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #2)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application2_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* respond all, ignore APPLICATION, respond APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* ignore all, respond APPLICATION, ignore APPLICATION id of app#1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_all()... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_all()) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_respond(APPLICATION)... ");
|
|
|
|
|
if(!decoder->set_metadata_respond(FLAC__METADATA_TYPE_APPLICATION)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("testing set_metadata_ignore_application(of app block #1)... ");
|
|
|
|
|
if(!decoder->set_metadata_ignore_application(application1_.data.application.id)) {
|
|
|
|
|
printf("FAILED, returned false\n");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
|
|
|
|
|
if(!decoder->test_respond())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
/* done, now leave the sequence the way we found it... */
|
|
|
|
|
num_expected_ = 0;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &streaminfo_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &padding_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &seektable_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application1_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &application2_;
|
|
|
|
|
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
|
2003-01-10 05:40:09 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
|
2003-01-10 08:15:35 +00:00
|
|
|
expected_metadata_sequence_[num_expected_++] = &unknown_;
|
2002-06-07 05:27:37 +00:00
|
|
|
|
|
|
|
|
printf("freeing decoder instance... ");
|
|
|
|
|
delete decoder;
|
|
|
|
|
printf("OK\n");
|
|
|
|
|
|
|
|
|
|
printf("\nPASSED!\n");
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool test_decoders()
|
|
|
|
|
{
|
|
|
|
|
init_metadata_blocks_();
|
2003-01-10 05:40:09 +00:00
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
if(!generate_file_())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(!test_stream_decoder())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(!test_seekable_stream_decoder())
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if(!test_file_decoder())
|
|
|
|
|
return false;
|
|
|
|
|
|
2002-11-07 05:07:30 +00:00
|
|
|
(void) grabbag__file_remove_file(flacfilename_);
|
2003-01-10 05:40:09 +00:00
|
|
|
|
2002-06-07 05:27:37 +00:00
|
|
|
free_metadata_blocks_();
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|