+
+static void
+#ifdef COREAUDIO105
+get_names (CAComponentDescription& comp_desc, std::string& name, std::string& maker)
+#else
+get_names (ArdourComponent& comp, std::string& name, std::string& maker)
+#endif
+{
+ CFStringRef itemName = NULL;
+ // Marc Poirier-style item name
+#ifdef COREAUDIO105
+ CAComponent auComponent (comp_desc);
+ if (auComponent.IsValid()) {
+ CAComponentDescription dummydesc;
+ Handle nameHandle = NewHandle(sizeof(void*));
+ if (nameHandle != NULL) {
+ OSErr err = GetComponentInfo(auComponent.Comp(), &dummydesc, nameHandle, NULL, NULL);
+ if (err == noErr) {
+ ConstStr255Param nameString = (ConstStr255Param) (*nameHandle);
+ if (nameString != NULL) {
+ itemName = CFStringCreateWithPascalString(kCFAllocatorDefault, nameString, CFStringGetSystemEncoding());
+ }
+ }
+ DisposeHandle(nameHandle);
+ }
+ }
+#else
+ assert (comp);
+ AudioComponentCopyName (comp, &itemName);
+#endif
+
+ // if Marc-style fails, do the original way
+ if (itemName == NULL) {
+#ifndef COREAUDIO105
+ CAComponentDescription comp_desc;
+ AudioComponentGetDescription (comp, &comp_desc);
+#endif
+ CFStringRef compTypeString = UTCreateStringForOSType(comp_desc.componentType);
+ CFStringRef compSubTypeString = UTCreateStringForOSType(comp_desc.componentSubType);
+ CFStringRef compManufacturerString = UTCreateStringForOSType(comp_desc.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 str = CFStringRefToStdString(itemName);
+ string::size_type colon = str.find (':');
+
+ if (colon) {
+ name = str.substr (colon+1);
+ maker = str.substr (0, colon);
+ strip_whitespace_edges (maker);
+ strip_whitespace_edges (name);
+ } else {
+ name = str;
+ maker = "unknown";
+ strip_whitespace_edges (name);
+ }
+}
+