use JACK thread creation functions to create process-graph threads; provide GUI contr...
[ardour.git] / libs / ardour / ardour / audioengine.h
index e630e1a95e87d8fb3a2d2d1f3ea1a4928f580082..9a0104b8fe08748b50c4338ac84f8a250531adcc 100644 (file)
@@ -55,6 +55,7 @@ class InternalPort;
 class MidiPort;
 class Port;
 class Session;
+class ProcessThread;
 
 class AudioEngine : public SessionHandlePtr
 {
@@ -69,6 +70,8 @@ class AudioEngine : public SessionHandlePtr
 
        bool is_realtime () const;
 
+        ProcessThread* main_thread() const { return _main_thread; }
+
        std::string client_name() const { return jack_client_name; }
 
        int reconnect_to_jack ();
@@ -221,7 +224,7 @@ _      the regular process() call to session->process() is not made.
 
        /* this signal is sent if JACK ever disconnects us */
 
-       PBD::Signal0<void> Halted;
+       PBD::Signal1<void,const char*> Halted;
 
        /* these two are emitted when the engine itself is
           started and stopped
@@ -242,6 +245,8 @@ _      the regular process() call to session->process() is not made.
        static AudioEngine* instance() { return _instance; }
        void died ();
 
+        pthread_t create_process_thread (boost::function<void()>, size_t stacksize);
+
   private:
        static AudioEngine*       _instance;
 
@@ -272,6 +277,8 @@ _      the regular process() call to session->process() is not made.
        Port *register_port (DataType type, const std::string& portname, bool input);
 
        int    process_callback (nframes_t nframes);
+       void*  process_thread ();
+        void   finish_process_cycle (int status);
        void   remove_all_ports ();
 
        std::string get_nth_physical (DataType type, uint32_t n, int flags);
@@ -284,6 +291,7 @@ _      the regular process() call to session->process() is not made.
 #endif
        static int  _graph_order_callback (void *arg);
        static int  _process_callback (nframes_t nframes, void *arg);
+       static void* _process_thread (void *arg);
        static int  _sample_rate_callback (nframes_t nframes, void *arg);
        static int  _bufsize_callback (nframes_t nframes, void *arg);
        static void _jack_timebase_callback (jack_transport_state_t, nframes_t, jack_position_t*, int, void*);
@@ -300,6 +308,7 @@ _      the regular process() call to session->process() is not made.
        int connect_to_jack (std::string client_name, std::string session_uuid);
 
        static void halted (void *);
+       static void halted_info (jack_status_t,const char*,void *);
 
        void meter_thread ();
        void start_metering_thread ();
@@ -307,6 +316,19 @@ _     the regular process() call to session->process() is not made.
 
        Glib::Thread*    m_meter_thread;
        static gint      m_meter_exit;
+
+        ProcessThread* _main_thread;
+
+        struct ThreadData {
+            AudioEngine* engine;
+            boost::function<void()> f;
+            size_t stacksize;
+            
+            ThreadData (AudioEngine* ae, boost::function<void()> fp, size_t stacksz) 
+            : engine (ae) , f (fp) , stacksize (stacksz) {}
+        };
+        
+        static void* _start_process_thread (void*);
 };
 
 } // namespace ARDOUR