const CAAUParameter* param = param_info.GetParamInfo (d.id);
const AudioUnitParameterInfo& info (param->ParamInfo());
- const int len = CFStringGetLength (param->GetName());;
+ const int len = CFStringGetLength (param->GetName());
char local_buffer[len*2];
- Boolean good = CFStringGetCString(param->GetName(),local_buffer,len*2,kCFStringEncodingMacRoman);
+ Boolean good = CFStringGetCString (param->GetName(), local_buffer ,len*2 , kCFStringEncodingUTF8);
if (!good) {
d.label = "???";
} else {
if (initialized) {
//if we are already running with the requested i/o config, bail out here
if ( (audio_in==input_channels) && (audio_out==output_channels) ) {
- return 0;
+ return true;
} else {
deactivate ();
}
streamFormat.mChannelsPerFrame = audio_in;
if (set_input_format (streamFormat) != 0) {
- return -1;
+ return false;
}
streamFormat.mChannelsPerFrame = audio_out;
if (set_output_format (streamFormat) != 0) {
- return -1;
+ return false;
}
/* reset plugin info to show currently configured state */
activate ();
}
- return 0;
+ return true;
}
ChanCount
include "<manufacturer>/<plugin-name>" in their path.
*/
- Plugin* p = (Plugin *) arg;
- string match = p->maker();
+ AUPluginInfo* p = (AUPluginInfo *) arg;
+ string match = p->creator;
match += '/';
- match += p->name();
+ match += p->name;
ret = str.find (match) != string::npos;
if (ret == false) {
- string m = p->maker ();
- string n = p->name ();
+ string m = p->creator;
+ string n = p->name;
strip_whitespace_edges (m);
strip_whitespace_edges (n);
match = m;
user_preset_map.clear ();
- find_files_matching_filter (preset_files, preset_search_path, au_preset_filter, this, true, true, true);
+ PluginInfoPtr nfo = get_info();
+ find_files_matching_filter (preset_files, preset_search_path, au_preset_filter,
+ boost::dynamic_pointer_cast<AUPluginInfo> (nfo).get(),
+ true, true, true);
if (preset_files.empty()) {
DEBUG_TRACE (DEBUG::AudioUnits, "AU No Preset Files found for given plugin.\n");
for (FactoryPresetMap::iterator i = factory_preset_map.begin(); i != factory_preset_map.end(); ++i) {
/* XXX: dubious */
string const uri = string_compose ("%1", _presets.size ());
- _presets.insert (make_pair (uri, Plugin::PresetRecord (uri, i->first, i->second)));
+ _presets.insert (make_pair (uri, Plugin::PresetRecord (uri, i->first, false)));
DEBUG_TRACE (DEBUG::AudioUnits, string_compose("AU Adding Factory Preset: %1 > %2\n", i->first, i->second));
}
}
}
}
+std::vector<Plugin::PresetRecord>
+AUPluginInfo::get_presets (bool user_only) const
+{
+ std::vector<Plugin::PresetRecord> p;
+ boost::shared_ptr<CAComponent> comp;
+#ifndef NO_PLUGIN_STATE
+ try {
+ comp = boost::shared_ptr<CAComponent>(new CAComponent(*descriptor));
+ if (!comp->IsValid()) {
+ throw failed_constructor();
+ }
+ } catch (failed_constructor& err) {
+ return p;
+ }
+
+ // user presets
+
+ if (!preset_search_path_initialized) {
+ Glib::ustring p = Glib::get_home_dir();
+ p += "/Library/Audio/Presets:";
+ p += preset_search_path;
+ preset_search_path = p;
+ preset_search_path_initialized = true;
+ DEBUG_TRACE (DEBUG::AudioUnits, string_compose("AU Preset Path: %1\n", preset_search_path));
+ }
+
+ vector<string> preset_files;
+ find_files_matching_filter (preset_files, preset_search_path, au_preset_filter, const_cast<AUPluginInfo*>(this), true, true, true);
+
+ for (vector<string>::iterator x = preset_files.begin(); x != preset_files.end(); ++x) {
+ string path = *x;
+ string preset_name;
+ preset_name = Glib::path_get_basename (path);
+ preset_name = preset_name.substr (0, preset_name.find_last_of ('.'));
+ if (check_and_get_preset_name (comp.get()->Comp(), path, preset_name)) {
+ p.push_back (Plugin::PresetRecord (path, preset_name));
+ }
+ }
+
+ if (user_only) {
+ return p;
+ }
+
+ // factory presets
+
+ CFArrayRef presets;
+ UInt32 dataSize;
+ Boolean isWritable;
+
+ boost::shared_ptr<CAAudioUnit> unit (new CAAudioUnit);
+ if (noErr != CAAudioUnit::Open (*(comp.get()), *unit)) {
+ return p;
+ }
+ if (noErr != unit->GetPropertyInfo (kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, &dataSize, &isWritable)) {
+ unit->Uninitialize ();
+ return p;
+ }
+ if (noErr != unit->GetProperty (kAudioUnitProperty_FactoryPresets, kAudioUnitScope_Global, 0, (void*) &presets, &dataSize)) {
+ unit->Uninitialize ();
+ return p;
+ }
+ if (!presets) {
+ unit->Uninitialize ();
+ return p;
+ }
+
+ CFIndex cnt = CFArrayGetCount (presets);
+ for (CFIndex i = 0; i < cnt; ++i) {
+ AUPreset* preset = (AUPreset*) CFArrayGetValueAtIndex (presets, i);
+ string const uri = string_compose ("%1", i);
+ string name = CFStringRefToStdString (preset->presetName);
+ p.push_back (Plugin::PresetRecord (uri, name, false));
+ }
+ CFRelease (presets);
+ unit->Uninitialize ();
+
+#endif // NO_PLUGIN_STATE
+ return p;
+}
+
Glib::ustring
AUPluginInfo::au_cache_path ()
{
- return Glib::build_filename (ARDOUR::user_config_directory(), "au_cache");
+ return Glib::build_filename (ARDOUR::user_cache_directory(), "au_cache");
}
PluginInfoList*