Add two utility methods to abstract PortAudioBackend state
authorTim Mayberry <mojofunk@gmail.com>
Thu, 27 Aug 2015 08:52:08 +0000 (18:52 +1000)
committerTim Mayberry <mojofunk@gmail.com>
Wed, 2 Sep 2015 02:07:58 +0000 (12:07 +1000)
These may change as support for callback API is added

libs/backends/portaudio/portaudio_backend.cc
libs/backends/portaudio/portaudio_backend.h

index 3555d099285a8ee46de12a111d913712b0723afc..006bf3143a07bad83c7c3e488509ca690f55cf3a 100644 (file)
@@ -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;
        }
 
index 08de76ccfb4d2df190cf27ed3f5ca323764ff4f1..7b3f247875ecf2707800a5f847bfda8c2d94cbcb 100644 (file)
@@ -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;