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)
44 _last_monitor = false;
48 Port::set_engine (AudioEngine* e)
54 Port::connect (Port& other)
56 /* caller must hold process lock */
58 pair<set<Port*>::iterator,bool> result;
60 result = _connections.insert (&other);
63 other.GoingAway.connect (sigc::bind (mem_fun (*this, &Port::port_going_away), &other));
71 Port::disconnect (Port& other)
73 /* caller must hold process lock */
75 for (set<Port*>::iterator i = _connections.begin(); i != _connections.end(); ++i) {
77 _connections.erase (i);
87 Port::disconnect_all ()
89 /* caller must hold process lock */
91 _connections.clear ();
96 Port::set_latency (nframes_t val)
102 Port::connected() const
104 /* caller must hold process lock */
105 return !_connections.empty();
109 Port::connected_to (const string& portname) const
111 /* caller must hold process lock */
113 for (set<Port*>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) {
114 if ((*p)->name() == portname) {
123 Port::get_connections (vector<string>& names) const
125 /* caller must hold process lock */
127 set<Port*>::const_iterator p;
129 for (i = 0, p = _connections.begin(); p != _connections.end(); ++p, ++i) {
130 names.push_back ((*p)->name());
137 Port::port_going_away (Port* p)
139 /* caller must hold process lock */
145 //-------------------------------------
148 PortFacade::set_name (const std::string& str)
153 if ((ret = _ext_port->set_name (str)) == 0) {
154 _name = _ext_port->name();
165 PortFacade::short_name () const
168 return _ext_port->short_name();
176 PortFacade::reestablish ()
179 return _ext_port->reestablish ();
187 PortFacade::reconnect()
190 return _ext_port->reconnect ();
197 PortFacade::set_latency (nframes_t val)
200 _ext_port->set_latency (val);
207 PortFacade::latency() const
210 return _ext_port->latency();
217 PortFacade::total_latency() const
220 return _ext_port->total_latency();
227 PortFacade::monitoring_input() const
230 return _ext_port->monitoring_input ();
237 PortFacade::ensure_monitor_input (bool yn)
240 _ext_port->ensure_monitor_input (yn);
245 PortFacade::request_monitor_input (bool yn)
248 _ext_port->request_monitor_input (yn);
253 PortFacade::connect (Port& other)
258 ret = _ext_port->connect (other);
264 ret = Port::connect (other);
271 PortFacade::connect (const std::string& other)
273 PortConnectableByName* pcn;
279 pcn = dynamic_cast<PortConnectableByName*>(_ext_port);
282 return pcn->connect (other);
290 PortFacade::disconnect (Port& other)
296 reta = _ext_port->disconnect (other);
301 retb = Port::disconnect (other);
307 PortFacade::disconnect_all ()
313 reta = _ext_port->disconnect_all ();
316 retb = Port::disconnect_all ();
322 PortFacade::disconnect (const std::string& other)
324 PortConnectableByName* pcn;
330 pcn = dynamic_cast<PortConnectableByName*>(_ext_port);
333 return pcn->disconnect (other);
340 PortFacade::connected () const
342 if (Port::connected()) {
347 return _ext_port->connected();
353 PortFacade::connected_to (const std::string& portname) const
355 if (Port::connected_to (portname)) {
360 return _ext_port->connected_to (portname);
368 PortFacade::get_connections (vector<string>& names) const
373 i = _ext_port->get_connections (names);
376 i += Port::get_connections (names);