2 Copyright (C) 2002 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef __ardour_port_h__
21 #define __ardour_port_h__
27 #include <sigc++/signal.h>
28 #include <pbd/failed_constructor.h>
29 #include <ardour/ardour.h>
30 #include <ardour/data_type.h>
31 #include <jack/jack.h>
38 /** Abstract base for ports
40 class Port : public virtual sigc::trackable {
43 IsInput = JackPortIsInput,
44 IsOutput = JackPortIsOutput,
45 IsPhysical = JackPortIsPhysical,
46 IsTerminal = JackPortIsTerminal,
47 CanMonitor = JackPortCanMonitor
52 std::string name() const {
60 bool receives_input() const {
61 return _flags & IsInput;
64 bool sends_output () const {
65 return _flags & IsOutput;
68 bool can_monitor () const {
69 return _flags & CanMonitor;
72 void enable_metering() {
76 void disable_metering () {
77 if (_metering) { _metering--; }
80 virtual void cycle_start (nframes_t nframes, nframes_t offset) {}
81 virtual void cycle_end (nframes_t nframes, nframes_t offset) {}
82 virtual void flush_buffers (nframes_t nframes, nframes_t offset ) {}
83 virtual DataType type() const = 0;
84 virtual Buffer& get_buffer( nframes_t nframes, nframes_t offset ) = 0;
86 virtual bool connected () const;
87 virtual bool connected_to (const std::string& portname) const;
88 virtual int get_connections (std::vector<std::string>&) const;
90 virtual int connect (Port& other);
91 virtual int disconnect (Port& other);
92 virtual int disconnect_all ();
94 virtual void reset ();
95 virtual int reestablish () {return 0; }
96 virtual int reconnect () { return 0; }
98 virtual int set_name (const std::string& str) {
103 virtual std::string short_name() const = 0;
104 virtual bool monitoring_input () const = 0;
105 virtual void ensure_monitor_input (bool yn) = 0;
106 virtual void request_monitor_input (bool yn) = 0;
107 virtual nframes_t latency () const = 0;
108 virtual nframes_t total_latency () const = 0;
109 virtual void set_latency (nframes_t nframes) = 0;
111 sigc::signal<void,bool> MonitorInputChanged;
112 sigc::signal<void,bool> ClockSyncChanged;
114 static void set_engine (AudioEngine*);
117 friend class AudioEngine;
119 Port (const std::string& name, Flags flgs);
121 virtual void recompute_total_latency() const {}
123 /* engine isn't supposed to access below here */
128 unsigned short _metering;
132 std::set<Port*> _connections;
134 static AudioEngine* engine;
137 class PortConnectableByName {
139 PortConnectableByName() {}
140 virtual ~PortConnectableByName() {}
142 virtual int connect (const std::string& other_name) = 0;
143 virtual int disconnect (const std::string& other_name) = 0;
146 class PortFacade : public virtual Port, public PortConnectableByName {
148 PortFacade (const std::string& name, Flags flgs) : Port (name, flgs), _ext_port (0) {}
155 int connect (Port& other);
156 int disconnect (Port& other);
157 int disconnect_all ();
159 int connect (const std::string& other_name);
160 int disconnect (const std::string& other_name);
162 bool connected () const;
163 bool connected_to (const std::string& portname) const;
164 int get_connections (std::vector<std::string>&) const;
166 std::string short_name() const;
167 int set_name (const std::string& str);
168 bool monitoring_input () const;
169 void ensure_monitor_input (bool yn);
170 void request_monitor_input (bool yn);
171 nframes_t latency () const;
172 nframes_t total_latency () const;
173 void set_latency (nframes_t nframes);
179 } // namespace ARDOUR
181 #endif /* __ardour_port_h__ */