X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fport.h;h=084022541d3993d3c9639237215e87f0dbc501a8;hb=1d210a54f9b1c0da7a196413bd760ff53f198270;hp=5da254b6df31e02d61c5e9ae7b7e62271bdfce66;hpb=5169a66f35508dfeee8e5f9486788843d229295a;p=ardour.git diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 5da254b6df..084022541d 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -15,12 +15,15 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __ardour_port_h__ #define __ardour_port_h__ +#include +#include +#include +#include #include #include #include @@ -32,69 +35,38 @@ namespace ARDOUR { class AudioEngine; class Buffer; -/** Abstract base for all outside ports (eg Jack ports) +/** Abstract base for ports */ -class Port : public sigc::trackable { +class Port : public virtual sigc::trackable { public: - virtual ~Port() { - free (_port); - } - - virtual DataType type() const = 0; - - virtual void cycle_start(jack_nframes_t nframes) {} - virtual void cycle_end() {} - - virtual Buffer& get_buffer() = 0; - - /** Silence/Empty the port, output ports only */ - virtual void silence (jack_nframes_t nframes, jack_nframes_t offset) = 0; + enum Flags { + IsInput = JackPortIsInput, + IsOutput = JackPortIsOutput, + IsPhysical = JackPortIsPhysical, + IsTerminal = JackPortIsTerminal, + CanMonitor = JackPortCanMonitor + }; + virtual ~Port(); std::string name() const { return _name; } - std::string short_name() { - return jack_port_short_name (_port); - } - - int set_name (std::string str); - - JackPortFlags flags() const { + Flags flags() const { return _flags; } - bool is_mine (jack_client_t *client) { - return jack_port_is_mine (client, _port); - } - - int connected () const { - return jack_port_connected (_port); - } - - bool connected_to (const std::string& portname) const { - return jack_port_connected_to (_port, portname.c_str()); - } - - const char ** get_connections () const { - return jack_port_get_connections (_port); - } - bool receives_input() const { - return _flags & JackPortIsInput; + return _flags & IsInput; } bool sends_output () const { - return _flags & JackPortIsOutput; - } - - bool monitoring_input () const { - return jack_port_monitoring_input (_port); + return _flags & IsOutput; } bool can_monitor () const { - return _flags & JackPortCanMonitor; + return _flags & CanMonitor; } void enable_metering() { @@ -104,55 +76,105 @@ class Port : public sigc::trackable { void disable_metering () { if (_metering) { _metering--; } } - - void ensure_monitor_input (bool yn) { - jack_port_ensure_monitor (_port, yn); - } - /*XXX completely bloody useless imho*/ - void request_monitor_input (bool yn) { - jack_port_request_monitor (_port, yn); - } + virtual void cycle_start (nframes_t nframes, nframes_t offset) {} + virtual void cycle_end (nframes_t nframes, nframes_t offset) {} + virtual DataType type() const = 0; + virtual Buffer& get_buffer() = 0; - jack_nframes_t latency () const { - return jack_port_get_latency (_port); - } + virtual bool connected () const; + virtual bool connected_to (const std::string& portname) const; + virtual int get_connections (std::vector&) const; - void set_latency (jack_nframes_t nframes) { - jack_port_set_latency (_port, nframes); + virtual int connect (Port& other); + virtual int disconnect (Port& other); + virtual int disconnect_all (); + + virtual void reset (); + virtual int reestablish () {return 0; } + virtual int reconnect () { return 0; } + + virtual int set_name (const std::string& str) { + _name = str; + return 0; } - bool is_silent() const { return _silent; } + virtual std::string short_name() const = 0; + virtual bool monitoring_input () const = 0; + virtual void ensure_monitor_input (bool yn) = 0; + virtual void request_monitor_input (bool yn) = 0; + virtual nframes_t latency () const = 0; + virtual nframes_t total_latency () const = 0; + virtual void set_latency (nframes_t nframes) = 0; - void mark_silence (bool yn) { - _silent = yn; - } - sigc::signal MonitorInputChanged; sigc::signal ClockSyncChanged; + static void set_engine (AudioEngine*); + protected: friend class AudioEngine; - Port (jack_port_t *port); - - virtual void reset (); + Port (const std::string& name, Flags flgs); + + virtual void recompute_total_latency() const {} /* engine isn't supposed to access below here */ - /* cache these 3 from JACK so we can access them for reconnecting */ - JackPortFlags _flags; - std::string _type; - std::string _name; + Flags _flags; + std::string _type; + std::string _name; + unsigned short _metering; + bool _last_monitor; + nframes_t _latency; - jack_port_t* _port; + std::set _connections; - unsigned short _metering; + static AudioEngine* engine; +}; - bool _last_monitor : 1; - bool _silent : 1; +class PortConnectableByName { + public: + PortConnectableByName() {} + virtual ~PortConnectableByName() {} + + virtual int connect (const std::string& other_name) = 0; + virtual int disconnect (const std::string& other_name) = 0; }; +class PortFacade : public virtual Port, public PortConnectableByName { + public: + PortFacade (const std::string& name, Flags flgs) : Port (name, flgs), _ext_port (0) {} + ~PortFacade() {} + + void reset (); + int reestablish (); + int reconnect (); + + int connect (Port& other); + int disconnect (Port& other); + int disconnect_all (); + + int connect (const std::string& other_name); + int disconnect (const std::string& other_name); + + bool connected () const; + bool connected_to (const std::string& portname) const; + int get_connections (std::vector&) const; + + std::string short_name() const; + int set_name (const std::string& str); + bool monitoring_input () const; + void ensure_monitor_input (bool yn); + void request_monitor_input (bool yn); + nframes_t latency () const; + nframes_t total_latency () const; + void set_latency (nframes_t nframes); + + protected: + Port* _ext_port; +}; + } // namespace ARDOUR #endif /* __ardour_port_h__ */