X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fport.h;h=23b42a55eaaa848a0aa51ef611e482ebb513a83e;hb=844b7d0f684eaf01a8d553f935027f496a09c3ad;hp=93c34da16d9c28d3e0dd915354b268856c7022b6;hpb=449aab3c465bbbf66d221fac3d7ea559f1720357;p=ardour.git diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h index 93c34da16d..23b42a55ea 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 @@ -21,160 +21,132 @@ #define __ardour_port_h__ #include -#include #include - -#include -#include -#include -#include +#include #include +#include +#include "pbd/signals.h" + +#include "ardour/data_type.h" +#include "ardour/types.h" namespace ARDOUR { class AudioEngine; class Buffer; -/** Abstract base for ports - */ -class Port : public virtual sigc::trackable { - public: +class Port : public boost::noncopyable +{ +public: enum Flags { IsInput = JackPortIsInput, IsOutput = JackPortIsOutput, - IsPhysical = JackPortIsPhysical, - IsTerminal = JackPortIsTerminal, - CanMonitor = JackPortCanMonitor }; - virtual ~Port(); + virtual ~Port (); + + static void set_buffer_size (nframes_t sz) { + _buffer_size = sz; + } + static void set_connecting_blocked( bool yn ) { + _connecting_blocked = yn; + } + static bool connecting_blocked() { + return _connecting_blocked; + } - std::string name() const { + /** @return Port short name */ + std::string name () const { return _name; } - Flags flags() const { + int set_name (std::string const &); + + /** @return flags */ + Flags 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 & IsOutput; } - bool can_monitor () const { - return _flags & CanMonitor; - } + bool connected () const; + int disconnect_all (); + int get_connections (std::vector &) const; - void enable_metering() { - _metering++; - } - - void disable_metering () { - if (_metering) { _metering--; } - } + /* connection by name */ + bool connected_to (std::string const &) const; + int connect (std::string const &); + int disconnect (std::string const &); - 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; + /* connection by Port* */ + bool connected_to (Port *) const; + virtual int connect (Port *); + int disconnect (Port *); - virtual bool connected () const; - virtual bool connected_to (const std::string& portname) const; - virtual int get_connections (std::vector&) const; + void ensure_monitor_input (bool); + bool monitoring_input () const; + nframes_t total_latency () const; + int reestablish (); + int reconnect (); + void request_monitor_input (bool); + void set_latency (nframes_t); - 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; - } - 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; + /** @return the size of the raw buffer (bytes) for duration @a nframes (audio frames) */ + virtual size_t raw_buffer_size(jack_nframes_t nframes) const = 0; - sigc::signal MonitorInputChanged; - sigc::signal ClockSyncChanged; - - static void set_engine (AudioEngine*); + virtual DataType type () const = 0; + virtual void cycle_start (nframes_t) = 0; + virtual void cycle_end (nframes_t) = 0; + virtual void cycle_split () = 0; + virtual Buffer& get_buffer (nframes_t nframes, nframes_t offset = 0) = 0; + virtual void flush_buffers (nframes_t nframes, framepos_t /*time*/, nframes_t offset = 0) { + assert(offset < nframes); + } + virtual void transport_stopped () {} - protected: - friend class AudioEngine; + bool physically_connected () const; - Port (const std::string& name, Flags flgs); + static void set_engine (AudioEngine *); - virtual void recompute_total_latency() const {} - - /* engine isn't supposed to access below here */ + PBD::Signal1 MonitorInputChanged; - Flags _flags; - std::string _type; - std::string _name; - unsigned short _metering; - bool _last_monitor; - nframes_t _latency; +protected: - std::set _connections; + Port (std::string const &, DataType, Flags); - static AudioEngine* engine; -}; + jack_port_t* _jack_port; ///< JACK port -class PortConnectableByName { - public: - PortConnectableByName() {} - virtual ~PortConnectableByName() {} + static nframes_t _buffer_size; + static bool _connecting_blocked; + + static AudioEngine* _engine; ///< the AudioEngine - 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() {} +private: + friend class AudioEngine; - void reset (); - int reestablish (); - int reconnect (); + void recompute_total_latency () const; - int connect (Port& other); - int disconnect (Port& other); - int disconnect_all (); + /* XXX */ + bool _last_monitor; - int connect (const std::string& other_name); - int disconnect (const std::string& other_name); + std::string _name; ///< port short name + Flags _flags; ///< flags - 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; + /** ports that we are connected to, kept so that we can + reconnect to JACK when required */ + std::set _connections; }; -} // namespace ARDOUR +} #endif /* __ardour_port_h__ */