2 Copyright (C) 2009 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__
26 #include <jack/jack.h>
27 #include <boost/utility.hpp>
28 #include <sigc++/trackable.h>
29 #include "ardour/data_type.h"
30 #include "ardour/types.h"
37 class Port : public sigc::trackable, public boost::noncopyable
41 IsInput = JackPortIsInput,
42 IsOutput = JackPortIsOutput,
47 /** @return Port short name */
48 std::string name () const {
52 int set_name (std::string const &);
55 Flags flags () const {
59 /** @return true if this Port receives input, otherwise false */
60 bool receives_input () const {
61 return _flags & IsInput;
64 /** @return true if this Port sends output, otherwise false */
65 bool sends_output () const {
66 return _flags & IsOutput;
69 bool connected () const;
70 int disconnect_all ();
71 int get_connections (std::vector<std::string> &) const;
73 /* connection by name */
74 bool connected_to (std::string const &) const;
75 int connect (std::string const &);
76 int disconnect (std::string const &);
78 /* connection by Port* */
79 bool connected_to (Port *) const;
80 virtual int connect (Port *);
81 int disconnect (Port *);
83 void ensure_monitor_input (bool);
84 bool monitoring_input () const;
85 nframes_t total_latency () const;
88 void request_monitor_input (bool);
89 void set_latency (nframes_t);
91 virtual void reset ();
93 virtual DataType type () const = 0;
94 virtual void cycle_start (nframes_t, nframes_t) = 0;
95 virtual void cycle_end (nframes_t, nframes_t) = 0;
96 virtual Buffer& get_buffer (nframes_t, nframes_t) = 0;
97 virtual void flush_buffers (nframes_t, nframes_t) {}
99 static void set_engine (AudioEngine *);
101 sigc::signal<void, bool> MonitorInputChanged;
105 Port (std::string const &, DataType, Flags);
107 jack_port_t* _jack_port; ///< JACK port
109 static AudioEngine* _engine; ///< the AudioEngine
112 friend class AudioEngine;
114 void recompute_total_latency () const;
119 std::string _name; ///< port short name
120 Flags _flags; ///< flags
122 /** ports that we are connected to, kept so that we can
123 reconnect to JACK when required */
124 std::set<std::string> _connections;
129 #endif /* __ardour_port_h__ */