Fix non-buffered PA backend. Wait for backend to become active

This hopefully fixes an issue with port-registration (new session)
being skipped because PortAudioBackend::available() still false
until the first callback.
This commit is contained in:
Robin Gareus 2017-08-07 23:23:39 +02:00
parent 7235d9751b
commit 26dc287c00

View File

@ -581,6 +581,8 @@ PortAudioBackend::_start (bool for_latency_measurement)
}
/* reset internal state */
assert (_run == false);
_run = false;
_dsp_load = 0;
_freewheeling = false;
_freewheel = false;
@ -658,7 +660,6 @@ PortAudioBackend::_start (bool for_latency_measurement)
if (register_system_midi_ports () != 0) {
DEBUG_PORTS("Failed to register system midi ports.\n")
_run = false;
return PortRegistrationError;
}
@ -666,7 +667,6 @@ PortAudioBackend::_start (bool for_latency_measurement)
if (register_system_audio_ports()) {
DEBUG_PORTS("Failed to register system audio ports.\n");
_run = false;
return PortRegistrationError;
}
@ -675,7 +675,6 @@ PortAudioBackend::_start (bool for_latency_measurement)
if (engine.reestablish_ports ()) {
DEBUG_PORTS("Could not re-establish ports.\n");
_run = false;
return PortReconnectError;
}
@ -699,6 +698,16 @@ PortAudioBackend::_start (bool for_latency_measurement)
stop();
return ProcessThreadStartError;
}
/* wait for backend to become active */
int timeout = 5000;
while (!_active && --timeout > 0) { Glib::usleep (1000); }
if (timeout == 0 || !_active) {
PBD::error << _("PortAudio:: failed to start device.") << endmsg;
stop ();
return ProcessThreadStartError;
}
}
return NoError;