Add two utility methods to abstract PortAudioBackend state

These may change as support for callback API is added
This commit is contained in:
Tim Mayberry 2015-08-27 18:52:08 +10:00
parent f143d76523
commit 23a490c906
2 changed files with 18 additions and 4 deletions

View file

@ -433,16 +433,27 @@ static void * pthread_process (void *arg)
return 0; return 0;
} }
bool
PortAudioBackend::engine_halted ()
{
return !_active && _run;
}
bool
PortAudioBackend::running ()
{
return _active || _run;
}
int int
PortAudioBackend::_start (bool for_latency_measurement) PortAudioBackend::_start (bool for_latency_measurement)
{ {
if (!_active && _run) { if (engine_halted()) {
// recover from 'halted', reap threads
stop(); stop();
} }
if (_active || _run) { if (running()) {
DEBUG_AUDIO("Already active.\n"); DEBUG_AUDIO("Already started.\n");
return -1; return -1;
} }

View file

@ -330,6 +330,9 @@ class PortAudioBackend : public AudioBackend {
void process_incoming_midi (); void process_incoming_midi ();
void process_outgoing_midi (); void process_outgoing_midi ();
bool engine_halted ();
bool running ();
private: private:
std::string _instance_name; std::string _instance_name;
PortAudioIO *_pcmio; PortAudioIO *_pcmio;