X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fport.h;h=99a2b60cc3a6b287b3f5429db3b64e9b1f033c98;hb=e5a181c323243a03338f5a9934a5df254986370d;hp=5c8192b6e86172c08fa9ab6636a05edaf0be956a;hpb=fc9ab1ccbdfc4ae8bdec962e4c9439c1fc59a55f;p=ardour.git diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 5c8192b6e8..99a2b60cc3 100644 --- a/libs/ardour/ardour/port.h +++ b/libs/ardour/ardour/port.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002 Paul Davis + Copyright (C) 2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,98 +20,169 @@ #ifndef __ardour_port_h__ #define __ardour_port_h__ -#include -#include -#include -#include -#include +#ifdef WAF_BUILD +#include "libardour-config.h" +#endif + +#include +#include +#include +#include +#include "pbd/signals.h" + +#include "ardour/data_type.h" +#include "ardour/port_engine.h" +#include "ardour/libardour_visibility.h" +#include "ardour/types.h" namespace ARDOUR { class AudioEngine; class Buffer; -/** Abstract base for ports - */ -class Port : public virtual sigc::trackable { - public: - enum Flags { - IsInput = JackPortIsInput, - IsOutput = JackPortIsOutput, - IsPhysical = JackPortIsPhysical, - IsTerminal = JackPortIsTerminal, - CanMonitor = JackPortCanMonitor - }; - - virtual ~Port() {} - - std::string name() const { +class LIBARDOUR_API Port : public boost::noncopyable +{ +public: + virtual ~Port (); + + static void set_connecting_blocked( bool yn ) { + _connecting_blocked = yn; + } + static bool connecting_blocked() { + return _connecting_blocked; + } + + /** @return Port short name */ + std::string name () const { return _name; } + /** @return Port human readable name */ + std::string pretty_name (bool fallback_to_name = false) const; + bool set_pretty_name (const std::string&); + + int set_name (std::string const &); - Flags flags() const { + /** @return flags */ + PortFlags flags () const { return _flags; } - bool receives_input() const { + /** @return true if this Port receives input, otherwise false */ + bool receives_input () const { return _flags & IsInput; } + /** @return true if this Port sends output, otherwise false */ bool sends_output () const { - return _flags & JackPortIsOutput; + return _flags & IsOutput; } - bool can_monitor () const { - return _flags & CanMonitor; - } + bool connected () const; + int disconnect_all (); + int get_connections (std::vector &) const; + + /* connection by name */ + bool connected_to (std::string const &) const; + int connect (std::string const &); + int disconnect (std::string const &); - void enable_metering() { - _metering++; + /* connection by Port* */ + bool connected_to (Port *) const; + virtual int connect (Port *); + int disconnect (Port *); + + void request_input_monitoring (bool); + void ensure_input_monitoring (bool); + bool monitoring_input () const; + int reestablish (); + int reconnect (); + + bool last_monitor() const { return _last_monitor; } + void set_last_monitor (bool yn) { _last_monitor = yn; } + + PortEngine::PortHandle port_handle() { return _port_handle; } + + void get_connected_latency_range (LatencyRange& range, bool playback) const; + + void set_private_latency_range (LatencyRange& range, bool playback); + const LatencyRange& private_latency_range (bool playback) const; + + void set_public_latency_range (LatencyRange const& range, bool playback) const; + LatencyRange public_latency_range (bool playback) const; + + virtual void reset (); + + virtual DataType type () const = 0; + virtual void cycle_start (pframes_t); + virtual void cycle_end (pframes_t) = 0; + virtual void cycle_split () = 0; + virtual Buffer& get_buffer (pframes_t nframes) = 0; + virtual void flush_buffers (pframes_t /*nframes*/) {} + virtual void transport_stopped () {} + virtual void realtime_locate () {} + + bool physically_connected () const; + bool externally_connected () const; + + PBD::Signal1 MonitorInputChanged; + static PBD::Signal2,boost::shared_ptr > PostDisconnect; + static PBD::Signal0 PortDrop; + static PBD::Signal0 PortSignalDrop; + + static void set_speed_ratio (double s); + static void set_cycle_samplecnt (pframes_t n); + + static samplecnt_t port_offset() { return _global_port_buffer_offset; } + static void set_global_port_buffer_offset (pframes_t off) { + _global_port_buffer_offset = off; } - - void disable_metering () { - if (_metering) { _metering--; } + static void increment_global_port_buffer_offset (pframes_t n) { + _global_port_buffer_offset += n; } - - virtual DataType type() const = 0; - virtual void cycle_start(nframes_t nframes) {} - virtual void cycle_end() {} - virtual Buffer& get_buffer() = 0; - virtual std::string short_name() = 0; - virtual int set_name (std::string str) = 0; - virtual int reestablish () = 0; - virtual int connected () const = 0; - virtual bool connected_to (const std::string& portname) const = 0; - virtual const char ** get_connections () 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; - - sigc::signal MonitorInputChanged; - sigc::signal ClockSyncChanged; - - protected: - friend class AudioEngine; - - Port (Flags); - - virtual int disconnect () = 0; - virtual void recompute_total_latency() const = 0; - virtual void reset (); - - /* engine isn't supposed to access below here */ - - Flags _flags; - std::string _type; - std::string _name; - unsigned short _metering; - bool _last_monitor; + + virtual XMLNode& get_state (void) const; + virtual int set_state (const XMLNode&, int version); + + static std::string state_node_name; + + static pframes_t cycle_nframes () { return _cycle_nframes; } + static double speed_ratio () { return _speed_ratio; } + +protected: + + Port (std::string const &, DataType, PortFlags); + + PortEngine::PortHandle _port_handle; + + static bool _connecting_blocked; + static pframes_t _cycle_nframes; /* access only from process() tree */ + + static pframes_t _global_port_buffer_offset; /* access only from process() tree */ + + LatencyRange _private_playback_latency; + LatencyRange _private_capture_latency; + + static double _speed_ratio; + static const uint32_t _resampler_quality; /* also latency of the resampler */ + +private: + std::string _name; ///< port short name + PortFlags _flags; ///< flags + bool _last_monitor; + + /** ports that we are connected to, kept so that we can + reconnect to the backend when required + */ + std::set _connections; + + void port_connected_or_disconnected (boost::weak_ptr, boost::weak_ptr, bool); + void signal_drop (); + void drop (); + PBD::ScopedConnection drop_connection; + PBD::ScopedConnection engine_connection; }; - -} // namespace ARDOUR + +} #endif /* __ardour_port_h__ */