diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-31 19:47:20 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-07-31 19:47:20 -0400 |
commit | b5239317d4657ad689ef7ef4d11c1fb6ae3e699b (patch) | |
tree | 830f8a759967912f7032eb92613b16024920d805 /libs/ardour/ardour | |
parent | fbfa0acebe01e85629c415bec849ca36324c56b1 (diff) |
more stuff compiles
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audio_backend.h | 23 | ||||
-rw-r--r-- | libs/ardour/ardour/audio_port.h | 8 | ||||
-rw-r--r-- | libs/ardour/ardour/audioengine.h | 18 | ||||
-rw-r--r-- | libs/ardour/ardour/jack_audiobackend.h | 6 | ||||
-rw-r--r-- | libs/ardour/ardour/jack_connection.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/jack_portengine.h | 24 | ||||
-rw-r--r-- | libs/ardour/ardour/midi_port.h | 4 | ||||
-rw-r--r-- | libs/ardour/ardour/port_engine.h | 52 | ||||
-rw-r--r-- | libs/ardour/ardour/port_manager.h | 49 | ||||
-rw-r--r-- | libs/ardour/ardour/types.h | 7 |
10 files changed, 141 insertions, 54 deletions
diff --git a/libs/ardour/ardour/audio_backend.h b/libs/ardour/ardour/audio_backend.h index 4d6d6a6dd8..44525c8353 100644 --- a/libs/ardour/ardour/audio_backend.h +++ b/libs/ardour/ardour/audio_backend.h @@ -33,6 +33,8 @@ namespace ARDOUR { class AudioEngine; +class PortEngine; +class PortManager; class AudioBackend { public: @@ -47,15 +49,18 @@ class AudioBackend { */ virtual std::string name() const = 0; + /** Return a private, type-free pointer to any data + * that might be useful to a concrete implementation + */ virtual void* private_handle() const = 0; - /** return true if the underlying mechanism/API is still available + /** 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. */ virtual bool connected() const = 0; - /** return true if the callback from the underlying mechanism/API + /** Return true if the callback from the underlying mechanism/API * (CoreAudio, JACK, ASIO etc.) occurs in a thread subject to realtime * constraints. Return false otherwise. */ @@ -160,6 +165,8 @@ class AudioBackend { */ virtual int set_systemic_output_latency (uint32_t) = 0; + /* Retrieving parameters */ + virtual std::string device_name () const = 0; virtual float sample_rate () const = 0; virtual uint32_t buffer_size () const = 0; @@ -337,7 +344,17 @@ class AudioBackend { AudioEngine& engine; }; -} +struct AudioBackendInfo { + const char* name; + + int (*instantiate) (const std::string& arg1, const std::string& arg2); + int (*deinstantiate) (void); + + boost::shared_ptr<AudioBackend> (*backend_factory) (AudioEngine&); + boost::shared_ptr<PortEngine> (*portengine_factory) (PortManager&); +}; + +} // namespace #endif /* __libardour_audiobackend_h__ */ diff --git a/libs/ardour/ardour/audio_port.h b/libs/ardour/ardour/audio_port.h index a473dda418..f5affb0580 100644 --- a/libs/ardour/ardour/audio_port.h +++ b/libs/ardour/ardour/audio_port.h @@ -46,10 +46,12 @@ class AudioPort : public Port AudioBuffer& get_audio_buffer (pframes_t nframes); protected: - friend class AudioEngine; - + friend class PortManager; AudioPort (std::string const &, PortFlags); - /* special access for engine only */ + + protected: + friend class AudioEngine; + /* special access for engine only (hah, C++) */ Sample* engine_get_whole_audio_buffer (); private: diff --git a/libs/ardour/ardour/audioengine.h b/libs/ardour/ardour/audioengine.h index db1f59d19f..9e9da62ce0 100644 --- a/libs/ardour/ardour/audioengine.h +++ b/libs/ardour/ardour/audioengine.h @@ -61,6 +61,7 @@ class Port; class Session; class ProcessThread; class AudioBackend; +class AudioBackendInfo; class AudioEngine : public SessionHandlePtr, public PortManager { @@ -164,16 +165,6 @@ public: 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; @@ -202,7 +193,8 @@ public: static AudioEngine* _instance; - AudioBackend* _backend; + boost::shared_ptr<AudioBackend> _backend; + Glib::Threads::Mutex _process_lock; Glib::Threads::Cond session_removed; bool session_remove_pending; @@ -239,9 +231,9 @@ public: void parameter_changed (const std::string&); PBD::ScopedConnection config_connection; - typedef std::map<std::string,AudioBackend*> BackendMap; + typedef std::map<std::string,AudioBackendInfo*> BackendMap; BackendMap _backends; - AudioBackend* backend_discover (const std::string&); + AudioBackendInfo* backend_discover (const std::string&); void drop_backend (); }; diff --git a/libs/ardour/ardour/jack_audiobackend.h b/libs/ardour/ardour/jack_audiobackend.h index 8f6e636d1a..0855b8e90f 100644 --- a/libs/ardour/ardour/jack_audiobackend.h +++ b/libs/ardour/ardour/jack_audiobackend.h @@ -26,6 +26,8 @@ #include <stdint.h> +#include <boost/shared_ptr.hpp> + #include <jack/jack.h> #ifdef HAVE_JACK_SESSION #include <jack/session.h> @@ -39,7 +41,7 @@ class JackConnection; class JACKAudioBackend : public AudioBackend { public: - JACKAudioBackend (AudioEngine& e, void*); + JACKAudioBackend (AudioEngine& e, boost::shared_ptr<JackConnection>); ~JACKAudioBackend (); std::string name() const; @@ -98,7 +100,7 @@ class JACKAudioBackend : public AudioBackend { bool get_sync_offset (pframes_t& /*offset*/) const; private: - JackConnection* _jack_connection; //< shared with JACKPortEngine + boost::shared_ptr<JackConnection> _jack_connection; //< shared with JACKPortEngine bool _running; bool _freewheeling; std::map<DataType,size_t> _raw_buffer_sizes; diff --git a/libs/ardour/ardour/jack_connection.h b/libs/ardour/ardour/jack_connection.h index 02fb7c7e55..543a70c439 100644 --- a/libs/ardour/ardour/jack_connection.h +++ b/libs/ardour/ardour/jack_connection.h @@ -13,6 +13,8 @@ class JackConnection { JackConnection (const std::string& client_name, const std::string& session_uuid); ~JackConnection (); + const std::string& client_name() const { return _client_name; } + int open (); int close (); bool connected () const { return _jack != 0; } @@ -26,7 +28,7 @@ class JackConnection { private: jack_client_t* volatile _jack; - std::string client_name; + std::string _client_name; std::string session_uuid; }; diff --git a/libs/ardour/ardour/jack_portengine.h b/libs/ardour/ardour/jack_portengine.h index 60aa52fb6b..80e34f3c92 100644 --- a/libs/ardour/ardour/jack_portengine.h +++ b/libs/ardour/ardour/jack_portengine.h @@ -25,6 +25,8 @@ #include <stdint.h> +#include <boost/shared_ptr.hpp> + #include "ardour/port_engine.h" #include "ardour/types.h" @@ -35,11 +37,13 @@ class JackConnection; class JACKPortEngine : public PortEngine { public: - JACKPortEngine (void* arg); // argument is a JackConnection + JACKPortEngine (PortManager&, boost::shared_ptr<JackConnection>); bool connected() const; void* private_handle() const; + const std::string& my_name() 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; @@ -48,6 +52,10 @@ class JACKPortEngine : public PortEngine std::string make_port_name_non_relative (const std::string& name) const; bool port_is_mine (const std::string& fullname) const; + int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const; + + DataType port_data_type (PortHandle) const; + PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags); void unregister_port (PortHandle); @@ -85,17 +93,25 @@ class JACKPortEngine : public PortEngine LatencyRange get_latency_range (PortHandle, bool for_playback); LatencyRange get_connected_latency_range (PortHandle, int dir); - void* get_buffer (PortHandle, pframes_t); + bool port_is_physical (PortHandle) const; + void get_physical_outputs (DataType type, std::vector<std::string>&); + void get_physical_inputs (DataType type, std::vector<std::string>&); + ChanCount n_physical_outputs () const; + ChanCount n_physical_inputs () const; - pframes_t last_frame_time () const; + void* get_buffer (PortHandle, pframes_t); + framecnt_t last_frame_time () const; + private: - JackConnection* _jack_connection; + boost::shared_ptr<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 *); + int graph_order_callback (); + void connect_callback (jack_port_id_t, jack_port_id_t, int); }; diff --git a/libs/ardour/ardour/midi_port.h b/libs/ardour/ardour/midi_port.h index e14c7926fb..4a9a2ededc 100644 --- a/libs/ardour/ardour/midi_port.h +++ b/libs/ardour/ardour/midi_port.h @@ -57,9 +57,9 @@ class MidiPort : public Port { MidiBuffer& get_midi_buffer (pframes_t nframes); protected: - friend class AudioEngine; + friend class PortManager; - MidiPort (const std::string& name, PortFlags); + MidiPort (const std::string& name, PortFlags); private: MidiBuffer* _buffer; diff --git a/libs/ardour/ardour/port_engine.h b/libs/ardour/ardour/port_engine.h index 3044426ff9..5992a48a85 100644 --- a/libs/ardour/ardour/port_engine.h +++ b/libs/ardour/ardour/port_engine.h @@ -30,6 +30,8 @@ namespace ARDOUR { +class PortManager; + /** PortEngine is an abstract base class that defines the functionality * required by Ardour. * @@ -74,7 +76,7 @@ namespace ARDOUR { class PortEngine { public: - PortEngine() {} + PortEngine (PortManager& pm) : manager (pm) {} virtual ~PortEngine(); /* We use void* here so that the API can be defined for any implementation. @@ -90,32 +92,37 @@ class PortEngine { virtual bool connected() const = 0; virtual void* private_handle() const = 0; + virtual const std::string& my_name() const = 0; + virtual int set_port_name (PortHandle, const std::string&) = 0; virtual std::string get_port_name (PortHandle) const = 0; virtual PortHandle* get_port_by_name (const std::string&) const = 0; - DataType port_data_type (PortHandle) const; + /* Discovering the set of ports whose names, types and flags match + * specified values. + */ + + virtual int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&) const = 0; - virtual std::string make_port_name_relative (const std::string& name) const = 0; - virtual std::string make_port_name_non_relative (const std::string& name) const = 0; - virtual bool port_is_mine (const std::string& fullname) const = 0; + virtual DataType port_data_type (PortHandle) const = 0; virtual PortHandle register_port (const std::string& shortname, ARDOUR::DataType, ARDOUR::PortFlags) = 0; - virtual void unregister_port (PortHandle) = 0; + virtual void unregister_port (PortHandle) = 0; + + /* Connection management */ + + virtual int connect (const std::string& src, const std::string& dst) = 0; + virtual int disconnect (const std::string& src, const std::string& dst) = 0; + + virtual int connect (PortHandle, const std::string&) = 0; + virtual int disconnect (PortHandle, const std::string&) = 0; + virtual int disconnect_all (PortHandle) = 0; virtual bool connected (PortHandle) = 0; virtual bool connected_to (PortHandle, const std::string&) = 0; virtual bool physically_connected (PortHandle) = 0; - virtual int get_connections (PortHandle, std::vector<std::string>&) = 0; - virtual int connect (PortHandle, const std::string&) = 0; - virtual int disconnect (PortHandle, const std::string&) = 0; - virtual int disconnect_all (PortHandle) = 0; - - virtual int connect (const std::string& src, const std::string& dst) = 0; - virtual int disconnect (const std::string& src, const std::string& dst) = 0; - /* MIDI */ virtual void midi_event_get (pframes_t& timestamp, size_t& size, uint8_t** buf, void* port_buffer, uint32_t event_index) = 0; @@ -137,9 +144,24 @@ class PortEngine { virtual LatencyRange get_latency_range (PortHandle, bool for_playback) = 0; virtual LatencyRange get_connected_latency_range (PortHandle, int dir) = 0; + /* Discovering physical ports */ + + virtual bool port_is_physical (PortHandle) const = 0; + virtual void get_physical_outputs (DataType type, std::vector<std::string>&) = 0; + virtual void get_physical_inputs (DataType type, std::vector<std::string>&) = 0; + virtual ChanCount n_physical_outputs () const = 0; + virtual ChanCount n_physical_inputs () const = 0; + + /* getting the port buffer. untyped (void*) because this will return + * buffers containing different data depending on the port type + */ + virtual void* get_buffer (PortHandle, pframes_t) = 0; - virtual pframes_t last_frame_time () const = 0; + virtual framecnt_t last_frame_time() const = 0; + + protected: + PortManager& manager; }; } diff --git a/libs/ardour/ardour/port_manager.h b/libs/ardour/ardour/port_manager.h index 38c8d8bf98..5838ac66af 100644 --- a/libs/ardour/ardour/port_manager.h +++ b/libs/ardour/ardour/port_manager.h @@ -42,9 +42,10 @@ class PortManager public: typedef std::map<std::string,boost::shared_ptr<Port> > Ports; - PortManager(); + PortManager (); virtual ~PortManager() {} + void set_port_engine (PortEngine& pe); PortEngine& port_engine() { return *_impl; } /* Port registration */ @@ -62,16 +63,28 @@ class PortManager int reestablish_ports (); int reconnect_ports (); + bool connected (const std::string&); + bool connected_to (const std::string&, const std::string&); + bool physically_connected (const std::string&); + int get_connections (const std::string&, std::vector<std::string>&); + + /* Naming */ + + boost::shared_ptr<Port> get_port_by_name (const std::string &); + void port_renamed (const std::string&, const std::string&); + 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; + /* other Port management */ - bool port_is_physical (const std::string&) const; - void get_physical_outputs (DataType type, std::vector<std::string>&); - void get_physical_inputs (DataType type, std::vector<std::string>&); - boost::shared_ptr<Port> get_port_by_name (const std::string &); - void port_renamed (const std::string&, const std::string&); + bool port_is_physical (const std::string&) const; + void get_physical_outputs (DataType type, std::vector<std::string>&); + void get_physical_inputs (DataType type, std::vector<std::string>&); ChanCount n_physical_outputs () const; ChanCount n_physical_inputs () const; - const char ** get_ports (const std::string& port_name_pattern, DataType type, uint32_t flags); + + int get_ports (const std::string& port_name_pattern, DataType type, PortFlags flags, std::vector<std::string>&); void remove_all_ports (); @@ -94,15 +107,33 @@ class PortManager std::string reason; }; + /* the port engine will invoke these callbacks when the time is right */ + + void registration_callback (); + int graph_order_callback (); + void connect_callback (const std::string&, const std::string&, bool connection); + + bool port_remove_in_progress() const { return _port_remove_in_progress; } + + /** 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; protected: - PortEngine* _impl; + boost::shared_ptr<PortEngine> _impl; SerializedRCUManager<Ports> ports; + bool _port_remove_in_progress; boost::shared_ptr<Port> register_port (DataType type, const std::string& portname, bool input); void port_registration_failure (const std::string& portname); }; -} +} // namespace #endif /* __libardour_port_manager_h__ */ diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 0167909ef3..b00b03e060 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -598,8 +598,11 @@ namespace ARDOUR { /* these values happen to match the constants used by JACK but this equality cannot be assumed. */ - IsInput = 1, - IsOutput = 2, + IsInput = 0x1, + IsOutput = 0x2, + IsPhysical = 0x4, + CanMonitor = 0x8, + IsTerminal = 0x10 }; struct LatencyRange { |