Signed-off-by: falkTX <falktx@falktx.com>pull/1933/merge
@@ -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<numChannels; ++i) | |||
for (uint32_t i=0; i<numChannels; ++i) | |||
{ | |||
if (channelInfo[i].inChannels < 0) | |||
channelInfo[i].inChannels = 2; | |||
if (channelInfo[i].outChannels < 0) | |||
channelInfo[i].outChannels = 2; | |||
if (channelInfo[i].inChannels > highestInfo->inChannels | |||
&& channelInfo[i].outChannels > highestInfo->outChannels) | |||
{ | |||
@@ -292,20 +294,69 @@ public: | |||
} | |||
} | |||
audioIns = highestInfo->inChannels; | |||
audioOuts = highestInfo->outChannels; | |||
audioIns = std::min<int16_t>(64, highestInfo->inChannels); | |||
audioOuts = std::min<int16_t>(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<uint32_t>(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<uint32_t>(64, desc.mChannelsPerFrame); | |||
} | |||
} | |||
} | |||
if (audioIns > 0) | |||
@@ -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<numChannels; ++i) | |||
for (uint32_t i=0; i<numChannels; ++i) | |||
{ | |||
if (channelInfo[i].inChannels < 0) | |||
channelInfo[i].inChannels = 2; | |||
if (channelInfo[i].outChannels < 0) | |||
channelInfo[i].outChannels = 2; | |||
if (channelInfo[i].inChannels > 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<int16_t>(64, highestInfo->inChannels); | |||
audioOuts = std::min<int16_t>(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<uint32_t>(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<uint32_t>(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); | |||
@@ -1,6 +1,6 @@ | |||
/* | |||
* Carla State utils | |||
* Copyright (C) 2012-2023 Filipe Coelho <falktx@falktx.com> | |||
* Copyright (C) 2012-2024 Filipe Coelho <falktx@falktx.com> | |||
* | |||
* 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 << " <Label>" << xmlSafeString(label, true) << "</Label>\n"; | |||
break; | |||
case PLUGIN_AU: | |||
infoXml << " <Bundle>" << xmlSafeString(binary, true) << "</Bundle>\n"; | |||
infoXml << " <Identifier>" << xmlSafeString(label, true) << "</Identifier>\n"; | |||
break; | |||
case PLUGIN_CLAP: | |||