From 07a36873e39bfe8c949fef2b343a8ee43686d45c Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 28 Feb 2025 16:33:50 -0800 Subject: [PATCH] Bug Fix: Attempt to solve a next track crash This was attempting to retrieve the NSURL host object, possibly on a file URL where the two did not match a previous check. Now we only pass the full scheme/host/path check if both URLs are not file URLs. Signed-off-by: Christopher Snowhill --- Audio/AudioPlayer.m | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Audio/AudioPlayer.m b/Audio/AudioPlayer.m index 20a1e3fe4..69bc5341e 100644 --- a/Audio/AudioPlayer.m +++ b/Audio/AudioPlayer.m @@ -410,9 +410,30 @@ if([unixPathNext isEqualToString:unixPathPrev]) pathsEqual = YES; + } else if(![nextStream isFileURL] && ![[lastChain streamURL] isFileURL]) { + @try { + NSURL *lastURL = [lastChain streamURL]; + NSString *nextScheme = [nextStream scheme]; + NSString *lastScheme = [lastURL scheme]; + NSString *nextHost = [nextStream host]; + NSString *lastHost = [lastURL host]; + NSString *nextPath = [nextStream path]; + NSString *lastPath = [lastURL path]; + if(nextScheme && lastScheme && [nextScheme isEqualToString:lastScheme]) { + if((!nextHost && !lastHost) || + (nextHost && lastHost && [nextHost isEqualToString:lastHost])) { + if(nextPath && lastPath && [nextPath isEqualToString:lastPath]) { + pathsEqual = YES; + } + } + } + } + @catch(id anException) { + DLog(@"Exception thrown checking file match: %@", anException); + } } - if(pathsEqual || ([[nextStream scheme] isEqualToString:[[lastChain streamURL] scheme]] && (([nextStream host] == nil && [[lastChain streamURL] host] == nil) || [[nextStream host] isEqualToString:[[lastChain streamURL] host]]) && [[nextStream path] isEqualToString:[[lastChain streamURL] path]])) { + if(pathsEqual) { if([lastChain setTrack:nextStream] && [newChain openWithInput:[lastChain inputNode] withOutputFormat:[output format] withUserInfo:nextStreamUserInfo withRGInfo:nextStreamRGInfo]) { [newChain setStreamURL:nextStream];