From 23a490c906974b0fc7ba46c58e533d2733c3a5d4 Mon Sep 17 00:00:00 2001 From: Tim Mayberry Date: Thu, 27 Aug 2015 18:52:08 +1000 Subject: [PATCH] Add two utility methods to abstract PortAudioBackend state These may change as support for callback API is added --- libs/backends/portaudio/portaudio_backend.cc | 19 +++++++++++++++---- libs/backends/portaudio/portaudio_backend.h | 3 +++ 2 files changed, 18 insertions(+), 4 deletions(-) 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;