From c7b64803d999ff993899dbf1f1449060e8ca9e9c Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 2 Sep 2015 21:05:09 +0200 Subject: rework AudioUnit variable input port count. --- libs/ardour/audio_unit.cc | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'libs/ardour/audio_unit.cc') diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc index bcf4778b7d..063055b5e6 100644 --- a/libs/ardour/audio_unit.cc +++ b/libs/ardour/audio_unit.cc @@ -423,7 +423,7 @@ AUPlugin::AUPlugin (AudioEngine& engine, Session& session, boost::shared_ptr 0) { + in.set (DataType::AUDIO, audio_input_cnt); } int32_t audio_in = in.n_audio(); @@ -1143,6 +1143,32 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) audio_out = audio_in; } + /* kAudioUnitProperty_SupportedNumChannels + * https://developer.apple.com/library/mac/documentation/MusicAudio/Conceptual/AudioUnitProgrammingGuide/TheAudioUnit/TheAudioUnit.html#//apple_ref/doc/uid/TP40003278-CH12-SW20 + * + * - both fields are -1 + * e.g. inChannels = -1 outChannels = -1 + * This is the default case. Any number of input and output channels, as long as the numbers match + * + * - one field is -1, the other field is positive + * e.g. inChannels = -1 outChannels = 2 + * Any number of input channels, exactly two output channels + * + * - one field is -1, the other field is -2 + * e.g. inChannels = -1 outChannels = -2 + * Any number of input channels, any number of output channels + * + * - both fields have non-negative values + * e.g. inChannels = 2 outChannels = 6 + * Exactly two input channels, exactly six output channels + * e.g. inChannels = 0 outChannels = 2 + * No input channels, exactly two output channels (such as for an instrument unit with stereo output) + * + * - both fields have negative values, neither of which is –1 or –2 + * e.g. inChannels = -4 outChannels = -8 + * Up to four input channels and up to eight output channels + */ + for (vector >::iterator i = io_configs.begin(); i != io_configs.end(); ++i) { int32_t possible_in = i->first; @@ -1314,9 +1340,10 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out) } if (found) { - if (possible_in < -2 && possible_in == possible_out) { - // input-port count needs to match output-port - _match_ioports = true; + if (possible_in < -2 && audio_in == 0) { + // input-port count cannot be zero, use as many ports + // as outputs, but at most abs(possible_in) + audio_input_cnt = max (1, min (audio_out, -possible_in)); } break; } -- cgit v1.2.3