Fix a crash with embedded cue sheet handling

Tag reading can read cue sheets as either a single NSString, or an
NSArray of NSStrings, so handle either case.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
main
Christopher Snowhill 2022-10-16 14:59:19 -07:00
parent cddf9fb9ba
commit e4bc5853ad
3 changed files with 81 additions and 12 deletions

View File

@ -50,11 +50,34 @@
NSDictionary *alsoMetadata = [NSClassFromString(@"AudioPropertiesReader") propertiesForURL:url skipCue:YES];
NSString *sheet = [fileMetadata objectForKey:@"cuesheet"];
if(!sheet || ![sheet length]) sheet = [alsoMetadata objectForKey:@"cuesheet"];
id sheet = [fileMetadata objectForKey:@"cuesheet"];
NSString *sheetString = nil;
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
if(!sheetString || ![sheetString length]) {
sheet = [alsoMetadata objectForKey:@"cuesheet"];
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
}
if([sheet length]) {
cuesheet = [CueSheet cueSheetWithString:sheet withFilename:[url path]];
if(sheetString && [sheetString length]) {
cuesheet = [CueSheet cueSheetWithString:sheetString withFilename:[url path]];
}
embedded = YES;
} else

View File

@ -92,11 +92,34 @@ static void *kCueSheetDecoderContext = &kCueSheetDecoderContext;
NSDictionary *alsoMetadata = [decoder metadata];
NSString *sheet = [fileMetadata objectForKey:@"cuesheet"];
if(!sheet || ![sheet length]) sheet = [alsoMetadata objectForKey:@"cuesheet"];
id sheet = [fileMetadata objectForKey:@"cuesheet"];
NSString *sheetString = nil;
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
if(!sheetString || ![sheetString length]) {
sheet = [alsoMetadata objectForKey:@"cuesheet"];
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
}
if([sheet length]) {
cuesheet = [CueSheet cueSheetWithString:sheet withFilename:[url path]];
if(sheetString && [sheetString length]) {
cuesheet = [CueSheet cueSheetWithString:sheetString withFilename:[url path]];
embedded = YES;
}

View File

@ -46,11 +46,34 @@
NSDictionary *alsoMetadata = [NSClassFromString(@"AudioPropertiesReader") propertiesForURL:url skipCue:YES];
NSString *sheet = [fileMetadata objectForKey:@"cuesheet"];
if(!sheet || ![sheet length]) sheet = [alsoMetadata objectForKey:@"cuesheet"];
id sheet = [fileMetadata objectForKey:@"cuesheet"];
NSString *sheetString = nil;
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
if(!sheetString || ![sheetString length]) {
sheet = [alsoMetadata objectForKey:@"cuesheet"];
if(sheet) {
if([sheet isKindOfClass:[NSArray class]]) {
NSArray *sheetContainer = sheet;
if([sheetContainer count]) {
sheetString = sheetContainer[0];
}
} else if([sheet isKindOfClass:[NSString class]]) {
sheetString = sheet;
}
}
}
if([sheet length]) {
cuesheet = [CueSheet cueSheetWithString:sheet withFilename:[url path]];
if(sheetString && [sheetString length]) {
cuesheet = [CueSheet cueSheetWithString:sheetString withFilename:[url path]];
embedded = YES;
}
} else