fix -Wreorder
[ardour.git] / libs / backends / portaudio / portaudio_backend.h
index 82583c6f8658ec8333e2645f9fba8fae0a644fcc..f0ef5fa9932df2a22b0d659176e3aba0e8d374e2 100644 (file)
 #include <boost/shared_ptr.hpp>
 
 #include "ardour/audio_backend.h"
+#include "ardour/dsp_load_calculator.h"
 #include "ardour/types.h"
 
 #include "portaudio_io.h"
 #include "winmmemidi_io.h"
 #include "cycle_timer.h"
-#include "dsp_load_calculator.h"
 
 namespace ARDOUR {
 
@@ -318,7 +318,9 @@ class PortAudioBackend : public AudioBackend {
 
                void* get_buffer (PortHandle, pframes_t);
 
-               void* main_blocking_process_thread ();
+               void* blocking_process_thread ();
+
+               void* freewheel_process_thread ();
 
        private: // Methods
                bool start_blocking_process_thread ();
@@ -334,6 +336,22 @@ class PortAudioBackend : public AudioBackend {
                bool engine_halted ();
                bool running ();
 
+               static int portaudio_callback(const void* input,
+                                         void* output,
+                                         unsigned long frameCount,
+                                         const PaStreamCallbackTimeInfo* timeInfo,
+                                         PaStreamCallbackFlags statusFlags,
+                                         void* userData);
+
+               bool process_callback(const float* input,
+                                 float* output,
+                                 uint32_t frame_count,
+                                 const PaStreamCallbackTimeInfo* timeInfo,
+                                 PaStreamCallbackFlags statusFlags);
+
+               bool start_freewheel_process_thread ();
+               bool stop_freewheel_process_thread ();
+
                static bool set_mmcss_pro_audio (HANDLE* task_handle);
                static bool reset_mmcss (HANDLE task_handle);
 
@@ -346,16 +364,23 @@ class PortAudioBackend : public AudioBackend {
                bool  _active; /* is running, process thread */
                bool  _freewheel;
                bool  _freewheeling;
+               bool  _freewheel_ack;
+               bool  _reinit_thread_callback;
                bool  _measure_latency;
 
-               DSPLoadCalculator m_dsp_calc;
+               ARDOUR::DSPLoadCalculator _dsp_calc;
 
-               uint64_t m_cycle_count;
-               uint64_t m_total_deviation_us;
-               uint64_t m_max_deviation_us;
+               bool _freewheel_thread_active;
 
-               CycleTimer m_cycle_timer;
-               uint64_t m_last_cycle_start;
+               pthread_mutex_t _freewheel_mutex;
+               pthread_cond_t _freewheel_signal;
+
+               uint64_t _cycle_count;
+               uint64_t _total_deviation_us;
+               uint64_t _max_deviation_us;
+
+               CycleTimer _cycle_timer;
+               uint64_t _last_cycle_start;
 
                static std::vector<std::string> _midi_options;
                static std::vector<AudioBackend::DeviceStatus> _input_audio_device_status;
@@ -387,6 +412,12 @@ class PortAudioBackend : public AudioBackend {
                /* blocking thread */
                pthread_t _main_blocking_thread;
 
+               /* main thread in callback mode(or fw thread when running) */
+               pthread_t _main_thread;
+
+               /* freewheel thread in callback mode */
+               pthread_t _pthread_freewheel;
+
                /* process threads */
                static void* portaudio_process_thread (void *);
                std::vector<pthread_t> _threads;