diff --git a/source/backend/plugin/CarlaPluginAU.cpp b/source/backend/plugin/CarlaPluginAU.cpp index 675b8ae5c..8660883bc 100644 --- a/source/backend/plugin/CarlaPluginAU.cpp +++ b/source/backend/plugin/CarlaPluginAU.cpp @@ -260,11 +260,8 @@ public: kAudioUnitProperty_SupportedNumChannels, kAudioUnitScope_Global, 0, &outDataSize, &outWritable) == noErr - /* && outDataSize != 0 - && outDataSize % sizeof(AUChannelInfo) == 0 - */ - ) + && outDataSize % sizeof(AUChannelInfo) == 0) { const uint32_t numChannels = outDataSize / sizeof(AUChannelInfo); AUChannelInfo* const channelInfo = new AUChannelInfo[numChannels]; @@ -279,12 +276,17 @@ public: { AUChannelInfo* highestInfo = &channelInfo[0]; - carla_stdout("getProperty returns {%u,%u}... config", + carla_stdout("kAudioUnitProperty_SupportedNumChannels returns {%d,%d}... config", channelInfo[0].inChannels, channelInfo[0].outChannels); - for (uint32_t i=1; i highestInfo->inChannels && channelInfo[i].outChannels > highestInfo->outChannels) { @@ -292,20 +294,69 @@ public: } } - audioIns = highestInfo->inChannels; - audioOuts = highestInfo->outChannels; + audioIns = std::min(64, highestInfo->inChannels); + audioOuts = std::min(64, highestInfo->outChannels); } else { - carla_stdout("getProperty failed"); + carla_stdout("kAudioUnitProperty_SupportedNumChannels failed"); } delete[] channelInfo; } else { - carla_stdout("kAudioUnitProperty_SupportedNumChannels returns no configs, assume stereo"); - audioIns = audioOuts = 2; + outDataSize = 0; + if (fFunctions.getPropertyInfo(fInterface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Input, + 0, &outDataSize, &outWritable) == noErr + && outDataSize == sizeof(UInt32)) + { + UInt32 count = 0; + if (fFunctions.getProperty(fInterface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Input, + 0, &count, &outDataSize) == noErr + && outDataSize == sizeof(UInt32) && count != 0) + { + AudioStreamBasicDescription desc; + std::memset(&desc, 0, sizeof(desc)); + outDataSize = sizeof(AudioStreamBasicDescription); + + if (fFunctions.getProperty(fInterface, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, &desc, &outDataSize) == noErr) + audioIns = std::min(64, desc.mChannelsPerFrame); + } + } + + outDataSize = 0; + if (fFunctions.getPropertyInfo(fInterface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Output, + 0, &outDataSize, &outWritable) == noErr + && outDataSize == sizeof(UInt32)) + { + UInt32 count = 0; + if (fFunctions.getProperty(fInterface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Output, + 0, &count, &outDataSize) == noErr + && outDataSize == sizeof(UInt32) && count != 0) + { + AudioStreamBasicDescription desc; + std::memset(&desc, 0, sizeof(desc)); + outDataSize = sizeof(AudioStreamBasicDescription); + + if (fFunctions.getProperty(fInterface, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 0, &desc, &outDataSize) == noErr) + audioOuts = std::min(64, desc.mChannelsPerFrame); + } + } } if (audioIns > 0) diff --git a/source/discovery/carla-discovery.cpp b/source/discovery/carla-discovery.cpp index 5ab21dd35..440064ccf 100644 --- a/source/discovery/carla-discovery.cpp +++ b/source/discovery/carla-discovery.cpp @@ -2182,8 +2182,13 @@ static bool do_au_check(const char* const filename, const bool doInit) { AUChannelInfo* highestInfo = &channelInfo[0]; - for (uint32_t i=1; i highestInfo->inChannels && channelInfo[i].outChannels > highestInfo->outChannels) { @@ -2191,12 +2196,70 @@ static bool do_au_check(const char* const filename, const bool doInit) } } - audioIns = highestInfo->inChannels; - audioOuts = highestInfo->outChannels; + audioIns = std::min(64, highestInfo->inChannels); + audioOuts = std::min(64, highestInfo->outChannels); } delete[] channelInfo; } + else + { + // unsupported for now + interface->Close(interface); + continue; + + outDataSize = 0; + if (auGetPropertyInfo(interface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Input, + 0, &outDataSize, &outWritable) == noErr + && outDataSize == sizeof(UInt32)) + { + UInt32 count = 0; + if (auGetProperty(interface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Input, + 0, &count, &outDataSize) == noErr + && outDataSize == sizeof(UInt32) && count != 0) + { + AudioStreamBasicDescription desc; + std::memset(&desc, 0, sizeof(desc)); + outDataSize = sizeof(AudioStreamBasicDescription); + + if (auGetProperty(interface, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Input, + 0, &desc, &outDataSize) == noErr) + audioIns = std::min(64, desc.mChannelsPerFrame); + } + } + + outDataSize = 0; + if (auGetPropertyInfo(interface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Output, + 0, &outDataSize, &outWritable) == noErr + && outDataSize == sizeof(UInt32)) + { + UInt32 count = 0; + if (auGetProperty(interface, + kAudioUnitProperty_ElementCount, + kAudioUnitScope_Output, + 0, &count, &outDataSize) == noErr + && outDataSize == sizeof(UInt32) && count != 0) + { + AudioStreamBasicDescription desc; + std::memset(&desc, 0, sizeof(desc)); + outDataSize = sizeof(AudioStreamBasicDescription); + + if (auGetProperty(interface, + kAudioUnitProperty_StreamFormat, + kAudioUnitScope_Output, + 0, &desc, &outDataSize) == noErr) + audioOuts = std::min(64, desc.mChannelsPerFrame); + } + } + } // parameter count outDataSize = 0; @@ -2292,17 +2355,7 @@ static bool do_au_check(const char* const filename, const bool doInit) if (doInit) { - // test valid scopes - outDataSize = 0; - if (auGetPropertyInfo(interface, kAudioUnitProperty_ElementCount, kAudioUnitScope_Input, 0, &outDataSize, &outWritable) == noErr && outDataSize == sizeof(UInt32)) - { - UInt32 count = 0; - if (auGetProperty(interface, kAudioUnitProperty_ElementCount, kAudioUnitScope_Input, 0, &count, &outDataSize) == noErr && outDataSize == sizeof(UInt32) && count != 0) - { - } - } - - // TODO + // TODO tests } const CFIndex componentNameLen = CFStringGetLength(componentName); diff --git a/source/utils/CarlaStateUtils.cpp b/source/utils/CarlaStateUtils.cpp index 419991ae0..8a87da853 100644 --- a/source/utils/CarlaStateUtils.cpp +++ b/source/utils/CarlaStateUtils.cpp @@ -1,6 +1,6 @@ /* * Carla State utils - * Copyright (C) 2012-2023 Filipe Coelho + * Copyright (C) 2012-2024 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -310,7 +310,7 @@ bool CarlaStateSave::fillFromXmlElement(const XmlElement* const xmlElement) name = xmlSafeStringCharDup(text, false); else if (tag == "Label" || tag == "URI" || tag == "Identifier" || tag == "Setup") label = xmlSafeStringCharDup(text, false); - else if (tag == "Binary" || tag == "Filename") + else if (tag == "Binary" || tag == "Bundle" || tag == "Filename") binary = xmlSafeStringCharDup(text, false); else if (tag == "UniqueID") uniqueId = text.getLargeIntValue(); @@ -594,6 +594,7 @@ void CarlaStateSave::dumpToMemoryStream(MemoryOutputStream& content) const infoXml << " \n"; break; case PLUGIN_AU: + infoXml << " " << xmlSafeString(binary, true) << "\n"; infoXml << " " << xmlSafeString(label, true) << "\n"; break; case PLUGIN_CLAP: