summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_unit.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2018-07-31 16:32:52 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2019-05-12 22:32:10 +0200
commitb5218fa38b74a7cdb19bf0fd8c6bf7590445351d (patch)
tree9afa0cde7c4999987369934422e59359d1a52b11 /libs/ardour/audio_unit.cc
parent0e0c55c6b548276defd7cdc36be373a708c59f90 (diff)
Introduce a macro for imprecise configurations
It enables only setting the imprecise audio channel count if the configuration is indeed selected.
Diffstat (limited to 'libs/ardour/audio_unit.cc')
-rw-r--r--libs/ardour/audio_unit.cc44
1 files changed, 29 insertions, 15 deletions
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index f8b3feac9a..af09bd82d6 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -1365,13 +1365,19 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
# pragma clang diagnostic ignored "-Wtautological-compare"
#endif
-#define FOUNDCFG(nch) { \
- float p = fabsf ((float)(nch) - preferred_out); \
- _output_configs.insert (nch); \
- if ((nch) > preferred_out) { p *= 1.1; } \
+#define FOUNDCFG_IMPRECISE(in, out) { \
+ float p = fabsf ((float)(out) - preferred_out); \
+ if (in != audio_in) { \
+ p += 1000; \
+ } \
+ _output_configs.insert (out); \
+ if ((out) > preferred_out) { p *= 1.1; } \
if (p < penalty) { \
used_possible_in = possible_in; \
- audio_out = (nch); \
+ audio_out = (out); \
+ if (imprecise) { \
+ imprecise->set (DataType::AUDIO, (in)); \
+ } \
penalty = p; \
found = true; \
variable_inputs = possible_in < 0; \
@@ -1379,6 +1385,9 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
} \
}
+#define FOUNDCFG(out) \
+ FOUNDCFG_IMPRECISE(audio_in, out)
+
#define ANYTHINGGOES \
_output_configs.insert (0);
@@ -1388,6 +1397,10 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
} \
}
+ if (imprecise) {
+ *imprecise = in;
+ }
+
for (vector<pair<int,int> >::iterator i = io_configs.begin(); i != io_configs.end(); ++i) {
int32_t possible_in = i->first;
@@ -1458,12 +1471,6 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
if (possible_in < -2 || possible_in > 0) {
/* specified number, exact or up to */
- if (possible_in < -2 && audio_in > -possible_in && imprecise) {
- // hide inputs ports
- // XXX: this is really *input* imprecise and should have
- // been part of the second pass below
- imprecise->set (DataType::AUDIO, -possible_in);
- }
if (possible_in < -2 && audio_in > -possible_in && !imprecise) {
/* request is too large */
} else if (possible_in > 0 && audio_in != possible_in) {
@@ -1482,6 +1489,14 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
/* exact number of outputs */
FOUNDCFG (possible_out);
}
+ if (possible_in < -2 && audio_in > -possible_in && imprecise) {
+ // hide inputs ports
+ // XXX: this is really *input* imprecise and should have
+ // been part of the second pass below. Also, this change
+ // should only be applied when really selecting a corresponding
+ // configuration.
+ imprecise->set (DataType::AUDIO, -possible_in);
+ }
}
}
@@ -1494,15 +1509,14 @@ AUPlugin::can_support_io_configuration (const ChanCount& in, ChanCount& out, Cha
assert (possible_in > 0); // all other cases will have been matched above
- imprecise->set (DataType::AUDIO, possible_in);
if (possible_out == -1 || possible_out == -2) {
- FOUNDCFG (2);
+ FOUNDCFG_IMPRECISE (possible_in, 2);
} else if (possible_out < -2) {
/* explicitly variable number of outputs, pick maximum */
- FOUNDCFG (min (-possible_out, preferred_out));
+ FOUNDCFG_IMPRECISE (possible_in, min (-possible_out, preferred_out));
} else {
/* exact number of outputs */
- FOUNDCFG (possible_out);
+ FOUNDCFG_IMPRECISE (possible_in, possible_out);
}
// ideally we'll also find the closest, best matching
// input configuration with minimal output penalty...