diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audio_backend.h | 41 | ||||
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 21 | ||||
-rw-r--r-- | libs/ardour/ardour/jack_audiobackend.h | 57 | ||||
-rw-r--r-- | libs/ardour/ardour/jack_portengine.h | 75 | ||||
-rw-r--r-- | libs/ardour/ardour/port_manager.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/session.h | 4 |
6 files changed, 153 insertions, 53 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index e8511d0c57..4d6d6a6dd8 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -28,6 +28,8 @@ #include <boost/function.hpp> +#include "ardour/types.h" + namespace ARDOUR { class AudioEngine; @@ -45,6 +47,8 @@ class AudioBackend { */ virtual std::string name() const = 0; + virtual void* private_handle() const = 0; + /** return true if the underlying mechanism/API is still available * for us to utilize. return false if some or all of the AudioBackend * API can no longer be effectively used. @@ -98,13 +102,6 @@ class AudioBackend { */ virtual uint32_t available_output_channel_count (const std::string& device) const = 0; - enum SampleFormat { - Signed16bitInteger, - Signed24bitInteger, - Signed32bitInteger, - FloatingPoint - }; - /* Set the hardware parameters. * * If called when the current state is stopped or paused, @@ -163,15 +160,15 @@ class AudioBackend { */ virtual int set_systemic_output_latency (uint32_t) = 0; - virtual std::string get_device_name () const = 0; - virtual float get_sample_rate () const = 0; - virtual uint32_t get_buffer_size () const = 0; - virtual SampleFormat get_sample_format () const = 0; - virtual bool get_interleaved () const = 0; - virtual uint32_t get_input_channels () const = 0; - virtual uint32_t get_output_channels () const = 0; - virtual uint32_t get_systemic_input_latency () const = 0; - virtual uint32_t get_systemic_output_latency () const = 0; + virtual std::string device_name () const = 0; + virtual float sample_rate () const = 0; + virtual uint32_t buffer_size () const = 0; + virtual SampleFormat sample_format () const = 0; + virtual bool interleaved () const = 0; + virtual uint32_t input_channels () const = 0; + virtual uint32_t output_channels () const = 0; + virtual uint32_t systemic_input_latency () const = 0; + virtual uint32_t systemic_output_latency () const = 0; /* Basic state control */ @@ -246,7 +243,7 @@ class AudioBackend { * Implementations can feel free to smooth the values returned over * time (e.g. high pass filtering, or its equivalent). */ - virtual float get_cpu_load() const = 0; + virtual float cpu_load() const = 0; /* Transport Control (JACK is the only audio API that currently offers the concept of shared transport control) @@ -260,14 +257,14 @@ class AudioBackend { virtual void transport_stop () {} /** return the current transport state */ - virtual TransportState transport_state () { return TransportStopped; } + virtual TransportState transport_state () const { return TransportStopped; } /** Attempt to locate the transport to @param pos */ virtual void transport_locate (framepos_t /*pos*/) {} /** Return the current transport location, in samples measured * from the origin (defined by the transport time master) */ - virtual framepos_t transport_frame() { return 0; } + virtual framepos_t transport_frame() const { return 0; } /** If @param yn is true, become the time master for any inter-application transport * timebase, otherwise cease to be the time master for the same. @@ -279,9 +276,7 @@ class AudioBackend { */ virtual int set_time_master (bool /*yn*/) { return 0; } - virtual framecnt_t sample_rate () const; - virtual pframes_t samples_per_cycle () const; - virtual int usecs_per_cycle () const { return 1000000 * (samples_per_cycle() / sample_rate()); } + virtual int usecs_per_cycle () const { return 1000000 * (buffer_size() / sample_rate()); } virtual size_t raw_buffer_size (DataType t); /* Process time */ @@ -338,7 +333,7 @@ class AudioBackend { */ virtual int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize) = 0; - private: + protected: AudioEngine& engine; }; diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index d7d9ca8224..4ac9221238 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -104,7 +104,8 @@ public: pframes_t samples_since_cycle_start (); bool get_sync_offset (pframes_t& offset) const; int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize); - + bool is_realtime() const; + /* END BACKEND PROXY API */ bool freewheeling() const { return _freewheeling; } @@ -180,13 +181,21 @@ public: static void destroy(); void died (); - /* The backend will cause this at the appropriate time(s) + /* The backend will cause these at the appropriate time(s) */ - int process_callback (pframes_t nframes); + int process_callback (pframes_t nframes); + int buffer_size_change (pframes_t nframes); + int sample_rate_change (pframes_t nframes); + void freewheel_callback (bool); + void timebase_callback (TransportState state, pframes_t nframes, framepos_t pos, int new_position); + int sync_callback (TransportState state, framepos_t position); + int port_registration_callback (); + void latency_callback (bool for_playback); + void halted_callback (const char* reason); + + /* sets up the process callback thread */ + static void thread_init_callback (void *); - int buffer_size_change (pframes_t nframes); - int sample_rate_change (pframes_t nframes); - private: AudioEngine (const std::string& client_name, const std::string& session_uuid); diff --git a/libs/ardour/ardour/jack_audiobackend.h b/libs/ardour/ardour/jack_audiobackend.h index 6d2683790c..8f6e636d1a 100644 --- a/libs/ardour/ardour/jack_audiobackend.h +++ b/libs/ardour/ardour/jack_audiobackend.h @@ -22,6 +22,7 @@ #include <string> #include <vector> +#include <map> #include <stdint.h> @@ -38,10 +39,11 @@ class JackConnection; class JACKAudioBackend : public AudioBackend { public: - JACKAudioBackend (AudioEngine& e); + JACKAudioBackend (AudioEngine& e, void*); ~JACKAudioBackend (); std::string name() const; + void* private_handle() const; bool connected() const; bool is_realtime () const; @@ -61,34 +63,53 @@ class JACKAudioBackend : public AudioBackend { int set_systemic_input_latency (uint32_t); int set_systemic_output_latency (uint32_t); - std::string get_device_name () const; - float get_sample_rate () const; - uint32_t get_buffer_size () const; - SampleFormat get_sample_format () const; - bool get_interleaved () const; - uint32_t get_input_channels () const; - uint32_t get_output_channels () const; - uint32_t get_systemic_input_latency () const; - uint32_t get_systemic_output_latency () const; + std::string device_name () const; + float sample_rate () const; + uint32_t buffer_size () const; + SampleFormat sample_format () const; + bool interleaved () const; + uint32_t input_channels () const; + uint32_t output_channels () const; + uint32_t systemic_input_latency () const; + uint32_t systemic_output_latency () const; int start (); int stop (); int pause (); int freewheel (bool); + float cpu_load() const; + + pframes_t sample_time (); + pframes_t sample_time_at_cycle_start (); + pframes_t samples_since_cycle_start (); + + size_t raw_buffer_size (DataType t); + + int create_process_thread (boost::function<void()> func, pthread_t*, size_t stacksize); + + void transport_start (); + void transport_stop (); + void transport_locate (framepos_t /*pos*/); + TransportState transport_state () const; + framepos_t transport_frame() const; + + int set_time_master (bool /*yn*/); + bool get_sync_offset (pframes_t& /*offset*/) const; + private: - JackConnection* _jack_connection; + JackConnection* _jack_connection; //< shared with JACKPortEngine + bool _running; + bool _freewheeling; + std::map<DataType,size_t> _raw_buffer_sizes; static int _xrun_callback (void *arg); - static int _graph_order_callback (void *arg); static void* _process_thread (void *arg); static int _sample_rate_callback (pframes_t nframes, void *arg); static int _bufsize_callback (pframes_t nframes, void *arg); static void _jack_timebase_callback (jack_transport_state_t, pframes_t, jack_position_t*, int, void*); static int _jack_sync_callback (jack_transport_state_t, jack_position_t*, void *arg); static void _freewheel_callback (int , void *arg); - static void _registration_callback (jack_port_id_t, int, void *); - static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *); static void _latency_callback (jack_latency_callback_mode_t, void*); #ifdef HAVE_JACK_SESSION static void _session_callback (jack_session_event_t *event, void *arg); @@ -99,12 +120,12 @@ class JACKAudioBackend : public AudioBackend { int jack_bufsize_callback (pframes_t); int jack_sample_rate_callback (pframes_t); void freewheel_callback (int); - void connect_callback (jack_port_id_t, jack_port_id_t, int); int process_callback (pframes_t nframes); void jack_latency_callback (jack_latency_callback_mode_t); - + void disconnected (const char*); + void set_jack_callbacks (); - int connect_to_jack (std::string client_name, std::string session_uuid); + int reconnect_to_jack (); struct ThreadData { JACKAudioBackend* engine; @@ -136,6 +157,8 @@ class JACKAudioBackend : public AudioBackend { uint32_t _current_sample_rate; uint32_t _current_buffer_size; uint32_t _current_usecs_per_cycle; + uint32_t _current_systemic_input_latency; + uint32_t _current_systemic_output_latency; }; diff --git a/libs/ardour/ardour/jack_portengine.h b/libs/ardour/ardour/jack_portengine.h index 2456adc272..60aa52fb6b 100644 --- a/libs/ardour/ardour/jack_portengine.h +++ b/libs/ardour/ardour/jack_portengine.h @@ -20,13 +20,84 @@ #ifndef __libardour_jack_portengine_h__ #define __libardour_jack_portengine_h__ +#include <string> +#include <vector> + +#include <stdint.h> + +#include "ardour/port_engine.h" +#include "ardour/types.h" + namespace ARDOUR { +class JackConnection; + class JACKPortEngine : public PortEngine { public: - JACKPortEngine (const std::string& client_name, - const std::string& session_uuid); + JACKPortEngine (void* arg); // argument is a JackConnection + + bool connected() const; + void* private_handle() const; + + int set_port_name (PortHandle, const std::string&); + std::string get_port_name (PortHandle) const; + PortHandle* get_port_by_name (const std::string&) const; + + std::string make_port_name_relative (const std::string& name) const; + std::string make_port_name_non_relative (const std::string& name) const; + bool port_is_mine (const std::string& fullname) const; + + PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags); + void unregister_port (PortHandle); + + bool connected (PortHandle); + bool connected_to (PortHandle, const std::string&); + bool physically_connected (PortHandle); + + int get_connections (PortHandle, std::vector<std::string>&); + + int connect (PortHandle, const std::string&); + int disconnect (PortHandle, const std::string&); + int disconnect_all (PortHandle); + + int connect (const std::string& src, const std::string& dst); + int disconnect (const std::string& src, const std::string& dst); + + /* MIDI */ + + void midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index); + int midi_event_put (void* port_buffer, pframes_t timestamp, const uint8_t* buffer, size_t size); + uint32_t get_midi_event_count (void* port_buffer); + void midi_clear (void* port_buffer); + + /* Monitoring */ + + bool can_monitor_input() const; + int request_input_monitoring (PortHandle, bool); + int ensure_input_monitoring (PortHandle, bool); + bool monitoring_input (PortHandle); + + /* Latency management + */ + + void set_latency_range (PortHandle, bool for_playback, LatencyRange); + LatencyRange get_latency_range (PortHandle, bool for_playback); + LatencyRange get_connected_latency_range (PortHandle, int dir); + + void* get_buffer (PortHandle, pframes_t); + + pframes_t last_frame_time () const; + + private: + JackConnection* _jack_connection; + + static int _graph_order_callback (void *arg); + static void _registration_callback (jack_port_id_t, int, void *); + static void _connect_callback (jack_port_id_t, jack_port_id_t, int, void *); + + void connect_callback (jack_port_id_t, jack_port_id_t, int); + }; } // namespace diff --git a/libs/ardour/ardour/port_manager.h b/libs/ardour/ardour/port_manager.h index 0e9a84ea8c..29a566aa2d 100644 --- a/libs/ardour/ardour/port_manager.h +++ b/libs/ardour/ardour/port_manager.h @@ -55,10 +55,12 @@ class PortManager /* Port connectivity */ - int connect (const std::string& source, const std::string& destination); - int disconnect (const std::string& source, const std::string& destination); - int disconnect (boost::shared_ptr<Port>); + int connect (const std::string& source, const std::string& destination); + int disconnect (const std::string& source, const std::string& destination); + int disconnect (boost::shared_ptr<Port>); bool connected (const std::string&); + int reestablish_ports (); + int reconnect_ports (); /* other Port management */ diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index a782680082..4c005ffa74 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -1426,8 +1426,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi */ std::list<GQuark> _current_trans_quarks; - void jack_timebase_callback (jack_transport_state_t, pframes_t, jack_position_t*, int); - int jack_sync_callback (jack_transport_state_t, jack_position_t*); + // void timebase_callback (TransportState, pframes_t, jack_position_t*, int); + int jack_sync_callback (TransportState, framepos_t); void reset_jack_connection (jack_client_t* jack); void process_rtop (SessionEvent*); |