2 Copyright (C) 2002-2006 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 #include <ardour/port.h>
22 using namespace ARDOUR;
25 AudioEngine* Port::engine = 0;
27 Port::Port (const std::string& name, Flags flgs)
31 , _last_monitor (false)
43 _last_monitor = false;
47 Port::set_engine (AudioEngine* e)
53 Port::connect (Port& other)
55 /* caller must hold process lock */
57 pair<set<Port*>::iterator,bool> result;
59 result = _connections.insert (&other);
69 Port::disconnect (Port& other)
71 /* caller must hold process lock */
73 for (set<Port*>::iterator i = _connections.begin(); i != _connections.end(); ++i) {
75 _connections.erase (i);
85 Port::disconnect_all ()
87 /* caller must hold process lock */
89 _connections.clear ();
94 Port::set_latency (nframes_t val)
100 Port::connected() const
102 /* caller must hold process lock */
103 return !_connections.empty();
107 Port::connected_to (const string& portname) const
109 /* caller must hold process lock */
111 for (set<Port*>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) {
112 if ((*p)->name() == portname) {
121 Port::get_connections (vector<string>& names) const
123 /* caller must hold process lock */
125 set<Port*>::const_iterator p;
127 for (i = 0, p = _connections.begin(); p != _connections.end(); ++p, ++i) {
128 names.push_back ((*p)->name());
135 //-------------------------------------
138 PortFacade::set_name (const std::string& str)
143 if ((ret = _ext_port->set_name (str)) == 0) {
144 _name = _ext_port->name();
155 PortFacade::short_name () const
158 return _ext_port->short_name();
166 PortFacade::reestablish ()
169 return _ext_port->reestablish ();
177 PortFacade::reconnect()
180 return _ext_port->reconnect ();
187 PortFacade::set_latency (nframes_t val)
190 _ext_port->set_latency (val);
197 PortFacade::latency() const
200 return _ext_port->latency();
207 PortFacade::total_latency() const
210 return _ext_port->total_latency();
217 PortFacade::monitoring_input() const
220 return _ext_port->monitoring_input ();
227 PortFacade::ensure_monitor_input (bool yn)
230 _ext_port->ensure_monitor_input (yn);
235 PortFacade::request_monitor_input (bool yn)
238 _ext_port->request_monitor_input (yn);
243 PortFacade::connect (Port& other)
248 ret = _ext_port->connect (other);
254 ret = Port::connect (other);
261 PortFacade::connect (const std::string& other)
263 PortConnectableByName* pcn;
269 pcn = dynamic_cast<PortConnectableByName*>(_ext_port);
272 return pcn->connect (other);
280 PortFacade::disconnect (Port& other)
286 reta = _ext_port->disconnect (other);
291 retb = Port::disconnect (other);
297 PortFacade::disconnect_all ()
303 reta = _ext_port->disconnect_all ();
306 retb = Port::disconnect_all ();
312 PortFacade::disconnect (const std::string& other)
314 PortConnectableByName* pcn;
320 pcn = dynamic_cast<PortConnectableByName*>(_ext_port);
323 return pcn->disconnect (other);
330 PortFacade::connected () const
332 if (Port::connected()) {
337 return _ext_port->connected();
343 PortFacade::connected_to (const std::string& portname) const
345 if (Port::connected_to (portname)) {
350 return _ext_port->connected_to (portname);
358 PortFacade::get_connections (vector<string>& names) const
363 i = _ext_port->get_connections (names);
366 i += Port::get_connections (names);