diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-13 20:48:33 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2010-04-13 20:48:33 +0000 |
commit | 3ea10b38bbb4b471178793f68fbd3a0ee74449f6 (patch) | |
tree | 347a964476f8383aefcdfa94ce548cdfdf15e1d8 /libs/ardour/ardour | |
parent | 46ea5f5f5885dda6b10b75c104f726f6638c431e (diff) |
substantive change: use the JACK wait API and provide "thread buffers" separately from session in preparation for parallelization. lots of debug output at present. If using JACK1, requires a very current version of JACK1 SVN (0.119.0)
git-svn-id: svn://localhost/ardour2/branches/3.0@6888 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/buffer_manager.h | 31 | ||||
-rw-r--r-- | libs/ardour/ardour/process_thread.h | 44 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 18 | ||||
-rw-r--r-- | libs/ardour/ardour/thread_buffers.h | 33 |
5 files changed, 123 insertions, 11 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index e630e1a95e..63f9afeb2b 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -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 (); @@ -272,6 +275,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 +289,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*); @@ -307,6 +313,8 @@ _ the regular process() call to session->process() is not made. Glib::Thread* m_meter_thread; static gint m_meter_exit; + + ProcessThread* _main_thread; }; } // namespace ARDOUR diff --git a/libs/ardour/ardour/buffer_manager.h b/libs/ardour/ardour/buffer_manager.h new file mode 100644 index 0000000000..4da8d0637f --- /dev/null +++ b/libs/ardour/ardour/buffer_manager.h @@ -0,0 +1,31 @@ +#ifndef __libardour_buffer_manager__ +#define __libardour_buffer_manager__ + +#include <stdint.h> + +#include "pbd/ringbufferNPT.h" + +#include "ardour/chan_count.h" + +namespace ARDOUR { + +class ThreadBuffers; + +class BufferManager +{ + public: + static void init (uint32_t); + + static ThreadBuffers* get_thread_buffers (); + static void put_thread_buffers (ThreadBuffers*); + + static void ensure_buffers (ChanCount howmany = ChanCount::ZERO); + + private: + typedef RingBufferNPT<ThreadBuffers*> ThreadBufferFIFO; + static ThreadBufferFIFO* thread_buffers; +}; + +} + +#endif /* __libardour_buffer_manager__ */ diff --git a/libs/ardour/ardour/process_thread.h b/libs/ardour/ardour/process_thread.h new file mode 100644 index 0000000000..d6bbbfc6fc --- /dev/null +++ b/libs/ardour/ardour/process_thread.h @@ -0,0 +1,44 @@ +#ifndef __libardour_process_thread__ +#define __libardour_process_thread__ + +#include <glibmm/thread.h> + +#include "ardour/chan_count.h" +#include "ardour/types.h" + +namespace ARDOUR { + +class ThreadBuffers; + +class ProcessThread +{ + public: + ProcessThread (); + ~ProcessThread (); + + static void init(); + + void get_buffers (); + void drop_buffers (); + + /* these MUST be called by a process thread's thread, nothing else + */ + + static BufferSet& get_silent_buffers (ChanCount count = ChanCount::ZERO); + static BufferSet& get_scratch_buffers (ChanCount count = ChanCount::ZERO); + static BufferSet& get_mix_buffers (ChanCount count = ChanCount::ZERO); + static gain_t* gain_automation_buffer (); + static pan_t** pan_automation_buffer (); + + protected: + void session_going_away (); + + private: + Glib::Thread* _thread; + + static Glib::Private<ThreadBuffers>* _private_thread_buffers; +}; + +} // namespace + +#endif /* __libardour_process_thread__ */ diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 2b51e3f8ec..b5c818e6a2 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -106,6 +106,7 @@ class Playlist; class PluginInsert; class Port; class PortInsert; +class ProcessThread; class Processor; class Region; class Return; @@ -736,8 +737,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi /* buffers for gain and pan */ - gain_t* gain_automation_buffer () const { return _gain_automation_buffer; } - pan_t** pan_automation_buffer () const { return _pan_automation_buffer; } + gain_t* gain_automation_buffer () const; + pan_t** pan_automation_buffer () const; void ensure_buffer_set (BufferSet& buffers, const ChanCount& howmany); @@ -859,9 +860,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi nframes64_t _last_slave_transport_frame; nframes_t maximum_output_latency; volatile nframes64_t _requested_return_frame; - BufferSet* _scratch_buffers; - BufferSet* _silent_buffers; - BufferSet* _mix_buffers; nframes_t current_block_size; nframes_t _worst_output_latency; nframes_t _worst_input_latency; @@ -881,7 +879,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void update_latency_compensation_proxy (void* ignored); - void ensure_buffers (ChanCount howmany); + void ensure_buffers (ChanCount howmany = ChanCount::ZERO); void process_scrub (nframes_t); void process_without_events (nframes_t); @@ -894,6 +892,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void unblock_processing() { g_atomic_int_set (&processing_prohibited, 0); } bool processing_blocked() const { return g_atomic_int_get (&processing_prohibited); } + Glib::Mutex process_thread_lock; + std::list<ProcessThread*> process_threads; + /* slave tracking */ static const int delta_accumulator_size = 25; @@ -1389,11 +1390,6 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi boost::shared_ptr<Route> _master_out; boost::shared_ptr<Route> _monitor_out; - gain_t* _gain_automation_buffer; - pan_t** _pan_automation_buffer; - void allocate_pan_automation_buffers (nframes_t nframes, uint32_t howmany, bool force); - uint32_t _npan_buffers; - /* VST support */ long _vst_callback (VSTPlugin*, diff --git a/libs/ardour/ardour/thread_buffers.h b/libs/ardour/ardour/thread_buffers.h new file mode 100644 index 0000000000..3c312176a8 --- /dev/null +++ b/libs/ardour/ardour/thread_buffers.h @@ -0,0 +1,33 @@ +#ifndef __libardour_thread_buffers__ +#define __libardour_thread_buffers__ + +#include <glibmm/thread.h> + +#include "ardour/chan_count.h" +#include "ardour/types.h" + +namespace ARDOUR { + +class BufferSet; + +class ThreadBuffers { + public: + ThreadBuffers (); + ~ThreadBuffers (); + + void ensure_buffers (ChanCount howmany = ChanCount::ZERO); + + BufferSet* silent_buffers; + BufferSet* scratch_buffers; + BufferSet* mix_buffers; + gain_t* gain_automation_buffer; + pan_t** pan_automation_buffer; + uint32_t npan_buffers; + + private: + void allocate_pan_automation_buffers (nframes_t nframes, uint32_t howmany, bool force); +}; + +} // namespace + +#endif /* __libardour_thread_buffers__ */ |