- if (possible_in && (possible_in == audio_in)) {
- /* exact number of inputs ... must match obviously */
- if (possible_out == -1) {
- /* any output configuration possible */
- FOUNDCFG (preferred_out);
- ANYTHINGGOES;
- } else if (possible_out == -2) {
- /* invalid. interpret as (>0, -1) */
- FOUNDCFG (preferred_out);
- ANYTHINGGOES;
- } else if (possible_out < -2) {
- /* > 0, < -2 is not specified
- * interpret as up to -N */
- FOUNDCFG (min (-possible_out, preferred_out));
- UPTO (-possible_out)
- } else {
- /* exact number of outputs */
- FOUNDCFG (possible_out);
- }
- }
- }
-
- if (found && imprecise) {
- *imprecise = in;
- }
-
- if (!found && imprecise) {
- /* try harder */
- 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;
-
- 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...
- }