2 Copyright (C) 2002 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.
21 #ifndef __ardour_port_h__
22 #define __ardour_port_h__
24 #include <sigc++/signal.h>
25 #include <pbd/failed_constructor.h>
26 #include <ardour/ardour.h>
27 #include <ardour/data_type.h>
28 #include <jack/jack.h>
35 /** Abstract base for all outside ports (eg Jack ports)
37 class Port : public sigc::trackable {
43 virtual DataType type() const = 0;
45 virtual void cycle_start(jack_nframes_t nframes) {}
46 virtual void cycle_end() {}
48 virtual Buffer& get_buffer() = 0;
50 std::string name() const {
54 std::string short_name() {
55 return jack_port_short_name (_port);
58 int set_name (std::string str);
60 JackPortFlags flags() const {
64 bool is_mine (jack_client_t *client) {
65 return jack_port_is_mine (client, _port);
68 int connected () const {
69 return jack_port_connected (_port);
72 bool connected_to (const std::string& portname) const {
73 return jack_port_connected_to (_port, portname.c_str());
76 const char ** get_connections () const {
77 return jack_port_get_connections (_port);
80 bool receives_input() const {
81 return _flags & JackPortIsInput;
84 bool sends_output () const {
85 return _flags & JackPortIsOutput;
88 bool monitoring_input () const {
89 return jack_port_monitoring_input (_port);
92 bool can_monitor () const {
93 return _flags & JackPortCanMonitor;
96 void enable_metering() {
100 void disable_metering () {
101 if (_metering) { _metering--; }
104 void ensure_monitor_input (bool yn) {
106 #ifdef HAVE_JACK_PORT_ENSURE_MONITOR
107 jack_port_ensure_monitor (_port, yn);
109 jack_port_request_monitor(_port, yn);
114 /*XXX completely bloody useless imho*/
115 void request_monitor_input (bool yn) {
116 jack_port_request_monitor (_port, yn);
119 nframes_t latency () const {
120 return jack_port_get_latency (_port);
123 void set_latency (nframes_t nframes) {
124 jack_port_set_latency (_port, nframes);
127 sigc::signal<void,bool> MonitorInputChanged;
128 sigc::signal<void,bool> ClockSyncChanged;
131 friend class AudioEngine;
133 Port (jack_port_t *port);
135 virtual void reset ();
137 /* engine isn't supposed to access below here */
139 /* cache these 3 from JACK so we can access them for reconnecting */
140 JackPortFlags _flags;
146 unsigned short _metering;
148 bool _last_monitor : 1;
151 } // namespace ARDOUR
153 #endif /* __ardour_port_h__ */