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)
44 InternalPort::~InternalPort ()
50 InternalPort::set_latency (nframes_t val)
56 InternalPort::connected_to (const string& portname) const
58 /* caller must hold process lock */
60 for (list<InternalPort*>::const_iterator p = _connections.begin(); p != _connections.end(); ++p) {
61 if ((*p)->name() == portname) {
70 InternalPort::get_connections () const
72 /* caller must hold process lock */
75 list<InternalPort*>::const_iterator p;
77 if (_connections.empty()) {
81 char **names = (char**) malloc (sizeof (char*) * ( _connections.size() + 1));
84 for (i = 0, p = _connections.begin(); p != _connections.end(); ++p, ++i) {
85 names[i] = (char*) (*p)->name().c_str();
90 return (const char**) names;
94 InternalPort::connected() const
96 /* caller must hold process lock */
97 return !_connections.empty();
101 InternalPort::set_name (string str)
110 InternalPort::short_name ()
112 return _name.substr (9);
116 InternalPort::connect (InternalPort& src, InternalPort& dst)
118 /* caller must hold process lock */
120 src._connections.push_back (&dst);
121 dst._connections.push_back (&src);
125 InternalPort::disconnect (InternalPort& a, InternalPort& b)
127 /* caller must hold process lock */
128 a._connections.remove (&b);
129 b._connections.remove (&a);
133 InternalPort::disconnect ()
135 /* caller must hold process lock */
137 for (list<InternalPort*>::const_iterator p = _connections.begin(); p != _connections.end(); ) {
138 list<InternalPort*>::const_iterator tmp;
143 disconnect (*this, **p);
148 _connections.clear ();
154 InternalPort::reestablish ()
160 InternalPort::recompute_total_latency () const