diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-07 10:18:16 -0600 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2020-04-07 13:23:49 -0600 |
commit | b9cb306e8b9a330ec5211ccdfde6b90f17701099 (patch) | |
tree | 4e3e2d90fe9d0747a06e08c8bfd099fc275c07b4 /libs/ardour/ardour/port_engine.h | |
parent | 1eb98316a3467c94842f6b6ba21eaf4470760880 (diff) |
use shared_ptr to manage backend port lifetimes (Pulse,ALSA,Dummy,JACK)
JACK is not yet finished.
Changes also include minor reformatting and a spelling correction (latecies to latencies)
Diffstat (limited to 'libs/ardour/ardour/port_engine.h')
-rw-r--r-- | libs/ardour/ardour/port_engine.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/libs/ardour/ardour/port_engine.h b/libs/ardour/ardour/port_engine.h index 483206578a..056b70f31b 100644 --- a/libs/ardour/ardour/port_engine.h +++ b/libs/ardour/ardour/port_engine.h @@ -75,6 +75,12 @@ class PortManager; * documentation, on which this entire object is based. */ +class LIBARDOUR_API ProtoPort { + public: + ProtoPort() {} + virtual ~ProtoPort () {} +}; + class LIBARDOUR_API PortEngine { public: @@ -88,14 +94,24 @@ public: /** Opaque handle to use as reference for Ports * - * We use void* here so that the API can be defined for any implementation. + * The handle needs to be lifetime managed (i.e. a shared_ptr type) + * in order to allow RCU to provide lock-free cross-thread operations + * on ports and ports containers. * * We could theoretically use a template (PortEngine\<T\>) and define * PortHandle as T, but this complicates the desired inheritance * pattern in which FooPortEngine handles things for the Foo API, * rather than being a derivative of PortEngine\<Foo\>. + * + * We use this to declare return values and members of structures. + */ + typedef boost::shared_ptr<ProtoPort> PortPtr; + + /* We use this to declare arguments to methods/functions, in order to + * avoid copying shared_ptr<ProtoPort> every time (a practice we use in + * other contexts where we pass shared_ptr<T>). */ - typedef void* PortHandle; + typedef PortPtr const & PortHandle; /** Return the name of this process as used by the port manager * when naming ports. @@ -164,7 +180,7 @@ public: * @param name Full port-name to lookup * @return PortHandle if lookup was successful, or an "empty" PortHandle (analogous to a null pointer) if no such port exists. */ - virtual PortHandle get_port_by_name (const std::string& name) const = 0; + virtual PortPtr get_port_by_name (const std::string& name) const = 0; /** Find the set of ports whose names, types and flags match * specified values, place the names of each port into \p ports . @@ -194,7 +210,7 @@ public: * @param flags flags of the port to create * @return a reference to the port, otherwise return a null pointer. */ - virtual PortHandle register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags) = 0; + virtual PortPtr register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags) = 0; /* Destroy the port referred to by \p port, including all resources * associated with it. This will also disconnect \p port from any ports it @@ -202,7 +218,7 @@ public: * * @param port \ref PortHandle of the port to destroy */ - virtual void unregister_port (PortHandle port) = 0; + virtual void unregister_port (PortHandle port) = 0; /* Connection management */ |