mirror of
https://github.com/claunia/flac.git
synced 2025-12-16 18:54:26 +00:00
add FLAC__metadata_get_cuesheet() and FLAC__metadata_object_cuesheet_calculate_cddb_id()
This commit is contained in:
@@ -471,10 +471,11 @@ void OurFileDecoder::error_callback(::FLAC__StreamDecoderErrorStatus status)
|
||||
printf("ERROR: got error callback, status = %s (%u)\n", FLAC__StreamDecoderErrorStatusString[status], (unsigned)status);
|
||||
}
|
||||
|
||||
static bool generate_file_()
|
||||
static bool generate_file_(FLAC__bool include_cuesheet)
|
||||
{
|
||||
::FLAC__StreamMetadata streaminfo, vorbiscomment, padding;
|
||||
::FLAC__StreamMetadata *metadata[1];
|
||||
::FLAC__StreamMetadata streaminfo, vorbiscomment, *cuesheet, padding;
|
||||
::FLAC__StreamMetadata *metadata[3];
|
||||
unsigned i = 0, n = 0;
|
||||
|
||||
printf("generating FLAC file for test\n");
|
||||
|
||||
@@ -497,7 +498,7 @@ static bool generate_file_()
|
||||
{
|
||||
const unsigned vendor_string_length = (unsigned)strlen(FLAC__VENDOR_STRING);
|
||||
vorbiscomment.is_last = false;
|
||||
vorbiscomment.type = FLAC__METADATA_TYPE_VORBIS_COMMENT;
|
||||
vorbiscomment.type = ::FLAC__METADATA_TYPE_VORBIS_COMMENT;
|
||||
vorbiscomment.length = (4 + vendor_string_length) + 4;
|
||||
vorbiscomment.data.vorbis_comment.vendor_string.length = vendor_string_length;
|
||||
vorbiscomment.data.vorbis_comment.vendor_string.entry = (FLAC__byte*)malloc_or_die_(vendor_string_length+1);
|
||||
@@ -506,23 +507,42 @@ static bool generate_file_()
|
||||
vorbiscomment.data.vorbis_comment.comments = 0;
|
||||
}
|
||||
|
||||
{
|
||||
if (0 == (cuesheet = ::FLAC__metadata_object_new(::FLAC__METADATA_TYPE_CUESHEET)))
|
||||
return die_("priming our metadata");
|
||||
cuesheet->is_last = false;
|
||||
strcpy(cuesheet->data.cue_sheet.media_catalog_number, "bogo-MCN");
|
||||
cuesheet->data.cue_sheet.lead_in = 123;
|
||||
cuesheet->data.cue_sheet.is_cd = false;
|
||||
if (!FLAC__metadata_object_cuesheet_insert_blank_track(cuesheet, 0))
|
||||
return die_("priming our metadata");
|
||||
cuesheet->data.cue_sheet.tracks[0].number = 1;
|
||||
if (!FLAC__metadata_object_cuesheet_track_insert_blank_index(cuesheet, 0, 0))
|
||||
return die_("priming our metadata");
|
||||
}
|
||||
|
||||
padding.is_last = true;
|
||||
padding.type = ::FLAC__METADATA_TYPE_PADDING;
|
||||
padding.length = 1234;
|
||||
|
||||
metadata[0] = &padding;
|
||||
metadata[n++] = &vorbiscomment;
|
||||
if (include_cuesheet)
|
||||
metadata[n++] = cuesheet;
|
||||
metadata[n++] = &padding;
|
||||
|
||||
FLAC::Metadata::StreamInfo s(&streaminfo);
|
||||
FLAC::Metadata::VorbisComment v(&vorbiscomment);
|
||||
FLAC::Metadata::CueSheet c(cuesheet, /*copy=*/false);
|
||||
FLAC::Metadata::Padding p(&padding);
|
||||
if(
|
||||
!insert_to_our_metadata_(&s, 0, /*copy=*/true) ||
|
||||
!insert_to_our_metadata_(&v, 1, /*copy=*/true) ||
|
||||
!insert_to_our_metadata_(&p, 2, /*copy=*/true)
|
||||
!insert_to_our_metadata_(&s, i++, /*copy=*/true) ||
|
||||
!insert_to_our_metadata_(&v, i++, /*copy=*/true) ||
|
||||
(include_cuesheet && !insert_to_our_metadata_(&v, i++, /*copy=*/true)) ||
|
||||
!insert_to_our_metadata_(&p, i++, /*copy=*/true)
|
||||
)
|
||||
return die_("priming our metadata");
|
||||
|
||||
if(!file_utils__generate_flacfile(flacfile_, 0, 512 * 1024, &streaminfo, metadata, 1))
|
||||
if(!file_utils__generate_flacfile(flacfile_, 0, 512 * 1024, &streaminfo, metadata, n))
|
||||
return die_("creating the encoded file");
|
||||
|
||||
free(vorbiscomment.data.vorbis_comment.vendor_string.entry);
|
||||
@@ -594,7 +614,7 @@ static bool test_level_0_()
|
||||
|
||||
printf("\n\n++++++ testing level 0 interface\n");
|
||||
|
||||
if(!generate_file_())
|
||||
if(!generate_file_(/*include_cuesheet=*/true))
|
||||
return false;
|
||||
|
||||
if(!test_file_(flacfile_, /*ignore_metadata=*/true))
|
||||
@@ -651,6 +671,38 @@ static bool test_level_0_()
|
||||
printf("OK\n");
|
||||
}
|
||||
|
||||
{
|
||||
printf("testing FLAC::Metadata::get_cuesheet(CueSheet *&)... ");
|
||||
|
||||
FLAC::Metadata::CueSheet *cuesheet = 0;
|
||||
|
||||
if(!FLAC::Metadata::get_cuesheet(flacfile_, cuesheet))
|
||||
return die_("during FLAC::Metadata::get_cuesheet()");
|
||||
|
||||
/* check to see if some basic data matches (c.f. generate_file_()) */
|
||||
if(cuesheet->get_lead_in() != 123)
|
||||
return die_("mismatch in cuesheet->get_lead_in()");
|
||||
|
||||
printf("OK\n");
|
||||
|
||||
delete cuesheet;
|
||||
}
|
||||
|
||||
{
|
||||
printf("testing FLAC::Metadata::get_cuesheet(CueSheet &)... ");
|
||||
|
||||
FLAC::Metadata::CueSheet cuesheet;
|
||||
|
||||
if(!FLAC::Metadata::get_cuesheet(flacfile_, cuesheet))
|
||||
return die_("during FLAC::Metadata::get_cuesheet()");
|
||||
|
||||
/* check to see if some basic data matches (c.f. generate_file_()) */
|
||||
if(cuesheet.get_lead_in() != 123)
|
||||
return die_("mismatch in cuesheet.get_lead_in()");
|
||||
|
||||
printf("OK\n");
|
||||
}
|
||||
|
||||
if(!remove_file_(flacfile_))
|
||||
return false;
|
||||
|
||||
@@ -675,7 +727,7 @@ static bool test_level_1_()
|
||||
{
|
||||
printf("simple iterator on read-only file\n");
|
||||
|
||||
if(!generate_file_())
|
||||
if(!generate_file_(/*include_cuesheet=*/false))
|
||||
return false;
|
||||
|
||||
if(!change_stats_(flacfile_, /*read_only=*/true))
|
||||
@@ -1340,7 +1392,7 @@ static bool test_level_2_(bool filename_based)
|
||||
|
||||
printf("generate read-only file\n");
|
||||
|
||||
if(!generate_file_())
|
||||
if(!generate_file_(/*include_cuesheet=*/false))
|
||||
return false;
|
||||
|
||||
if(!change_stats_(flacfile_, /*read_only=*/true))
|
||||
@@ -1895,7 +1947,7 @@ static bool test_level_2_misc_()
|
||||
|
||||
printf("generate file\n");
|
||||
|
||||
if(!generate_file_())
|
||||
if(!generate_file_(/*include_cuesheet=*/false))
|
||||
return false;
|
||||
|
||||
printf("create chain\n");
|
||||
|
||||
Reference in New Issue
Block a user