diff options
-rw-r--r-- | libs/ardour/audio_unit.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index e155a2b081..42c18fd5f3 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -388,19 +388,15 @@ void AUPlugin::discover_factory_presets () { CFArrayRef presets; - UInt32 dataSize = 0; - OSStatus err = unit->GetPropertyInfo (kAudioUnitProperty_FactoryPresets, - kAudioUnitScope_Global, 0, - &dataSize, NULL); - if (err || !dataSize) { - /* no presets? */ + UInt32 dataSize = sizeof (presets); + OSStatus err; + + if ((err = unit->GetProperty (kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, (void*) &presets, &dataSize)) != 0) { + cerr << "cannot get factory preset info: " << err << endl; return; } - dataSize = sizeof (presets); - - if ((err = unit->GetProperty (kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, (void*) &presets, &dataSize)) != 0) { - cerr << "cannot get factory preset info: " << err << endl; + if (!presets) { return; } @@ -412,6 +408,8 @@ AUPlugin::discover_factory_presets () string name = CFStringRefToStdString (preset->presetName); factory_preset_map[name] = preset->presetNumber; } + + CFRelease (presets); } void |