summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour/port.h
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2009-01-21 02:27:21 +0000
committerCarl Hetherington <carl@carlh.net>2009-01-21 02:27:21 +0000
commitd6637dad5a239d74038fdf9e5800e5108ba0c44f (patch)
tree8371648bdc73dc98407c6924fefa00934e344902 /libs/ardour/ardour/port.h
parent4476461443061703e9ef268ade72511dff3e3ae5 (diff)
Rework Port class hierarchy a bit. Hopefully now simpler, and should
support connection of JACK ports with internal ones. git-svn-id: svn://localhost/ardour2/branches/3.0@4417 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/port.h')
-rw-r--r--libs/ardour/ardour/port.h191
1 files changed, 71 insertions, 120 deletions
diff --git a/libs/ardour/ardour/port.h b/libs/ardour/ardour/port.h
index 6bd607c334..cf62429db3 100644
--- a/libs/ardour/ardour/port.h
+++ b/libs/ardour/ardour/port.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2002 Paul Davis
+ Copyright (C) 2009 Paul Davis
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,167 +20,118 @@
#ifndef __ardour_port_h__
#define __ardour_port_h__
+#include "ardour/data_type.h"
+#include "ardour/types.h"
+#include <sigc++/trackable.h>
+#include <jack/jack.h>
+#include <string>
#include <set>
#include <vector>
-#include <string>
-#include <cstring>
-#include <sigc++/signal.h>
-#include <pbd/failed_constructor.h>
-#include <pbd/destructible.h>
-#include <ardour/ardour.h>
-#include <ardour/data_type.h>
-#include <jack/jack.h>
namespace ARDOUR {
class AudioEngine;
-class Buffer;
+class Buffer;
-/** Abstract base for ports
- */
-class Port : public virtual PBD::Destructible {
- public:
+class Port : public sigc::trackable
+{
+public:
enum Flags {
IsInput = JackPortIsInput,
IsOutput = JackPortIsOutput,
- IsPhysical = JackPortIsPhysical,
- IsTerminal = JackPortIsTerminal,
- CanMonitor = JackPortCanMonitor
};
- virtual ~Port();
+ virtual ~Port ();
- std::string name() const {
+ /** @return Port name (excluding prefix) */
+ std::string name () const {
return _name;
}
- Flags flags() const {
+ int set_name (std::string const &);
+
+ /** @return flags */
+ Flags flags () const {
return _flags;
}
- bool receives_input() const {
+ /** @return true if this Port receives input, otherwise false */
+ bool receives_input () const {
return _flags & IsInput;
}
+ /** @return true if this Port sends output, otherwise false */
bool sends_output () const {
return _flags & IsOutput;
}
- bool can_monitor () const {
- return _flags & CanMonitor;
- }
-
- void enable_metering() {
- _metering++;
- }
-
- void disable_metering () {
- if (_metering) { _metering--; }
+ /* @return true if this port is visible outside Ardour (via JACK) */
+ bool external () const {
+ return _jack_port != 0;
}
- virtual void cycle_start (nframes_t nframes, nframes_t offset) {}
- virtual void cycle_end (nframes_t nframes, nframes_t offset) {}
- virtual void flush_buffers (nframes_t nframes, nframes_t offset ) {}
- virtual DataType type() const = 0;
- virtual Buffer& get_buffer( nframes_t nframes, nframes_t offset ) = 0;
-
- virtual bool connected () const;
- virtual bool connected_to (const std::string& portname) const;
- virtual int get_connections (std::vector<std::string>&) const;
+ bool connected () const;
+ int disconnect_all ();
+ int get_connections (std::vector<std::string> &) const;
- virtual int connect (Port& other);
- virtual int disconnect (Port& other);
- virtual int disconnect_all ();
-
- virtual void reset ();
- virtual int reestablish () {return 0; }
- virtual int reconnect () { return 0; }
+ /* connection by name */
+ bool connected_to (std::string const &) const;
+ int connect (std::string const &);
+ int disconnect (std::string const &);
- virtual int set_name (const std::string& str) {
- _name = str;
- return 0;
- }
+ /* connection by Port* */
+ bool connected_to (Port *) const;
+ int connect (Port *);
+ int disconnect (Port *);
- virtual std::string short_name() const = 0;
- virtual bool monitoring_input () const = 0;
- virtual void ensure_monitor_input (bool yn) = 0;
- virtual void request_monitor_input (bool yn) = 0;
- virtual nframes_t latency () const = 0;
- virtual nframes_t total_latency () const = 0;
- virtual void set_latency (nframes_t nframes) = 0;
+ void ensure_monitor_input (bool);
+ bool monitoring_input () const;
+ nframes_t total_latency () const;
+ int reestablish ();
+ int reconnect ();
+ void set_latency (nframes_t);
+ void request_monitor_input (bool);
+ void make_external ();
- sigc::signal<void,bool> MonitorInputChanged;
- sigc::signal<void,bool> ClockSyncChanged;
+ virtual void reset ();
- static void set_engine (AudioEngine*);
+ virtual DataType type () const = 0;
+ virtual void cycle_start (nframes_t, nframes_t) = 0;
+ virtual void cycle_end (nframes_t, nframes_t) = 0;
+ virtual Buffer& get_buffer (nframes_t, nframes_t) = 0;
+ virtual void flush_buffers (nframes_t, nframes_t) {}
- protected:
- friend class AudioEngine;
+ static void set_engine (AudioEngine *);
- Port (const std::string& name, Flags flgs);
+ sigc::signal<void, bool> MonitorInputChanged;
- virtual void recompute_total_latency() const {}
+protected:
- /* engine isn't supposed to access below here */
-
- Flags _flags;
- std::string _type;
- std::string _name;
- unsigned short _metering;
- bool _last_monitor;
- nframes_t _latency;
-
- std::set<Port*> _connections;
-
- static AudioEngine* engine;
+ Port (std::string const &, DataType, Flags, bool);
- private:
+ jack_port_t* _jack_port; ///< JACK port, or 0 if we don't have one
+ std::set<Port*> _connections; ///< internal Ports that we are connected to
- void port_going_away (Port *);
-};
-
-class PortConnectableByName {
- public:
- PortConnectableByName() {}
- virtual ~PortConnectableByName() {}
-
- virtual int connect (const std::string& other_name) = 0;
- virtual int disconnect (const std::string& other_name) = 0;
-};
-
-class PortFacade : public virtual Port, public PortConnectableByName {
- public:
- PortFacade (const std::string& name, Flags flgs) : Port (name, flgs), _ext_port (0) {}
- ~PortFacade() {}
-
- void reset ();
- int reestablish ();
- int reconnect ();
+ static AudioEngine* _engine; ///< the AudioEngine
+
+private:
+ friend class AudioEngine;
- int connect (Port& other);
- int disconnect (Port& other);
- int disconnect_all ();
+ void recompute_total_latency () const;
+ void do_make_external (DataType);
+
+ /* XXX */
+ bool _last_monitor;
+ nframes_t _latency;
- int connect (const std::string& other_name);
- int disconnect (const std::string& other_name);
+ std::string _name; ///< port name (excluding prefix)
+ Flags _flags; ///< flags
- bool connected () const;
- bool connected_to (const std::string& portname) const;
- int get_connections (std::vector<std::string>&) const;
-
- std::string short_name() const;
- int set_name (const std::string& str);
- bool monitoring_input () const;
- void ensure_monitor_input (bool yn);
- void request_monitor_input (bool yn);
- nframes_t latency () const;
- nframes_t total_latency () const;
- void set_latency (nframes_t nframes);
-
- protected:
- Port* _ext_port;
+ /// list of JACK ports that we are connected to; we only keep this around
+ /// so that we can implement ::reconnect ()
+ std::set<std::string> _named_connections;
};
-} // namespace ARDOUR
+}
-#endif /* __ardour_port_h__ */
+#endif