From be6fda4663f9a4fb95fe7e75c01a087c9584bf55 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Fri, 11 Feb 2022 03:55:26 -0800 Subject: [PATCH] SID Input: Don't close hinted source files The SID decoder uses a hint cache so that when the library requests the current file open, it will return the exact file already opened, rather than opening it again. Unfortunately, I was closing the file regardless, and sometimes, libsidplayfp will reopen the file multiple times, from other threads, even. Signed-off-by: Christopher Snowhill --- Plugins/sidplay/SidDecoder.mm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Plugins/sidplay/SidDecoder.mm b/Plugins/sidplay/SidDecoder.mm index 084baba42..b6cf37d83 100644 --- a/Plugins/sidplay/SidDecoder.mm +++ b/Plugins/sidplay/SidDecoder.mm @@ -75,7 +75,10 @@ static const char *extListStr[] = { ".str", NULL }; static void sidTuneLoader(const char *fileName, std::vector &bufferRef) { id source; + BOOL usedHint = YES; if(![[sid_file_container instance] try_hint:[NSString stringWithUTF8String:fileName] source:&source]) { + usedHint = NO; + NSString *urlString = [NSString stringWithUTF8String:fileName]; NSURL *url = [NSURL URLWithDataRepresentation:[urlString dataUsingEncoding:NSUTF8StringEncoding] relativeToURL:nil]; @@ -97,7 +100,8 @@ static void sidTuneLoader(const char *fileName, std::vector &bufferRef) [source read:&bufferRef[0] amount:size]; - [source close]; + if(!usedHint) + [source close]; } @implementation SidDecoder