- 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 ());
-
- int possible_in = io["audio_in"];
- int possible_out = io["audio_out"];
-
- if (possible_out == 0 && possible_in == 0 && _has_midi_output) {
- assert (audio_in > 0); // no input is handled above
- // TODO hide audio input from plugin
- imprecise->set (DataType::AUDIO, 0);
- audio_out = 0;
- found = true;
- continue;
- }
-
- 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) {
- FOUNDCFG (2);
- } else if (possible_out < -2) {
- /* explicitly variable number of outputs, pick maximum */
- FOUNDCFG (min (-possible_out, preferred_out));
- } else {
- /* exact number of outputs */
- FOUNDCFG (possible_out);
- }
- // ideally we'll also find the closest, best matching
- // input configuration with minimal output penalty...
- }