diff --git a/libs/backends/portaudio/portaudio_backend.cc b/libs/backends/portaudio/portaudio_backend.cc index 3555d09928..006bf3143a 100644 --- a/libs/backends/portaudio/portaudio_backend.cc +++ b/libs/backends/portaudio/portaudio_backend.cc @@ -433,16 +433,27 @@ static void * pthread_process (void *arg) return 0; } +bool +PortAudioBackend::engine_halted () +{ + return !_active && _run; +} + +bool +PortAudioBackend::running () +{ + return _active || _run; +} + int PortAudioBackend::_start (bool for_latency_measurement) { - if (!_active && _run) { - // recover from 'halted', reap threads + if (engine_halted()) { stop(); } - if (_active || _run) { - DEBUG_AUDIO("Already active.\n"); + if (running()) { + DEBUG_AUDIO("Already started.\n"); return -1; } diff --git a/libs/backends/portaudio/portaudio_backend.h b/libs/backends/portaudio/portaudio_backend.h index 08de76ccfb..7b3f247875 100644 --- a/libs/backends/portaudio/portaudio_backend.h +++ b/libs/backends/portaudio/portaudio_backend.h @@ -330,6 +330,9 @@ class PortAudioBackend : public AudioBackend { void process_incoming_midi (); void process_outgoing_midi (); + bool engine_halted (); + bool running (); + private: std::string _instance_name; PortAudioIO *_pcmio;