Remove wrong asserts
[ardour.git] / libs / ardour / luaproc.cc
index 48daf8cede1243da7ada3cfe1d3ac7e42d27737e..6be2edafa562b32ef2fc1f3e9e275056c136ba07 100644 (file)
@@ -380,19 +380,20 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
 
        bool found = false;
        bool exact_match = false;
-       const int32_t audio_in = in.n_audio ();
-       int32_t midi_out = _has_midi_output ? 1 : 0;
+       const int audio_in = in.n_audio ();
+       int midi_out = _has_midi_output ? 1 : 0;
 
        // preferred setting (provided by plugin_insert)
-       assert (out.n_audio () > 0 || midi_out > 0);
        const int preferred_out = out.n_audio ();
 
        for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
-               assert (i.value ().type () == LUA_TTABLE);
                luabridge::LuaRef io (i.value ());
+               if (!io.isTable()) {
+                       continue;
+               }
 
-               int possible_in = io["audio_in"];
-               int possible_out = io["audio_out"];
+               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)) {
@@ -404,7 +405,7 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
        }
 
        /* now allow potentially "imprecise" matches */
-       int32_t audio_out = -1;
+       int audio_out = -1;
        float penalty = 9999;
 
 #define FOUNDCFG(nch) {                            \
@@ -428,11 +429,13 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
 }
 
        for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
-               assert (i.value ().type () == LUA_TTABLE);
                luabridge::LuaRef io (i.value ());
+               if (!io.isTable()) {
+                       continue;
+               }
 
-               int possible_in = io["audio_in"];
-               int possible_out = io["audio_out"];
+               int possible_in = io["audio_in"].isNumber() ? io["audio_in"] : -1;
+               int possible_out = io["audio_out"].isNumber() ? io["audio_out"] : -1;
 
                if (possible_out == 0) {
                        if (possible_in == 0) {
@@ -558,17 +561,18 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
 
        if (found && imprecise) {
                *imprecise = in;
-               imprecise->set (DataType::MIDI, _has_midi_input ? 1 : 0);
        }
 
        if (!found && imprecise) {
                /* try harder */
                for (luabridge::Iterator i (iotable); !i.isNil (); ++i) {
-                       assert (i.value ().type () == LUA_TTABLE);
                        luabridge::LuaRef io (i.value ());
+                       if (!io.isTable()) {
+                               continue;
+                       }
 
-                       int possible_in = io["audio_in"];
-                       int possible_out = io["audio_out"];
+                       int possible_in = io["audio_in"].isNumber() ? io["audio_in"] : -1;
+                       int possible_out = io["audio_out"].isNumber() ? io["audio_out"] : -1;
 
                        if (possible_out == 0 && possible_in == 0 && _has_midi_output) {
                                assert (audio_in > 0); // no input is handled above
@@ -580,7 +584,6 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan
                        }
 
                        assert (possible_in > 0); // all other cases will have been matched above
-                       assert (possible_out !=0 || possible_in !=0); // already handled above
 
                        imprecise->set (DataType::AUDIO, possible_in);
                        if (possible_out == -1 || possible_out == -2) {
@@ -658,7 +661,6 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
                                                        lin.set (DataType::MIDI, c);
                                                }
                                        }
-                                       _info->n_inputs = lin;
                                        if (io["midi_out"].type() == LUA_TNUMBER) {
                                                const int c = io["midi_out"].cast<int> ();
                                                if (c >= 0) {