2 Copyright (C) 2007 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 <pbd/error.h>
21 #include <ardour/internal_port.h>
22 #include <ardour/audioengine.h>
26 using namespace ARDOUR;
29 AudioEngine* InternalPort::engine = 0;
32 InternalPort::set_engine (AudioEngine* e)
37 InternalPort::InternalPort (const string& str, DataType type, Flags flags)
43 InternalPort::~InternalPort ()
49 InternalPort::set_latency (nframes_t val)
55 InternalPort::connected_to (const string& portname) const
57 /* caller must hold process lock */
59 for (list<InternalPort*>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) {
60 if ((*p)->name() == portname) {
69 InternalPort::get_connections () const
71 /* caller must hold process lock */
74 list<InternalPort*>::const_iterator p;
76 if (_connections.empty()) {
80 char **names = (char**) malloc (sizeof (char*) * ( _connections.size() + 1));
83 for (i = 0, p = _connections.begin(); p != _connections.end(); ++p, ++i) {
84 names[i] = (char*) (*p)->name().c_str();
89 return (const char**) names;
93 InternalPort::connected() const
95 /* caller must hold process lock */
96 return !_connections.empty();
100 InternalPort::set_name (string str)
109 InternalPort::short_name ()
111 return _name.substr (9);
115 InternalPort::connect (InternalPort& src, InternalPort& dst)
117 /* caller must hold process lock */
119 src._connections.push_back (&dst);
120 dst._connections.push_back (&src);
124 InternalPort::disconnect (InternalPort& a, InternalPort& b)
126 /* caller must hold process lock */
127 a._connections.remove (&b);
128 b._connections.remove (&a);
132 InternalPort::disconnect ()
134 /* caller must hold process lock */
136 for (list<InternalPort*>::const_iterator p = _connections.begin(); p != _connections.end(); ) {
137 list<InternalPort*>::const_iterator tmp;
142 disconnect (*this, **p);
147 _connections.clear ();
153 InternalPort::reestablish ()
159 InternalPort::recompute_total_latency () const