2 Copyright (C) 2006 Paul Davis
3 Written by Taybin Rutkin
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <ardour/audio_unit.h>
22 #include <ardour/utils.h>
24 #include <CoreServices/CoreServices.h>
25 #include <AudioUnit/AudioUnit.h>
27 using namespace ARDOUR;
30 AUPluginInfo::load (Session& session)
33 return PluginPtr((AUPlugin*)0);
38 AUPluginInfo::discover ()
42 int numTypes = 2; // this magic number was retrieved from the apple AUHost example.
44 ComponentDescription desc;
45 desc.componentFlags = 0;
46 desc.componentFlagsMask = 0;
47 desc.componentSubType = 0;
48 desc.componentManufacturer = 0;
50 for (int i = 0; i < numTypes; ++i) {
52 desc.componentType = kAudioUnitType_MusicEffect;
54 desc.componentType = kAudioUnitType_Effect;
59 comp = FindNextComponent (NULL, &desc);
60 while (comp != NULL) {
61 ComponentDescription temp;
62 GetComponentInfo (comp, &temp, NULL, NULL, NULL);
64 AUPluginInfoPtr plug(new AUPluginInfo);
65 plug->name = AUPluginInfo::get_name (temp);
66 plug->type = PluginInfo::AudioUnit;
69 plug->category = "AudioUnit";
70 plug->desc = CompDescPtr(new ComponentDescription(temp));
72 plugs.push_back(plug);
74 comp = FindNextComponent (comp, &desc);
82 AUPluginInfo::get_name (ComponentDescription& comp_desc)
84 CFStringRef itemName = NULL;
85 // Marc Poirier -style item name
86 Component auComponent = FindNextComponent (0, &comp_desc);
87 if (auComponent != NULL) {
88 ComponentDescription dummydesc;
89 Handle nameHandle = NewHandle(sizeof(void*));
90 if (nameHandle != NULL) {
91 OSErr err = GetComponentInfo(auComponent, &dummydesc, nameHandle, NULL, NULL);
93 ConstStr255Param nameString = (ConstStr255Param) (*nameHandle);
94 if (nameString != NULL) {
95 itemName = CFStringCreateWithPascalString(kCFAllocatorDefault, nameString, CFStringGetSystemEncoding());
98 DisposeHandle(nameHandle);
102 // if Marc-style fails, do the original way
103 if (itemName == NULL) {
104 CFStringRef compTypeString = UTCreateStringForOSType(comp_desc.componentType);
105 CFStringRef compSubTypeString = UTCreateStringForOSType(comp_desc.componentSubType);
106 CFStringRef compManufacturerString = UTCreateStringForOSType(comp_desc.componentManufacturer);
108 itemName = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%@ - %@ - %@"),
109 compTypeString, compManufacturerString, compSubTypeString);
111 if (compTypeString != NULL)
112 CFRelease(compTypeString);
113 if (compSubTypeString != NULL)
114 CFRelease(compSubTypeString);
115 if (compManufacturerString != NULL)
116 CFRelease(compManufacturerString);
119 return CFStringRefToStdString(itemName);