diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-24 08:36:04 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-24 08:36:04 -0400 |
commit | 3d95822716d2e52b54a5bdbe7be4478ab034f8db (patch) | |
tree | 258f77985dda0c2cd5980e44a2bd8459d85cf0ec /libs/ardour/ardour/audioengine.h | |
parent | 17588cc9be3522c806d4c9b734714e0b164b5ae2 (diff) |
more miscellaneous changes for audioengine, all of this is still far from actually compiling
Diffstat (limited to 'libs/ardour/ardour/audioengine.h')
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 277 |
1 files changed, 129 insertions, 148 deletions
diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index 5a064f5183..a3f16ff376 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -33,7 +33,6 @@ #include <glibmm/threads.h> -#include "pbd/rcu.h" #include "pbd/signals.h" #include "pbd/stacktrace.h" @@ -60,163 +59,145 @@ class MidiPort; class Port; class Session; class ProcessThread; +class AudioBackend; class AudioEngine : public SessionHandlePtr { public: - typedef std::map<std::string,boost::shared_ptr<Port> > Ports; - - AudioEngine (std::string client_name, std::string session_uuid); - virtual ~AudioEngine (); - - static int discover_backends(); - std::vector<std::string> available_backends() const; - - ProcessThread* main_thread() const { return _main_thread; } - - std::string client_name() const { return jack_client_name; } - - int stop (bool forever = false); - int start (); - int pause (); - int freewheel (bool); + typedef std::map<std::string,boost::shared_ptr<Port> > Ports; - bool running() const { return _running; } - - Glib::Threads::Mutex& process_lock() { return _process_lock; } - - - int request_buffer_size (pframes_t); - - framecnt_t processed_frames() const { return _processed_frames; } - - float get_cpu_load() { - jack_client_t* _priv_jack = _jack; - if (!_running || !_priv_jack) { - return 0; - } - return jack_cpu_load (_priv_jack); - } - - void set_session (Session *); - void remove_session (); // not a replacement for SessionHandle::session_going_away() - - class NoBackendAvailable : public std::exception { - public: - virtual const char *what() const throw() { return "could not connect to engine backend"; } - }; - - void split_cycle (pframes_t offset); - - int reset_timebase (); - - void update_latencies (); - - /* start/stop freewheeling */ - - int freewheel (bool onoff); - bool freewheeling() const { return _freewheeling; } - - /* this signal is sent for every process() cycle while freewheeling. -_ the regular process() call to session->process() is not made. - */ - - PBD::Signal1<int, pframes_t> Freewheel; - - PBD::Signal0<void> Xrun; - - /* this signal is if JACK notifies us of a graph order event */ + AudioEngine (std::string client_name, std::string session_uuid); + virtual ~AudioEngine (); + + static int discover_backends(); + std::vector<std::string> available_backends() const; + std::string current_backend_name () const; - PBD::Signal0<void> GraphReordered; + ProcessThread* main_thread() const { return _main_thread; } + + std::string client_name() const { return backend_client_name; } + + int stop (bool forever = false); + int start (); + int pause (); + int freewheel (bool onoff); + bool freewheeling() const { return _freewheeling; } + + bool running() const { return _running; } + Glib::Threads::Mutex& process_lock() { return _process_lock; } + + int request_buffer_size (pframes_t); + + framecnt_t processed_frames() const { return _processed_frames; } + + float get_cpu_load(); + + void set_session (Session *); + void remove_session (); // not a replacement for SessionHandle::session_going_away() + + class NoBackendAvailable : public std::exception { + public: + virtual const char *what() const throw() { return "could not connect to engine backend"; } + }; + + void split_cycle (pframes_t offset); + + int reset_timebase (); + + void update_latencies (); + + /* this signal is sent for every process() cycle while freewheeling. + (the regular process() call to session->process() is not made) + */ + + PBD::Signal1<int, pframes_t> Freewheel; + + PBD::Signal0<void> Xrun; + + /* this signal is if the backend notifies us of a graph order event */ + + PBD::Signal0<void> GraphReordered; + #ifdef HAVE_JACK_SESSION - PBD::Signal1<void,jack_session_event_t *> JackSessionEvent; + PBD::Signal1<void,jack_session_event_t *> JackSessionEvent; #endif - - - /* this signal is emitted if the sample rate changes */ - - PBD::Signal1<void, framecnt_t> SampleRateChanged; - - /* this signal is sent if JACK ever disconnects us */ - - PBD::Signal1<void,const char*> Halted; - - /* these two are emitted when the engine itself is - started and stopped - */ - - PBD::Signal0<void> Running; - PBD::Signal0<void> Stopped; - - /** Emitted if a JACK port is registered or unregistered */ - PBD::Signal0<void> PortRegisteredOrUnregistered; - - /** Emitted if a JACK port is connected or disconnected. - * The Port parameters are the ports being connected / disconnected, or 0 if they are not known to Ardour. - * The std::string parameters are the (long) port names. - * The bool parameter is true if ports were connected, or false for disconnected. - */ - PBD::Signal5<void, boost::weak_ptr<Port>, std::string, boost::weak_ptr<Port>, std::string, bool> PortConnectedOrDisconnected; - - std::string make_port_name_relative (std::string) const; - std::string make_port_name_non_relative (std::string) const; - bool port_is_mine (const std::string&) const; - - static AudioEngine* instance() { return _instance; } - static void destroy(); - void died (); - - int create_process_thread (boost::function<void()>, pthread_t*, size_t stacksize); - -private: - static AudioEngine* _instance; - - Glib::Threads::Mutex _process_lock; - Glib::Threads::Cond session_removed; - bool session_remove_pending; - frameoffset_t session_removal_countdown; - gain_t session_removal_gain; - gain_t session_removal_gain_step; - bool _running; - bool _has_run; - mutable framecnt_t _buffer_size; - std::map<DataType,size_t> _raw_buffer_sizes; - mutable framecnt_t _frame_rate; - /// number of frames between each check for changes in monitor input - framecnt_t monitor_check_interval; - /// time of the last monitor check in frames - framecnt_t last_monitor_check; - /// the number of frames processed since start() was called - framecnt_t _processed_frames; - bool _freewheeling; - bool _pre_freewheel_mmc_enabled; - int _usecs_per_cycle; - bool port_remove_in_progress; - Glib::Threads::Thread* m_meter_thread; - ProcessThread* _main_thread; - - - SerializedRCUManager<Ports> ports; - - boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input); - - int process_callback (pframes_t nframes); - void* process_thread (); - void remove_all_ports (); - - void port_registration_failure (const std::string& portname); - - void meter_thread (); - void start_metering_thread (); - void stop_metering_thread (); - - static gint m_meter_exit; - - void parameter_changed (const std::string&); - PBD::ScopedConnection config_connection; + + /* this signal is emitted if the sample rate changes */ + + PBD::Signal1<void, framecnt_t> SampleRateChanged; + + /* this signal is sent if the backend ever disconnects us */ + + PBD::Signal1<void,const char*> Halted; + + /* these two are emitted when the engine itself is + started and stopped + */ + + PBD::Signal0<void> Running; + PBD::Signal0<void> Stopped; + + /** Emitted if a Port is registered or unregistered */ + PBD::Signal0<void> PortRegisteredOrUnregistered; + + /** Emitted if a Port is connected or disconnected. + * The Port parameters are the ports being connected / disconnected, or 0 if they are not known to Ardour. + * The std::string parameters are the (long) port names. + * The bool parameter is true if ports were connected, or false for disconnected. + */ + PBD::Signal5<void, boost::weak_ptr<Port>, std::string, boost::weak_ptr<Port>, std::string, bool> PortConnectedOrDisconnected; + + std::string make_port_name_relative (std::string) const; + std::string make_port_name_non_relative (std::string) const; + bool port_is_mine (const std::string&) const; + + static AudioEngine* instance() { return _instance; } + static void destroy(); + void died (); + + /* The backend will cause this at the appropriate time(s) + */ + int process_callback (pframes_t nframes); + + private: + static AudioEngine* _instance; + + Glib::Threads::Mutex _process_lock; + Glib::Threads::Cond session_removed; + bool session_remove_pending; + frameoffset_t session_removal_countdown; + gain_t session_removal_gain; + gain_t session_removal_gain_step; + bool _running; + bool _has_run; + mutable framecnt_t _buffer_size; + std::map<DataType,size_t> _raw_buffer_sizes; + mutable framecnt_t _frame_rate; + /// number of frames between each check for changes in monitor input + framecnt_t monitor_check_interval; + /// time of the last monitor check in frames + framecnt_t last_monitor_check; + /// the number of frames processed since start() was called + framecnt_t _processed_frames; + bool _freewheeling; + bool _pre_freewheel_mmc_enabled; + int _usecs_per_cycle; + bool port_remove_in_progress; + Glib::Threads::Thread* m_meter_thread; + ProcessThread* _main_thread; + + + void meter_thread (); + void start_metering_thread (); + void stop_metering_thread (); + + static gint m_meter_exit; + + void parameter_changed (const std::string&); + PBD::ScopedConnection config_connection; }; - + } // namespace ARDOUR #endif /* __ardour_audioengine_h__ */ |