diff options
author | Taybin Rutkin <taybin@taybin.com> | 2006-07-31 22:05:28 +0000 |
---|---|---|
committer | Taybin Rutkin <taybin@taybin.com> | 2006-07-31 22:05:28 +0000 |
commit | 2e2e20563ce4bec22a8f5ca158bcc077d3f3e1b2 (patch) | |
tree | decbc8fdf69c9c490cb84debe5406b099cc89658 /libs/ardour/plugin_manager.cc | |
parent | 4be1ccc43fbc70317f1373370518f2dc0515c516 (diff) |
Start of AudioUnit work. COREAUDIO=y is a little destable for now.
git-svn-id: svn://localhost/ardour2/trunk@724 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/plugin_manager.cc')
-rw-r--r-- | libs/ardour/plugin_manager.cc | 122 |
1 files changed, 116 insertions, 6 deletions
diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index c8787a7d34..4be9b19468 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -27,7 +27,7 @@ #include <fst.h> #include <pbd/basename.h> #include <string.h> -#endif +#endif // VST_SUPPORT #include <pbd/pathscanner.h> @@ -41,6 +41,11 @@ #include <pbd/error.h> #include <pbd/stl_delete.h> +#ifdef HAVE_COREAUDIO +#include <CoreServices/CoreServices.h> +#include <AudioUnit/AudioUnit.h> +#endif // HAVE_COREAUDIO + #include "i18n.h" using namespace ARDOUR; @@ -95,7 +100,11 @@ PluginManager::refresh () if (Config->get_use_vst()) { vst_refresh (); } -#endif +#endif // VST_SUPPORT + +#ifdef HAVE_COREAUDIO + au_discover (); +#endif // HAVE_COREAUDIO } void @@ -302,10 +311,10 @@ PluginManager::load (Session& session, PluginInfo *info) } else { error << _("You asked ardour to not use any VST plugins") << endmsg; } -#else +#else // !VST_SUPPORT error << _("This version of ardour has no support for VST plugins") << endmsg; return boost::shared_ptr<Plugin> ((Plugin*) 0); -#endif +#endif // !VST_SUPPORT } else { @@ -342,12 +351,15 @@ ARDOUR::find_plugin(Session& session, string name, long unique_id, PluginInfo::T unique_id = 0; // VST plugins don't have a unique id. break; case PluginInfo::AudioUnit: + plugs = &mgr->au_plugin_info(); + unique_id = 0; + break; default: return boost::shared_ptr<Plugin> ((Plugin *) 0); } for (i = plugs->begin(); i != plugs->end(); ++i) { - if ((name == "" || (*i)->name == name) && + if ((name == "" || (*i)->name == name) && (unique_id == 0 || (*i)->unique_id == unique_id)) { return mgr->load (session, *i); } @@ -489,4 +501,102 @@ PluginManager::vst_discover (string path) return 0; } -#endif +#endif // VST_SUPPORT + +#ifdef HAVE_COREAUDIO + +int +PluginManager::au_discover () +{ + int mNumUnits = 0; + int numTypes = 2; // this magic number was retrieved from the apple AUHost example. + + ComponentDescription desc; + desc.componentFlags = 0; + desc.componentFlagsMask = 0; + desc.componentSubType = 0; + desc.componentManufacturer = 0; + + for (int i = 0; i < numTypes; ++i) { + if (i == 1) { + desc.componentType = kAudioUnitType_MusicEffect; + } else { + desc.componentType = kAudioUnitType_Effect; + } + + int n = CountComponents (&desc); + + mNumUnits += n; + } + cout << "Number of AU plugins: " << mNumUnits << endl; + + ComponentDescription* mCompDescs = new ComponentDescription[mNumUnits]; + + int n = 0; + for (int i = 0; i < numTypes; ++i) + { + if (i == 1) { + desc.componentType = kAudioUnitType_MusicEffect; + } else { + desc.componentType = kAudioUnitType_Effect; + } + + Component comp = 0; + + comp = FindNextComponent (NULL, &desc); + while (comp != NULL) { + ComponentDescription temp; + GetComponentInfo (comp, &temp, NULL, NULL, NULL); + mCompDescs[n++] = temp; + comp = FindNextComponent (comp, &desc); + } + } + + for (int i = 0; i < mNumUnits; ++i) { + + // the following large block is just for determining the name of the plugin. + CFStringRef itemName = NULL; + // Marc Poirier -style item name + Component auComponent = FindNextComponent (0, &(mCompDescs[i])); + if (auComponent != NULL) { + ComponentDescription dummydesc; + Handle nameHandle = NewHandle(sizeof(void*)); + if (nameHandle != NULL) { + OSErr err = GetComponentInfo(auComponent, &dummydesc, nameHandle, NULL, NULL); + if (err == noErr) { + ConstStr255Param nameString = (ConstStr255Param) (*nameHandle); + if (nameString != NULL) { + itemName = CFStringCreateWithPascalString(kCFAllocatorDefault, nameString, CFStringGetSystemEncoding()); + } + } + DisposeHandle(nameHandle); + } + } + + // if Marc-style fails, do the original way + if (itemName == NULL) { + CFStringRef compTypeString = UTCreateStringForOSType(mCompDescs[i].componentType); + CFStringRef compSubTypeString = UTCreateStringForOSType(mCompDescs[i].componentSubType); + CFStringRef compManufacturerString = UTCreateStringForOSType(mCompDescs[i].componentManufacturer); + + itemName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ - %@ - %@"), + compTypeString, compManufacturerString, compSubTypeString); + + if (compTypeString != NULL) + CFRelease(compTypeString); + if (compSubTypeString != NULL) + CFRelease(compSubTypeString); + if (compManufacturerString != NULL) + CFRelease(compManufacturerString); + } + string realname = CFStringRefToStdString(itemName); + cout << realname << endl; + } + + delete[] mCompDescs; + + return 0; +} + +#endif // HAVE_COREAUDIO + |