Introduce a macro for imprecise configurations
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Tue, 2 Aug 2016 15:47:14 +0000 (17:47 +0200)
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>
Sat, 6 Aug 2016 17:38:09 +0000 (19:38 +0200)
It enables only setting the imprecise audio channel count if the
configuration is indeed selected.

libs/ardour/luaproc.cc

index 27746d29cbce14194f8c2bb065daf3d80dd230fd..52b567711d479065495a8df399cb6a9d4e600f8d 100644 (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...
                }