summaryrefslogtreecommitdiff
path: root/libs/ardour/luaproc.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-08-01 15:41:10 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2016-08-06 19:38:09 +0200
commit4c7242545bf7c5171851de260a74f583b55c7ea3 (patch)
treee6b9151e357d13bd77bb7da5db9ff42ef66f4ce8 /libs/ardour/luaproc.cc
parentdde13d288e22ba5dd8e23802c47fac288b089c57 (diff)
Replace the exact_match logic by a negative penalty
Instead of doing an initial loop for detection of exact matches, then letting the following loop set \audio_out yet ignore its value, merge the two loops but give exact matches a negative penalty so that the \audio_out value they set won't change afterwards. No policy change.
Diffstat (limited to 'libs/ardour/luaproc.cc')
-rw-r--r--libs/ardour/luaproc.cc44
1 files changed, 15 insertions, 29 deletions
diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc
index 6be2edafa5..f1f64f038b 100644
--- a/libs/ardour/luaproc.cc
+++ b/libs/ardour/luaproc.cc
@@ -378,35 +378,15 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
return false;
}
- bool found = false;
- bool exact_match = false;
const int audio_in = in.n_audio ();
- int midi_out = _has_midi_output ? 1 : 0;
// preferred setting (provided by plugin_insert)
const int preferred_out = out.n_audio ();
- for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
- luabridge::LuaRef io (i.value ());
- if (!io.isTable()) {
- continue;
- }
-
- int possible_in = io["audio_in"].isNumber() ? io["audio_in"] : -1;
- int possible_out = io["audio_out"].isNumber() ? io["audio_out"] : -1;
-
- // exact match
- if ((possible_in == audio_in) && (possible_out == preferred_out)) {
- _output_configs.insert (preferred_out);
- exact_match = true;
- found = true;
- break;
- }
- }
-
- /* now allow potentially "imprecise" matches */
+ int midi_out = _has_midi_output ? 1 : 0;
int audio_out = -1;
float penalty = 9999;
+ bool found = false;
#define FOUNDCFG(nch) { \
float p = fabsf ((float)(nch) - preferred_out); \
@@ -437,6 +417,17 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
int possible_in = io["audio_in"].isNumber() ? io["audio_in"] : -1;
int possible_out = io["audio_out"].isNumber() ? io["audio_out"] : -1;
+ // exact match
+ if ((possible_in == audio_in) && (possible_out == preferred_out)) {
+ _output_configs.insert (preferred_out);
+ audio_out = preferred_out;
+ /* Set penalty so low that this output configuration
+ * will trump any other one */
+ penalty = -1;
+ found = true;
+ }
+
+ // "imprecise" matches
if (possible_out == 0) {
if (possible_in == 0) {
if (_has_midi_output && audio_in == 0) {
@@ -611,13 +602,8 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
_selected_in = in;
}
- if (exact_match) {
- out.set (DataType::MIDI, midi_out);
- out.set (DataType::AUDIO, preferred_out);
- } else {
- out.set (DataType::MIDI, midi_out);
- out.set (DataType::AUDIO, audio_out);
- }
+ out.set (DataType::MIDI, midi_out);
+ out.set (DataType::AUDIO, audio_out);
_selected_out = out;
return true;