Bundled resources: Use NSBundle interface

These methods should use NSBundle, rather than CF* C functions

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-01 14:40:02 -08:00
parent f3ddd69f63
commit 61a30c959c
3 changed files with 5 additions and 17 deletions

View File

@ -1244,10 +1244,7 @@ static float db_to_scale(float db)
}
if (!presetUrl) {
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("gsx"), CFSTR("wv"), NULL);
if (appUrlRef)
presetUrl = (__bridge NSURL *) appUrlRef;
CFRelease(appUrlRef);
presetUrl = [[NSBundle mainBundle] URLForResource:@"gsx" withExtension:@"wv"];
if (![HeadphoneFilter validateImpulseFile:presetUrl])
presetUrl = nil;
}

View File

@ -23,20 +23,15 @@ static CAdPlugDatabase * g_database = NULL;
+ (void)initialize
{
if (!g_database) {
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetBundleWithIdentifier(CFSTR("net.kode54.AdPlug")), CFSTR("adplug"), CFSTR("db"), NULL);
NSURL * dbUrl = [[NSBundle bundleWithIdentifier:@"net.kode54.AdPlug"] URLForResource:@"adplug" withExtension:@"db"];
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
NSString *dbPath = (__bridge NSString *) macPath;
NSString *dbPath = [dbUrl path];
if (dbPath) {
g_database = new CAdPlugDatabase;
g_database->load([dbPath UTF8String]);
CAdPlug::set_database( g_database );
CFRelease(macPath);
CFRelease(appUrlRef);
}
}
}

View File

@ -136,11 +136,9 @@ static void loadPresets()
{
if ([equalizer_presets_processed count]) return;
CFURLRef appUrlRef = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("Cog.q1"), CFSTR("json"), NULL);
NSURL * url = [[NSBundle mainBundle] URLForResource:@"Cog.q1" withExtension:@"json"];
CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, kCFURLPOSIXPathStyle);
NSFileHandle * fileHandle = [NSFileHandle fileHandleForReadingAtPath:(__bridge NSString *)macPath];
NSFileHandle * fileHandle = [NSFileHandle fileHandleForReadingAtPath:[url path]];
if (fileHandle) {
NSError *err;
NSData *data;
@ -235,8 +233,6 @@ static void loadPresets()
json_value_free(equalizer_presets);
equalizer_presets = NULL;
}
CFRelease(macPath);
CFRelease(appUrlRef);
}
void equalizerApplyGenre(AudioUnit au, NSString *genre) {