From e16866416738a3b2089e760fb76d45ff7a59fe3a Mon Sep 17 00:00:00 2001 From: "Julien \"_FrnchFrgg_\" RIVAUD" Date: Sun, 31 Jul 2016 23:43:15 +0200 Subject: Be more tolerant to missing values or errors in io_config() --- libs/ardour/luaproc.cc | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'libs/ardour/luaproc.cc') diff --git a/libs/ardour/luaproc.cc b/libs/ardour/luaproc.cc index b393a2e00d..af5534e21a 100644 --- a/libs/ardour/luaproc.cc +++ b/libs/ardour/luaproc.cc @@ -388,11 +388,13 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan 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)) { @@ -428,11 +430,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) { @@ -563,11 +567,13 @@ LuaProc::can_support_io_configuration (const ChanCount& in, ChanCount& out, Chan 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 -- cgit v1.2.3