13
0

Introduce a macro for imprecise configurations

It enables only setting the imprecise audio channel count if the
configuration is indeed selected.
This commit is contained in:
Julien "_FrnchFrgg_" RIVAUD 2016-08-02 17:47:14 +02:00
parent 961b9c8be8
commit 80541de283

View File

@ -385,14 +385,17 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
float penalty = 9999;
bool found = false;
#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) { \
audio_out = (nch); \
audio_out = (out); \
if (imprecise) { \
*imprecise = in; \
imprecise->set (DataType::AUDIO, (in)); \
imprecise->set (DataType::MIDI, \
possible_midiin); \
} \
@ -401,6 +404,9 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
} \
}
#define FOUNDCFG(out) \
FOUNDCFG_IMPRECISE(audio_in, out)
#define ANYTHINGGOES \
_output_configs.insert (0);
@ -410,6 +416,10 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
} \
}
if (imprecise) {
*imprecise = in;
}
for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
luabridge::LuaRef io (i.value ());
if (!io.isTable()) {
@ -534,15 +544,14 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
assert (possible_in > 0); // all other cases will have been matched above
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);
}
imprecise->set (DataType::AUDIO, possible_in);
// ideally we'll also find the closest, best matching
// input configuration with minimal output penalty...
}