X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fbundle.h;h=a84ae624f6e0f7062ba1b347f8b4267a6966cf31;hb=7a524285385d4581ad3f1e085629379e32f82fda;hp=1af7a3bad0e979bf07ae1fc0442317e9667ba7d3;hpb=dbb0b9ca4f82ea8e3829cfeb009b9746c3d6f0dc;p=ardour.git diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 1af7a3bad0..a84ae624f6 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -22,22 +22,25 @@ #include #include -#include -#include +#include #include + +#include "pbd/signals.h" + #include "ardour/data_type.h" +#include "ardour/chan_count.h" namespace ARDOUR { class AudioEngine; /** A set of `channels', each of which is associated with 0 or more ports. - * Each channel has a name which can be anything useful. + * Each channel has a name which can be anything useful, and a data type. * Intended for grouping things like, for example, a buss' outputs. * `Channel' is a rather overloaded term but I can't think of a better * one right now. */ -class Bundle : public sigc::trackable +class LIBARDOUR_API Bundle : public PBD::ScopedConnectionList { public: @@ -47,33 +50,41 @@ class Bundle : public sigc::trackable typedef std::vector PortList; struct Channel { - Channel (std::string n) : name (n) {} + Channel (std::string n, DataType t) : name (n), type (t) {} + Channel (std::string n, DataType t, PortList p) : name (n), type (t), ports (p) {} + Channel (std::string n, DataType t, std::string const & p) : name (n), type (t) { + ports.push_back (p); + } bool operator== (Channel const &o) const { - return name == o.name && ports == o.ports; + return name == o.name && type == o.type && ports == o.ports; } std::string name; + DataType type; PortList ports; }; Bundle (bool i = true); Bundle (std::string const &, bool i = true); - Bundle (std::string const &, DataType, bool i = true); Bundle (boost::shared_ptr); virtual ~Bundle() {} /** @return Number of channels that this Bundle has */ - uint32_t nchannels () const; + ChanCount nchannels () const; + uint32_t n_total () const; /* shortcut for nchannels().n_total() */ /** @param Channel index. * @return Ports associated with this channel. */ PortList const & channel_ports (uint32_t) const; - void add_channel (std::string const &); + void add_channel (std::string const &, DataType); + void add_channel (std::string const &, DataType, std::string const &); + void add_channel (std::string const &, DataType, PortList); std::string channel_name (uint32_t) const; + DataType channel_type (uint32_t) const; void set_channel_name (uint32_t, std::string const &); void add_port_to_channel (uint32_t, std::string); void set_port (uint32_t, std::string); @@ -81,26 +92,27 @@ class Bundle : public sigc::trackable void remove_ports_from_channel (uint32_t); void remove_ports_from_channels (); bool port_attached_to_channel (uint32_t, std::string); - bool uses_port (std::string) const; + bool offers_port (std::string) const; bool offers_port_alone (std::string) const; void remove_channel (uint32_t); void remove_channels (); void add_channels_from_bundle (boost::shared_ptr); - void connect (boost::shared_ptr, AudioEngine &); + void connect (boost::shared_ptr, AudioEngine &, + bool allow_partial = false); void disconnect (boost::shared_ptr, AudioEngine &); - bool connected_to (boost::shared_ptr, AudioEngine &); + bool connected_to (boost::shared_ptr, AudioEngine &, + DataType type = DataType::NIL, + bool exclusive = false); + bool connected_to_anything (AudioEngine &); bool has_same_ports (boost::shared_ptr) const; + uint32_t type_channel_to_overall (DataType, uint32_t) const; + uint32_t overall_channel_to_type (DataType, uint32_t) const; void set_name (std::string const &); /** @return Bundle name */ std::string name () const { return _name; } - void set_type (DataType); - - /** @return Type of the ports in this Bundle. */ - DataType type () const { return _type; } - void set_ports_are_inputs (); void set_ports_are_outputs (); bool ports_are_inputs () const { return _ports_are_inputs; } @@ -109,6 +121,8 @@ class Bundle : public sigc::trackable void suspend_signals (); void resume_signals (); + bool operator== (Bundle const & other); + /** Things that might change about this bundle */ enum Change { NameChanged = 0x1, ///< the bundle name or a channel name has changed @@ -118,13 +132,13 @@ class Bundle : public sigc::trackable DirectionChanged = 0x10 ///< the direction (whether ports are inputs or outputs) has changed }; - sigc::signal Changed; + PBD::Signal1 Changed; protected: /// mutex for _channel_ports and _channel_names /// XXX: is this necessary? - mutable Glib::Mutex _channel_mutex; + mutable Glib::Threads::Mutex _channel_mutex; std::vector _channel; private: @@ -133,20 +147,18 @@ class Bundle : public sigc::trackable void emit_changed (Change); std::string _name; - DataType _type; bool _ports_are_inputs; bool _signals_suspended; Change _pending_change; }; - - -struct BundleChannel +class LIBARDOUR_API BundleChannel { - BundleChannel () : channel (0) {} +public: + BundleChannel () : channel (-1) {} - BundleChannel (boost::shared_ptr b, uint32_t c) + BundleChannel (boost::shared_ptr b, int c) : bundle (b), channel (c) {} bool operator== (BundleChannel const& other) const { @@ -158,9 +170,11 @@ struct BundleChannel } boost::shared_ptr bundle; - uint32_t channel; + int channel; ///< channel index, or -1 for "all" }; } +std::ostream & operator<< (std::ostream & o, ARDOUR::Bundle const &); + #endif /* __ardour_bundle_h__ */