mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-22 01:34:21 +00:00
AU: Use slightly more readable channel type
This commit is contained in:
parent
3dcd2759e6
commit
a48a564f9e
2 changed files with 31 additions and 22 deletions
|
|
@ -2051,10 +2051,12 @@ private:
|
|||
addSupportedLayoutTags();
|
||||
|
||||
for (int i = 0; i < enabledInputs; ++i)
|
||||
if ((err = syncAudioUnitWithChannelSet (true, i, juceFilter->getChannelLayoutOfBus (true, i))) != noErr) return err;
|
||||
if ((err = syncAudioUnitWithChannelSet (true, i, juceFilter->getChannelLayoutOfBus (true, i))) != noErr)
|
||||
return err;
|
||||
|
||||
for (int i = 0; i < enabledOutputs; ++i)
|
||||
if ((err = syncAudioUnitWithChannelSet (false, i, juceFilter->getChannelLayoutOfBus (false, i))) != noErr) return err;
|
||||
if ((err = syncAudioUnitWithChannelSet (false, i, juceFilter->getChannelLayoutOfBus (false, i))) != noErr)
|
||||
return err;
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
|
@ -2177,7 +2179,7 @@ private:
|
|||
#endif
|
||||
|
||||
// add discrete layout tags
|
||||
int n = bus->getMaxSupportedChannels(maxChannelsToProbeFor());
|
||||
int n = bus->getMaxSupportedChannels (maxChannelsToProbeFor());
|
||||
|
||||
for (int ch = 0; ch < n; ++ch)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -353,11 +353,22 @@ struct AudioUnitHelpers
|
|||
auto defaultInputs = processor.getChannelCountOfBus (true, 0);
|
||||
auto defaultOutputs = processor.getChannelCountOfBus (false, 0);
|
||||
|
||||
SortedSet<int> supportedChannels;
|
||||
struct Channels
|
||||
{
|
||||
SInt16 ins, outs;
|
||||
|
||||
std::pair<SInt16, SInt16> makePair() const noexcept { return std::make_pair (ins, outs); }
|
||||
|
||||
bool operator< (const Channels& other) const noexcept { return makePair() < other.makePair(); }
|
||||
bool operator== (const Channels& other) const noexcept { return makePair() == other.makePair(); }
|
||||
};
|
||||
|
||||
SortedSet<Channels> supportedChannels;
|
||||
|
||||
// add the current configuration
|
||||
if (defaultInputs != 0 || defaultOutputs != 0)
|
||||
supportedChannels.add ((defaultInputs << 16) | defaultOutputs);
|
||||
supportedChannels.add ({ static_cast<SInt16> (defaultInputs),
|
||||
static_cast<SInt16> (defaultOutputs) });
|
||||
|
||||
for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum)
|
||||
{
|
||||
|
|
@ -375,19 +386,16 @@ struct AudioUnitHelpers
|
|||
if (! isNumberOfChannelsSupported (outBus, outChanNum, outLayout))
|
||||
continue;
|
||||
|
||||
supportedChannels.add (((hasMainInputBus ? outLayout.getMainInputChannels() : 0) << 16)
|
||||
| (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0));
|
||||
supportedChannels.add ({ static_cast<SInt16> (hasMainInputBus ? outLayout.getMainInputChannels() : 0),
|
||||
static_cast<SInt16> (hasMainOutputBus ? outLayout.getMainOutputChannels() : 0) });
|
||||
}
|
||||
}
|
||||
|
||||
auto hasInOutMismatch = false;
|
||||
|
||||
for (auto supported : supportedChannels)
|
||||
for (const auto& supported : supportedChannels)
|
||||
{
|
||||
auto numInputs = (supported >> 16) & 0xffff;
|
||||
auto numOutputs = (supported >> 0) & 0xffff;
|
||||
|
||||
if (numInputs != numOutputs)
|
||||
if (supported.ins != supported.outs)
|
||||
{
|
||||
hasInOutMismatch = true;
|
||||
break;
|
||||
|
|
@ -398,9 +406,10 @@ struct AudioUnitHelpers
|
|||
|
||||
for (auto inChanNum = hasMainInputBus ? 1 : 0; inChanNum <= (hasMainInputBus ? maxNumChanToCheckFor : 0); ++inChanNum)
|
||||
{
|
||||
auto channelConfiguration = (inChanNum << 16) | (hasInOutMismatch ? defaultOutputs : inChanNum);
|
||||
Channels channelConfiguration { static_cast<SInt16> (inChanNum),
|
||||
static_cast<SInt16> (hasInOutMismatch ? defaultOutputs : inChanNum) };
|
||||
|
||||
if (! supportedChannels.contains (channelConfiguration))
|
||||
if (supportedChannels.contains (channelConfiguration))
|
||||
{
|
||||
hasUnsupportedInput = true;
|
||||
break;
|
||||
|
|
@ -409,25 +418,23 @@ struct AudioUnitHelpers
|
|||
|
||||
for (auto outChanNum = hasMainOutputBus ? 1 : 0; outChanNum <= (hasMainOutputBus ? maxNumChanToCheckFor : 0); ++outChanNum)
|
||||
{
|
||||
auto channelConfiguration = ((hasInOutMismatch ? defaultInputs : outChanNum) << 16) | outChanNum;
|
||||
Channels channelConfiguration { static_cast<SInt16> (hasInOutMismatch ? defaultInputs : outChanNum),
|
||||
static_cast<SInt16> (outChanNum) };
|
||||
|
||||
if (! supportedChannels.contains (channelConfiguration))
|
||||
if (supportedChannels.contains (channelConfiguration))
|
||||
{
|
||||
hasUnsupportedOutput = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (auto supported : supportedChannels)
|
||||
for (const auto& supported : supportedChannels)
|
||||
{
|
||||
auto numInputs = (supported >> 16) & 0xffff;
|
||||
auto numOutputs = (supported >> 0) & 0xffff;
|
||||
|
||||
AUChannelInfo info;
|
||||
|
||||
// see here: https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html
|
||||
info.inChannels = static_cast<SInt16> (hasMainInputBus ? (hasUnsupportedInput ? numInputs : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0);
|
||||
info.outChannels = static_cast<SInt16> (hasMainOutputBus ? (hasUnsupportedOutput ? numOutputs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0);
|
||||
info.inChannels = static_cast<SInt16> (hasMainInputBus ? (hasUnsupportedInput ? supported.ins : (hasInOutMismatch && (! hasUnsupportedOutput) ? -2 : -1)) : 0);
|
||||
info.outChannels = static_cast<SInt16> (hasMainOutputBus ? (hasUnsupportedOutput ? supported.outs : (hasInOutMismatch && (! hasUnsupportedInput) ? -2 : -1)) : 0);
|
||||
|
||||
if (info.inChannels == -2 && info.outChannels == -2)
|
||||
info.inChannels = -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue