FLAC Input: Correctly prioritize text CUESheet tag

Prioritize "cuesheet" Vorbis tag over binary CUESheet tag, as the former
can contain metadata, while the latter cannot.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-14 19:54:08 -08:00
parent 4a0690b3ab
commit a8c9f748c7
2 changed files with 6 additions and 1 deletions

View File

@ -51,6 +51,7 @@
NSData *albumArt;
BOOL cuesheetFound;
NSString *cuesheet;
}

View File

@ -196,7 +196,9 @@ void MetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMeta
flacDecoder->hasStreamInfo = YES;
}
if(metadata->type == FLAC__METADATA_TYPE_CUESHEET) {
if(metadata->type == FLAC__METADATA_TYPE_CUESHEET && !flacDecoder->cuesheetFound) {
flacDecoder->cuesheetFound = YES;
NSString *_cuesheet;
grabbag__cuesheet_emit(&_cuesheet, metadata, [[NSString stringWithFormat:@"\"%@\"", [[[flacDecoder->source url] path] lastPathComponent]] UTF8String]);
@ -256,6 +258,7 @@ void MetadataCallback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMeta
_genre = value;
} else if([name isEqualToString:@"cuesheet"]) {
_cuesheet = value;
flacDecoder->cuesheetFound = YES;
} else if([name isEqualToString:@"date"] ||
[name isEqualToString:@"year"]) {
_year = [NSNumber numberWithInt:[value intValue]];
@ -358,6 +361,7 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS
replayGainTrackGain = 0.0;
replayGainTrackPeak = 0.0;
albumArt = [NSData data];
cuesheetFound = NO;
cuesheet = @"";
decoder = FLAC__stream_decoder_new();