From a8c9f748c7cb701ad3f8cea4cdcffd7db5574c6f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Mon, 14 Feb 2022 19:54:08 -0800 Subject: [PATCH] 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 --- Plugins/Flac/FlacDecoder.h | 1 + Plugins/Flac/FlacDecoder.m | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Plugins/Flac/FlacDecoder.h b/Plugins/Flac/FlacDecoder.h index be1f2ca26..09038fa17 100644 --- a/Plugins/Flac/FlacDecoder.h +++ b/Plugins/Flac/FlacDecoder.h @@ -51,6 +51,7 @@ NSData *albumArt; + BOOL cuesheetFound; NSString *cuesheet; } diff --git a/Plugins/Flac/FlacDecoder.m b/Plugins/Flac/FlacDecoder.m index 755c32928..2a5386c7e 100644 --- a/Plugins/Flac/FlacDecoder.m +++ b/Plugins/Flac/FlacDecoder.m @@ -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();