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

augment unit tests to test for correctness with unknown metadata blocks

parent 7eca3ff9
......@@ -30,8 +30,8 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_;
static ::FLAC__StreamMetadata *expected_metadata_sequence_[7];
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
static ::FLAC__StreamMetadata *expected_metadata_sequence_[8];
static unsigned num_expected_;
static const char *flacfilename_ = "metadata.flac";
static unsigned flacfilesize_;
......@@ -44,12 +44,12 @@ static bool die_(const char *msg)
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static bool generate_file_()
......@@ -63,6 +63,7 @@ static bool generate_file_()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_utils__generate_flacfile(flacfilename_, &flacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_))
return die_("creating the encoded file");
......@@ -444,6 +445,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -489,6 +491,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -517,6 +520,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -546,6 +550,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -581,6 +586,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -722,6 +728,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -766,6 +773,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
::fclose(decoder->file_);
......@@ -1159,6 +1167,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1204,6 +1213,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1232,6 +1242,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1261,6 +1272,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1296,6 +1308,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1437,6 +1450,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1481,6 +1495,7 @@ static bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
::fclose(decoder->file_);
......@@ -1784,6 +1799,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1829,6 +1845,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1857,6 +1874,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1886,6 +1904,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -1921,6 +1940,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -2062,6 +2082,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!decoder->test_respond())
return false;
......@@ -2106,6 +2127,7 @@ static bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
printf("freeing decoder instance... ");
delete decoder;
......
......@@ -27,19 +27,19 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_;
static ::FLAC__StreamMetadata *metadata_sequence_[] = { &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_ };
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
static ::FLAC__StreamMetadata *metadata_sequence_[] = { &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_ };
static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]);
static const char *flacfilename_ = "metadata.flac";
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
class StreamEncoder : public FLAC::Encoder::Stream {
......
......@@ -368,7 +368,8 @@ void mutils__init_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
)
{
/*
......@@ -439,7 +440,7 @@ void mutils__init_metadata_blocks(
vorbiscomment->data.vorbis_comment.comments[1].entry = 0;
}
cuesheet->is_last = true;
cuesheet->is_last = false;
cuesheet->type = FLAC__METADATA_TYPE_CUESHEET;
cuesheet->length =
/* cuesheet guts */
......@@ -497,6 +498,12 @@ void mutils__init_metadata_blocks(
cuesheet->data.cue_sheet.tracks[2].offset = 12345 * 588;
cuesheet->data.cue_sheet.tracks[2].number = 170;
cuesheet->data.cue_sheet.tracks[2].num_indices = 0;
unknown->is_last = true;
unknown->type = 127;
unknown->length = 8;
unknown->data.unknown.data = (FLAC__byte*)malloc_or_die_(8);
memcpy(unknown->data.unknown.data, "\xfe\xdc\xba\x98\xf0\xe1\xd2\xc3", 8);
}
void mutils__free_metadata_blocks(
......@@ -506,7 +513,8 @@ void mutils__free_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
)
{
(void)streaminfo, (void)padding, (void)application2;
......@@ -518,4 +526,5 @@ void mutils__free_metadata_blocks(
free(cuesheet->data.cue_sheet.tracks[0].indices);
free(cuesheet->data.cue_sheet.tracks[1].indices);
free(cuesheet->data.cue_sheet.tracks);
free(unknown->data.unknown.data);
}
......@@ -51,7 +51,8 @@ void mutils__init_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
);
void mutils__free_metadata_blocks(
......@@ -61,7 +62,8 @@ void mutils__free_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
);
#endif
......@@ -39,8 +39,8 @@ typedef struct {
typedef stream_decoder_client_data_struct seekable_stream_decoder_client_data_struct;
typedef stream_decoder_client_data_struct file_decoder_client_data_struct;
static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_;
static FLAC__StreamMetadata *expected_metadata_sequence_[7];
static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
static FLAC__StreamMetadata *expected_metadata_sequence_[8];
static unsigned num_expected_;
static const char *flacfilename_ = "metadata.flac";
static unsigned flacfilesize_;
......@@ -107,12 +107,12 @@ static FLAC__bool die_f_(const char *msg, const FLAC__FileDecoder *decoder)
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static FLAC__bool generate_file_()
......@@ -126,6 +126,7 @@ static FLAC__bool generate_file_()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_utils__generate_flacfile(flacfilename_, &flacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_))
return die_("creating the encoded file");
......@@ -486,6 +487,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -525,6 +527,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -549,6 +552,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -574,6 +578,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -603,6 +608,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -720,6 +726,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -758,6 +765,7 @@ static FLAC__bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
printf("testing FLAC__stream_decoder_delete()... ");
FLAC__stream_decoder_delete(decoder);
......@@ -1188,6 +1196,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1227,6 +1236,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1251,6 +1261,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1276,6 +1287,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1305,6 +1317,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1422,6 +1435,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!seekable_stream_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1460,6 +1474,7 @@ static FLAC__bool test_seekable_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
printf("testing FLAC__seekable_stream_decoder_delete()... ");
FLAC__seekable_stream_decoder_delete(decoder);
......@@ -1721,6 +1736,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1760,6 +1776,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1784,6 +1801,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1809,6 +1827,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1838,6 +1857,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &seektable_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1955,6 +1975,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application1_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_decoder_test_respond_(decoder, &decoder_client_data))
return false;
......@@ -1993,6 +2014,7 @@ static FLAC__bool test_file_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
printf("testing FLAC__file_decoder_delete()... ");
FLAC__file_decoder_delete(decoder);
......
......@@ -28,8 +28,8 @@
#include <stdlib.h>
#include <string.h>
static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_;
static FLAC__StreamMetadata *metadata_sequence_[] = { &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_ };
static FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
static FLAC__StreamMetadata *metadata_sequence_[] = { &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_ };
static const unsigned num_metadata_ = sizeof(metadata_sequence_) / sizeof(metadata_sequence_[0]);
static const char *flacfilename_ = "metadata.flac";
......@@ -101,12 +101,12 @@ static FLAC__bool die_f_(const char *msg, const FLAC__FileEncoder *encoder)
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static FLAC__StreamEncoderWriteStatus stream_encoder_write_callback_(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
......
......@@ -368,7 +368,8 @@ void mutils__init_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
)
{
/*
......@@ -439,7 +440,7 @@ void mutils__init_metadata_blocks(
vorbiscomment->data.vorbis_comment.comments[1].entry = 0;
}
cuesheet->is_last = true;
cuesheet->is_last = false;
cuesheet->type = FLAC__METADATA_TYPE_CUESHEET;
cuesheet->length =
/* cuesheet guts */
......@@ -497,6 +498,12 @@ void mutils__init_metadata_blocks(
cuesheet->data.cue_sheet.tracks[2].offset = 12345 * 588;
cuesheet->data.cue_sheet.tracks[2].number = 170;
cuesheet->data.cue_sheet.tracks[2].num_indices = 0;
unknown->is_last = true;
unknown->type = 127;
unknown->length = 8;
unknown->data.unknown.data = (FLAC__byte*)malloc_or_die_(unknown->length);
memcpy(unknown->data.unknown.data, "\xfe\xdc\xba\x98\xf0\xe1\xd2\xc3", unknown->length);
}
void mutils__free_metadata_blocks(
......@@ -506,7 +513,8 @@ void mutils__free_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
)
{
(void)streaminfo, (void)padding, (void)application2;
......@@ -518,4 +526,5 @@ void mutils__free_metadata_blocks(
free(cuesheet->data.cue_sheet.tracks[0].indices);
free(cuesheet->data.cue_sheet.tracks[1].indices);
free(cuesheet->data.cue_sheet.tracks);
free(unknown->data.unknown.data);
}
......@@ -51,7 +51,8 @@ void mutils__init_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
);
void mutils__free_metadata_blocks(
......@@ -61,7 +62,8 @@ void mutils__free_metadata_blocks(
FLAC__StreamMetadata *application1,
FLAC__StreamMetadata *application2,
FLAC__StreamMetadata *vorbiscomment,
FLAC__StreamMetadata *cuesheet
FLAC__StreamMetadata *cuesheet,
FLAC__StreamMetadata *unknown
);
#endif
......@@ -30,8 +30,8 @@ extern "C" {
#include <stdlib.h>
#include <string.h>
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_;
static ::FLAC__StreamMetadata *expected_metadata_sequence_[7];
static ::FLAC__StreamMetadata streaminfo_, padding_, seektable_, application1_, application2_, vorbiscomment_, cuesheet_, unknown_;
static ::FLAC__StreamMetadata *expected_metadata_sequence_[8];
static unsigned num_expected_;
static const char *oggflacfilename_ = "metadata.ogg";
static unsigned oggflacfilesize_;
......@@ -44,12 +44,12 @@ static bool die_(const char *msg)
static void init_metadata_blocks_()
{
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__init_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static void free_metadata_blocks_()
{
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_);
mutils__free_metadata_blocks(&streaminfo_, &padding_, &seektable_, &application1_, &application2_, &vorbiscomment_, &cuesheet_, &unknown_);
}
static bool generate_file_()
......@@ -63,6 +63,7 @@ static bool generate_file_()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;
expected_metadata_sequence_[num_expected_++] = &cuesheet_;
expected_metadata_sequence_[num_expected_++] = &unknown_;
if(!file_utils__generate_oggflacfile(oggflacfilename_, &oggflacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_))
return die_("creating the encoded file");
......@@ -453,6 +454,7 @@ static bool test_stream_decoder()
expected_metadata_sequence_[num_expected_++] = &application2_;
expected_metadata_sequence_[num_expected_++] = &vorbiscomment_;