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 <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-11 03:55:26 -08:00
parent e7df4e529d
commit be6fda4663
1 changed files with 5 additions and 1 deletions

View File

@ -75,7 +75,10 @@ static const char *extListStr[] = { ".str", NULL };
static void sidTuneLoader(const char *fileName, std::vector<uint8_t> &bufferRef) {
id<CogSource> 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<uint8_t> &bufferRef)
[source read:&bufferRef[0] amount:size];
[source close];
if(!usedHint)
[source close];
}
@implementation SidDecoder