augment unit tests to test for correctness with unknown metadata blocks
authorJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 10 Jan 2003 08:15:35 +0000 (08:15 +0000)
committerJosh Coalson <jcoalson@users.sourceforce.net>
Fri, 10 Jan 2003 08:15:35 +0000 (08:15 +0000)
16 files changed:
src/test_libFLAC++/decoders.cpp
src/test_libFLAC++/encoders.cpp
src/test_libFLAC++/metadata_utils.c
src/test_libFLAC++/metadata_utils.h
src/test_libFLAC/decoders.c
src/test_libFLAC/encoders.c
src/test_libFLAC/metadata_utils.c
src/test_libFLAC/metadata_utils.h
src/test_libOggFLAC++/decoders.cpp
src/test_libOggFLAC++/encoders.cpp
src/test_libOggFLAC++/metadata_utils.c
src/test_libOggFLAC++/metadata_utils.h
src/test_libOggFLAC/decoders.c
src/test_libOggFLAC/encoders.c
src/test_libOggFLAC/metadata_utils.c
src/test_libOggFLAC/metadata_utils.h

index 4ed0a759935b045e4e37670dff7183707390a315..881562b81afdee0f8453ee916749995c9d5d3ab5 100644 (file)
@@ -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;
index a66a233755fbd403e56065ee454ebdcb80801254..cc75f8d46e23bd3a414c5f05e95a1a6f389afe90 100644 (file)
@@ -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 {
index bb95f337e06a25915ab70ed0f0792f623b381657..427980d33c73e6e3635f0573ea5110a58dda1242 100644 (file)
@@ -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);
 }
index f5546d823c29188cd229d97f947e4db12f6dd432..a26730c8e269277609934756fdd1b9cc741c7382 100644 (file)
@@ -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
index e1b7dec6d762db673c2bc557752c4609b47e2443..2d5055742a0fe7425db7704f51f505d8df70bf43 100644 (file)
@@ -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);
index 3fabd5a51ed1453ae66c908817ab2d4c9fbd0c6e..24ea70b867cb4b9b2ab0cca77c10d069f93d9dea 100644 (file)
@@ -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)
index bb95f337e06a25915ab70ed0f0792f623b381657..d281788acb744d6d846b320578829a792e0f418b 100644 (file)
@@ -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);
 }
index f5546d823c29188cd229d97f947e4db12f6dd432..a26730c8e269277609934756fdd1b9cc741c7382 100644 (file)
@@ -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
index 4f7b7678612eb83ab1653815b693cca093b418b7..236a2446f84f63e3c88a70fc972eb42f58ad7d71 100644 (file)
@@ -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_;
        expected_metadata_sequence_[num_expected_++] = &cuesheet_;
+       expected_metadata_sequence_[num_expected_++] = &unknown_;
 
        if(!decoder->test_respond())
                return false;
@@ -498,6 +500,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;
@@ -526,6 +529,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;
@@ -555,6 +559,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;
@@ -590,6 +595,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;
@@ -731,6 +737,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;
@@ -775,6 +782,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_);
 
index 6f3019ffb26da0ec7a4fcfdd854c920371fbfe09..11792269af85a58647fdec67c06601f921045130 100644 (file)
@@ -27,18 +27,18 @@ 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 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 OggFLAC::Encoder::Stream {
index bb95f337e06a25915ab70ed0f0792f623b381657..427980d33c73e6e3635f0573ea5110a58dda1242 100644 (file)
@@ -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);
 }
index f5546d823c29188cd229d97f947e4db12f6dd432..a26730c8e269277609934756fdd1b9cc741c7382 100644 (file)
@@ -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
index 9bfa9e80cc4248921a2d4789c14de87e1495196a..1204f7f79ae36363d36e454ed83e699b7b5bd7ef 100644 (file)
@@ -34,8 +34,8 @@ typedef struct {
        FLAC__bool error_occurred;
 } stream_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 *oggflacfilename_ = "metadata.ogg";
 static unsigned oggflacfilesize_;
@@ -66,12 +66,12 @@ static FLAC__bool die_s_(const char *msg, const OggFLAC__StreamDecoder *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_()
@@ -85,6 +85,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_oggflacfile(oggflacfilename_, &oggflacfilesize_, 512 * 1024, &streaminfo_, expected_metadata_sequence_, num_expected_))
                return die_("creating the encoded file");
@@ -450,6 +451,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;
@@ -489,6 +491,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;
@@ -513,6 +516,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;
@@ -538,6 +542,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;
@@ -567,6 +572,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;
@@ -684,6 +690,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;
@@ -722,6 +729,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 OggFLAC__stream_decoder_delete()... ");
        OggFLAC__stream_decoder_delete(decoder);
index 798a71e1844cb4bacfb2a1f30854735b0ae2dfd8..864b5dddc0593d1ad5777421c26e75ee0879a307 100644 (file)
@@ -26,8 +26,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 *oggflacfilename_ = "metadata.ogg";
 
@@ -55,12 +55,12 @@ static FLAC__bool die_s_(const char *msg, const OggFLAC__StreamEncoder *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 OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data)
index bb95f337e06a25915ab70ed0f0792f623b381657..d281788acb744d6d846b320578829a792e0f418b 100644 (file)
@@ -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);
 }
index f5546d823c29188cd229d97f947e4db12f6dd432..a26730c8e269277609934756fdd1b9cc741c7382 100644 (file)
@@ -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