From bed58e9f372a6c2671e9f072c19a4c77d06c4292 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 14 Jan 2009 23:54:46 +0000 Subject: Make Bundles work a bit better. A few include optimisations. git-svn-id: svn://localhost/ardour2/branches/3.0@4408 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/auto_bundle.h | 4 -- libs/ardour/ardour/bundle.h | 82 +++++++++++++++++++++++++++++++--------- libs/ardour/ardour/io.h | 23 +++++------ libs/ardour/ardour/session.h | 3 +- libs/ardour/ardour/user_bundle.h | 28 +------------- 5 files changed, 76 insertions(+), 64 deletions(-) (limited to 'libs/ardour/ardour') diff --git a/libs/ardour/ardour/auto_bundle.h b/libs/ardour/ardour/auto_bundle.h index 9df26a449b..e3899069de 100644 --- a/libs/ardour/ardour/auto_bundle.h +++ b/libs/ardour/ardour/auto_bundle.h @@ -39,10 +39,6 @@ class AutoBundle : public Bundle { void set_port (uint32_t, std::string const &); private: - /// mutex for _ports; - /// XXX: is this necessary? - mutable Glib::Mutex _ports_mutex; - std::vector _ports; }; } diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 46ba13152e..1b029dc2b4 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -22,42 +22,69 @@ #include #include - #include "ardour/data_type.h" -#include "ardour/chan_count.h" namespace ARDOUR { - -typedef std::vector PortList; -/** - * A set of `channels', each of which is associated with 0 or more JACK ports. +/** A set of `channels', each of which is associated with 0 or more ports. + * 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 { +class Bundle : public sigc::trackable { public: - Bundle () : _type (DataType::AUDIO) {} - Bundle (bool i) : _type (DataType::AUDIO), _ports_are_inputs (i) {} + + /// List of ports associated with a channel. We can't use a + /// PortSet because we might want to involve non-Ardour ports + /// (ie those without a Port object) + typedef std::vector PortList; + + /** Construct an audio bundle. + * @param i true if ports are inputs, otherwise false. + */ + Bundle (bool i = true) : _type (DataType::AUDIO), _ports_are_inputs (i) {} + + /** Construct an audio bundle. + * @param n Name. + * @param i true if ports are inputs, otherwise false. + */ Bundle (std::string const & n, bool i = true) : _name (n), _type (DataType::AUDIO), _ports_are_inputs (i) {} virtual ~Bundle() {} - /** - * @return Number of channels that this Bundle has. - */ - virtual ChanCount nchannels () const = 0; - virtual const PortList& channel_ports (uint32_t) const = 0; + /** @return Number of channels that this Bundle has */ + uint32_t nchannels () const; + /** @param Channel index. + * @return Ports associated with this channel. + */ + PortList const & channel_ports (uint32_t) const; + + void add_channel (); + void add_port_to_channel (uint32_t, std::string); + void set_port (uint32_t, std::string); + void remove_port_from_channel (uint32_t, std::string); + void set_nchannels (uint32_t); + bool port_attached_to_channel (uint32_t, std::string); + void remove_channel (uint32_t); + + /** Set the name. + * @param n New name. + */ void set_name (std::string const & n) { _name = n; NameChanged (); } - - std::string name () const { return _name; } - sigc::signal NameChanged; + /** @return Bundle name */ + std::string name () const { return _name; } + /** Set the type of the ports in this Bundle. + * @param t New type. + */ void set_type (DataType t) { _type = t; } + + /** @return Type of the ports in this Bundle. */ DataType type () const { return _type; } void set_ports_are_inputs () { _ports_are_inputs = true; } @@ -65,7 +92,26 @@ class Bundle { bool ports_are_inputs () const { return _ports_are_inputs; } bool ports_are_outputs () const { return !_ports_are_inputs; } + bool operator== (Bundle const &) const; + + /** Emitted when the name changes */ + sigc::signal NameChanged; + /** The number of channels has changed */ + sigc::signal ConfigurationChanged; + /** The port list associated with one of our channels has changed */ + sigc::signal PortsChanged; + + protected: + + /// mutex for _ports; + /// XXX: is this necessary? + mutable Glib::Mutex _ports_mutex; + std::vector _ports; + private: + int set_channels (std::string const &); + int parse_io_string (std::string const &, std::vector &); + std::string _name; ARDOUR::DataType _type; bool _ports_are_inputs; diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index 69473b5747..a738519d57 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -42,7 +42,6 @@ #include #include #include -#include using std::string; using std::vector; @@ -54,7 +53,7 @@ namespace ARDOUR { class Session; class AudioEngine; class Bundle; -class AutoBundle; +class UserBundle; class Panner; class PeakMeter; class Port; @@ -131,8 +130,8 @@ class IO : public SessionObject, public AutomatableControls, public Latent std::vector > bundles_connected_to_inputs (); std::vector > bundles_connected_to_outputs (); - boost::shared_ptr bundle_for_inputs () { return _bundle_for_inputs; } - boost::shared_ptr bundle_for_outputs () { return _bundle_for_outputs; } + boost::shared_ptr bundle_for_inputs () { return _bundle_for_inputs; } + boost::shared_ptr bundle_for_outputs () { return _bundle_for_outputs; } int add_input_port (string source, void *src, DataType type = DataType::NIL); int add_output_port (string destination, void *src, DataType type = DataType::NIL); @@ -334,17 +333,15 @@ class IO : public SessionObject, public AutomatableControls, public Latent ChanCount _output_minimum; ///< minimum number of output channels (0 for no minimum) ChanCount _output_maximum; ///< maximum number of output channels (ChanCount::INFINITE for no maximum) - boost::shared_ptr _bundle_for_inputs; ///< a bundle representing our inputs - boost::shared_ptr _bundle_for_outputs; ///< a bundle representing our outputs + boost::shared_ptr _bundle_for_inputs; ///< a bundle representing our inputs + boost::shared_ptr _bundle_for_outputs; ///< a bundle representing our outputs struct UserBundleInfo { UserBundleInfo (IO*, boost::shared_ptr b); boost::shared_ptr bundle; - sigc::connection configuration_will_change; - sigc::connection configuration_has_changed; - sigc::connection ports_will_change; - sigc::connection ports_have_changed; + sigc::connection configuration_changed; + sigc::connection ports_changed; }; std::vector _bundles_connected_to_outputs; ///< user bundles connected to our outputs @@ -364,10 +361,8 @@ class IO : public SessionObject, public AutomatableControls, public Latent void check_bundles_connected_to_outputs (); void check_bundles (std::vector&, const PortSet&); - void bundle_configuration_will_change (); - void bundle_configuration_has_changed (); - void bundle_ports_will_change (int); - void bundle_ports_have_changed (int); + void bundle_configuration_changed (); + void bundle_ports_changed (int); int create_ports (const XMLNode&); int make_connections (const XMLNode&); diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 8b45dad958..2c173a9766 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -53,7 +53,7 @@ #include #include #include -#include +#include #include @@ -80,6 +80,7 @@ class AuxInput; class Source; class AudioSource; class BufferSet; +class IO; class Diskstream; class AudioDiskstream; diff --git a/libs/ardour/ardour/user_bundle.h b/libs/ardour/ardour/user_bundle.h index c33ddeaed9..6d197450c3 100644 --- a/libs/ardour/ardour/user_bundle.h +++ b/libs/ardour/ardour/user_bundle.h @@ -35,36 +35,10 @@ class UserBundle : public Bundle, public PBD::Stateful { UserBundle (std::string const &); UserBundle (XMLNode const &, bool); - ChanCount nchannels () const; - const ARDOUR::PortList& channel_ports (uint32_t) const; - - void add_channel (); - void set_channels (uint32_t); - void remove_channel (uint32_t); - void add_port_to_channel (uint32_t, std::string const &); - void remove_port_from_channel (uint32_t, std::string const &); - bool port_attached_to_channel (uint32_t, std::string const &) const; XMLNode& get_state (); - - /// The number of channels is about to change - sigc::signal ConfigurationWillChange; - /// The number of channels has changed - sigc::signal ConfigurationHasChanged; - /// The port set associated with one of our channels is about to change - /// Parameter is the channel number - sigc::signal PortsWillChange; - /// The port set associated with one of our channels has changed - /// Parameter is the channel number - sigc::signal PortsHaveChanged; private: - - int set_state (const XMLNode &); - - /// mutex for _ports; - /// XXX: is this necessary? - mutable Glib::Mutex _ports_mutex; - std::vector _ports; + int set_state (XMLNode const &); }; } -- cgit v1.2.3