Make Bundles work a bit better. A few include optimisations.
authorCarl Hetherington <carl@carlh.net>
Wed, 14 Jan 2009 23:54:46 +0000 (23:54 +0000)
committerCarl Hetherington <carl@carlh.net>
Wed, 14 Jan 2009 23:54:46 +0000 (23:54 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@4408 d708f5d6-7413-0410-9779-e7cbd77b26cf

21 files changed:
gtk2_ardour/ardour_ui.h
gtk2_ardour/automation_controller.cc
gtk2_ardour/bundle_manager.cc
gtk2_ardour/mixer_strip.cc
libs/ardour/SConscript
libs/ardour/ardour/auto_bundle.h
libs/ardour/ardour/bundle.h
libs/ardour/ardour/io.h
libs/ardour/ardour/session.h
libs/ardour/ardour/user_bundle.h
libs/ardour/audioengine.cc
libs/ardour/audiosource.cc
libs/ardour/bundle.cc
libs/ardour/io.cc
libs/ardour/ladspa_plugin.cc
libs/ardour/meter.cc
libs/ardour/panner.cc
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/ardour/user_bundle.cc
libs/surfaces/mackie/mackie_control_protocol.h

index baa8224cf8c2408daf7a133d5c156e7dafab8aa5..5bb8691ac4cc434b43c1552e4e57349a0c34f650 100644 (file)
@@ -37,6 +37,7 @@
 #include <libgnomecanvasmm/canvas.h>
 
 #include <pbd/xml++.h>
+#include <pbd/controllable.h>
 #include <gtkmm/box.h>
 #include <gtkmm/frame.h>
 #include <gtkmm/label.h>
index c9e04bf70b7d521c3116eac7b8c63e71368a1694..6f62608f0a8c789f067a3bc1ae897841c1bd15f1 100644 (file)
@@ -21,6 +21,8 @@
 #include <pbd/error.h>
 #include "ardour/automation_list.h"
 #include "ardour/automation_control.h"
+#include "ardour/event_type_map.h"
+#include "ardour/automatable.h"
 #include "ardour_ui.h"
 #include "utils.h"
 #include "automation_controller.h"
index 916413d8359c75ec36f9a5bf31c2e0b1c30f00e1..e4e848557e1b45ea7dcde8c897d16dfc3c0bb182 100644 (file)
@@ -61,7 +61,7 @@ BundleEditorMatrix::get_state (int r, std::string const & p) const
 uint32_t
 BundleEditorMatrix::n_rows () const
 {
-       return _bundle->nchannels ().n_total();
+       return _bundle->nchannels ();
 }
 
 uint32_t
index 6c006d7e249e3b0e752ffb71daccf551d4a62a77..6f591bc6c0059567a959dde3fead2880a1f8be76 100644 (file)
@@ -43,7 +43,6 @@
 #include <ardour/processor.h>
 #include <ardour/profile.h>
 #include <ardour/ladspa_plugin.h>
-#include <ardour/auto_bundle.h>
 #include <ardour/user_bundle.h>
 
 #include "ardour_ui.h"
@@ -758,7 +757,7 @@ MixerStrip::add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, std::vector<b
 
        MenuList& citems = input_menu.items();
        
-       if (b->nchannels() == _route->n_inputs()) {
+       if (b->nchannels() == _route->n_inputs().get (b->type ())) {
 
                citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_input_chosen), b)));
 
@@ -781,7 +780,7 @@ MixerStrip::add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, std::vector<
                return;
        }
 
-       if (b->nchannels() == _route->n_outputs()) {
+       if (b->nchannels() == _route->n_outputs().get (b->type ())) {
 
                MenuList& citems = output_menu.items();
                citems.push_back (CheckMenuElem (b->name(), bind (mem_fun(*this, &MixerStrip::bundle_output_chosen), b)));
index ac66d95b6fb086705ea04548967ef0c2b3d2bd7a..58db70c6a6ead15378de3213cd43fbddedaa4225 100644 (file)
@@ -48,7 +48,6 @@ audioregion.cc
 audio_region_importer.cc
 audiosource.cc
 auditioner.cc
-auto_bundle.cc
 automatable.cc
 automation.cc
 automation_control.cc
@@ -58,6 +57,7 @@ base_midi_port.cc
 broadcast_info.cc
 buffer.cc
 buffer_set.cc
+bundle.cc
 chan_count.cc
 configuration.cc
 control_protocol_manager.cc
index 9df26a449b359ad58e5f9a3587716b271ccbbe89..e3899069dea1b054e1f28decb5c91f4e3469f096 100644 (file)
@@ -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<PortList> _ports;
 };
 
 }      
index 46ba13152e689d45acd724f5ca76102c49be735a..1b029dc2b4584d68a4e67c003224e5954bcc9e49 100644 (file)
 
 #include <string>
 #include <sigc++/signal.h>
-
 #include "ardour/data_type.h"
-#include "ardour/chan_count.h"
 
 namespace ARDOUR {
-
-typedef std::vector<std::string> 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<std::string> 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<void> 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<void> NameChanged;
+       /** The number of channels has changed */
+       sigc::signal<void> ConfigurationChanged;
+       /** The port list associated with one of our channels has changed */
+       sigc::signal<void, int> PortsChanged;
+
+  protected:
+       
+       /// mutex for _ports;
+       /// XXX: is this necessary?
+       mutable Glib::Mutex _ports_mutex;
+       std::vector<PortList> _ports;
+
   private:
+       int set_channels (std::string const &);
+       int parse_io_string (std::string const &, std::vector<std::string> &);
+       
        std::string _name;
        ARDOUR::DataType _type;
        bool _ports_are_inputs;
index 69473b57479f406c2467ea2b2869ff028ade8c49..a738519d57256fbfd8f35ff7f32fe454e8f4ccb7 100644 (file)
@@ -42,7 +42,6 @@
 #include <ardour/chan_count.h>
 #include <ardour/latent.h>
 #include <ardour/automation_control.h>
-#include <ardour/user_bundle.h>
 
 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<boost::shared_ptr<Bundle> > bundles_connected_to_inputs ();
        std::vector<boost::shared_ptr<Bundle> > bundles_connected_to_outputs ();
 
-        boost::shared_ptr<AutoBundle> bundle_for_inputs () { return _bundle_for_inputs; }
-        boost::shared_ptr<AutoBundle> bundle_for_outputs () { return _bundle_for_outputs; }
+        boost::shared_ptr<Bundle> bundle_for_inputs () { return _bundle_for_inputs; }
+        boost::shared_ptr<Bundle> 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<AutoBundle> _bundle_for_inputs; ///< a bundle representing our inputs
-       boost::shared_ptr<AutoBundle> _bundle_for_outputs; ///< a bundle representing our outputs
+       boost::shared_ptr<Bundle> _bundle_for_inputs; ///< a bundle representing our inputs
+       boost::shared_ptr<Bundle> _bundle_for_outputs; ///< a bundle representing our outputs
 
        struct UserBundleInfo {
                UserBundleInfo (IO*, boost::shared_ptr<UserBundle> b);
                
                boost::shared_ptr<UserBundle> 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<UserBundleInfo> _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<UserBundleInfo>&, 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&);
index 8b45dad958c48e61435c1c49e8fc0842d3cbf473..2c173a97661210d29dbeec00a50e386b81d55a42 100644 (file)
@@ -53,7 +53,7 @@
 #include <ardour/configuration.h>
 #include <ardour/location.h>
 #include <ardour/gain.h>
-#include <ardour/io.h>
+#include <ardour/chan_count.h>
 
 #include <ardour/smpte.h>
 
@@ -80,6 +80,7 @@ class AuxInput;
 class Source;
 class AudioSource;
 class BufferSet;
+class IO;
 
 class Diskstream;
 class AudioDiskstream;
index c33ddeaed9ba5e1cf1bc836f24003dea17e1f73a..6d197450c3f038f488309937dc0ba95dfd3d1063 100644 (file)
@@ -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<void> ConfigurationWillChange;
-       /// The number of channels has changed
-       sigc::signal<void> ConfigurationHasChanged;
-       /// The port set associated with one of our channels is about to change
-       /// Parameter is the channel number
-       sigc::signal<void, int> PortsWillChange;
-       /// The port set associated with one of our channels has changed
-       /// Parameter is the channel number
-       sigc::signal<void, int> PortsHaveChanged;
        
   private:
-
-       int set_state (const XMLNode &);
-
-       /// mutex for _ports;
-       /// XXX: is this necessary?
-       mutable Glib::Mutex _ports_mutex; 
-       std::vector<PortList> _ports;
+       int set_state (XMLNode const &);
 };
 
 }
index 2c9ce67917ee281b92446a4e11dcc2bfd949425f..0c36db6b01e5969233f887bf9483b92aa3f81479 100644 (file)
 #include <ardour/port.h>
 #include <ardour/jack_audio_port.h>
 #include <ardour/jack_midi_port.h>
+#include <ardour/midi_port.h>
 #include <ardour/audio_port.h>
 #include <ardour/session.h>
 #include <ardour/cycle_timer.h>
 #include <ardour/utils.h>
+#include <ardour/event_type_map.h>
+#include <ardour/io.h>
 #ifdef VST_SUPPORT
 #include <fst.h>
 #endif
index b8366e0ac038a70e1d92e8fed326b57ed7a93cde..8d710b247a0bb496d042d7c9f3fe2214da2c6c57 100644 (file)
@@ -41,6 +41,7 @@
 #include <ardour/cycle_timer.h>
 #include <ardour/session.h>
 #include <ardour/transient_detector.h>
+#include <ardour/runtime_functions.h>
 
 #include "i18n.h"
 
index 0d8c36a84f4fffec9b921e3e5861358c6f9fc98e..bdad9d364da0141eaa0faeefd215ae63d6feef01 100644 (file)
 using namespace ARDOUR;
 using namespace PBD;
 
-/** Construct a Bundle from an XML node.
- * @param node XML node.
- */
-Bundle::Bundle (const XMLNode& node)
+uint32_t
+Bundle::nchannels () const
 {
-       if (set_state (node)) {
-               throw failed_constructor();
-       }
+       Glib::Mutex::Lock lm (_ports_mutex);
+       return _ports.size ();
 }
 
-/** Construct an InputBundle from an XML node.
- * @param node XML node.
- */
-InputBundle::InputBundle (const XMLNode& node)
-       : Bundle (node)
+Bundle::PortList const &
+Bundle::channel_ports (uint32_t c) const
 {
-  
-}
+       assert (c < nchannels());
 
-/** Construct an OutputBundle from an XML node.
- * @param node XML node.
- */
-OutputBundle::OutputBundle (const XMLNode& node)
-       : Bundle (node)
-{
-  
+       Glib::Mutex::Lock lm (_ports_mutex);
+       return _ports[c];
 }
 
-/** Set the name.
- * @param name New name.
+/** Add an association between one of our channels and a port.
+ *  @param ch Channel index.
+ *  @param portname port name to associate with.
  */
 void
-Bundle::set_name (string name, void *src)
+Bundle::add_port_to_channel (uint32_t ch, string portname)
 {
-       _name = name;
-       NameChanged (src);
-}
+       assert (ch < nchannels());
 
-/** Add an association between one of our channels and a JACK port.
- * @param ch Channel index.
- * @param portname JACK port name to associate with.
- */
-void
-Bundle::add_port_to_channel (int ch, string portname)
-{
        {
-               Glib::Mutex::Lock lm (channels_lock);
-               _channels[ch].push_back (portname);
+               Glib::Mutex::Lock lm (_ports_mutex);
+               _ports[ch].push_back (portname);
        }
        
        PortsChanged (ch); /* EMIT SIGNAL */
 }
 
-/** Disassociate a JACK port from one of our channels.
- * @param ch Channel index.
- * @param portname JACK port name to disassociate from.
+/** Disassociate a port from one of our channels.
+ *  @param ch Channel index.
+ *  @param portname port name to disassociate from.
  */
-
 void
-Bundle::remove_port_from_channel (int ch, string portname)
+Bundle::remove_port_from_channel (uint32_t ch, string portname)
 {
+       assert (ch < nchannels());
+
        bool changed = false;
 
        {
-               Glib::Mutex::Lock lm (channels_lock);
-               PortList& pl = _channels[ch];
+               Glib::Mutex::Lock lm (_ports_mutex);
+               PortList& pl = _ports[ch];
                PortList::iterator i = find (pl.begin(), pl.end(), portname);
                
                if (i != pl.end()) {
@@ -108,24 +89,13 @@ Bundle::remove_port_from_channel (int ch, string portname)
        }
 }
 
-/**
- * @param ch Channel index.
- * @return List of JACK ports that this channel is connected to.
- */
-const Bundle::PortList&
-Bundle::channel_ports (int ch) const
-{
-       Glib::Mutex::Lock lm (channels_lock);
-       return _channels[ch];
-}
-
 /** operator== for Bundles; they are equal if their channels are the same.
  * @param other Bundle to compare with this one.
  */
 bool
 Bundle::operator== (const Bundle& other) const
 {
-       return other._channels == _channels;
+       return other._ports == _ports;
 }
 
 
@@ -134,149 +104,58 @@ Bundle::operator== (const Bundle& other) const
  */
 
 void
-Bundle::set_nchannels (int n)
+Bundle::set_nchannels (uint32_t n)
 {
        {
-               Glib::Mutex::Lock lm (channels_lock);
-               _channels.clear ();
-               for (int i = 0; i < n; ++i) {
-                       _channels.push_back (PortList());
+               Glib::Mutex::Lock lm (_ports_mutex);
+               _ports.clear ();
+               for (uint32_t i = 0; i < n; ++i) {
+                       _ports.push_back (PortList());
                }
        }
 
        ConfigurationChanged (); /* EMIT SIGNAL */
 }
 
-XMLNode&
-Bundle::get_state ()
+void
+Bundle::set_port (uint32_t ch, string portname)
 {
-       XMLNode *node;
-       string str;
-
-       if (dynamic_cast<InputBundle *> (this)) {
-               node = new XMLNode ("InputConnection");
-       } else {
-               node = new XMLNode ("OutputConnection");
-       }
+       assert (ch < nchannels());
 
-       node->add_property ("name", _name);
-
-       for (vector<PortList>::iterator i = _channels.begin(); i != _channels.end(); ++i) {
-
-               str += '{';
-
-               for (vector<string>::iterator ii = (*i).begin(); ii != (*i).end(); ++ii) {
-                       if (ii != (*i).begin()) {
-                               str += ',';
-                       }
-                       str += *ii;
-               }
-               str += '}';
+       {
+               Glib::Mutex::Lock lm (_ports_mutex);
+               _ports[ch].clear ();
+               _ports[ch].push_back (portname);
        }
 
-       node->add_property ("connections", str);
-
-       return *node;
+       PortsChanged (ch); /* EMIT SIGNAL */
 }
 
-int
-Bundle::set_state (const XMLNode& node)
+void
+Bundle::add_channel ()
 {
-       const XMLProperty *prop;
-
-       if ((prop = node.property ("name")) == 0) {
-               error << _("Node for Connection has no \"name\" property") << endmsg;
-               return -1;
-       }
-
-       _name = prop->value();
-       _dynamic = false;
-       
-       if ((prop = node.property ("connections")) == 0) {
-               error << _("Node for Connection has no \"connections\" property") << endmsg;
-               return -1;
+       {
+               Glib::Mutex::Lock lm (_ports_mutex);
+               _ports.push_back (PortList ());
        }
-       
-       set_channels (prop->value());
 
-       return 0;
+       ConfigurationChanged (); /* EMIT SIGNAL */
 }
 
-/** Set up channels from an XML property string.
- * @param str String.
- * @return 0 on success, -1 on error.
- */
-int
-Bundle::set_channels (const string& str)
+bool
+Bundle::port_attached_to_channel (uint32_t ch, std::string portname)
 {
-       vector<string> ports;
-       int i;
-       int n;
-       int nchannels;
+       assert (ch < nchannels());
        
-       if ((nchannels = count (str.begin(), str.end(), '{')) == 0) {
-               return 0;
-       }
-
-       set_nchannels (nchannels);
-
-       string::size_type start, end, ostart;
-
-       ostart = 0;
-       start = 0;
-       end = 0;
-       i = 0;
-
-       while ((start = str.find_first_of ('{', ostart)) != string::npos) {
-               start += 1;
-
-               if ((end = str.find_first_of ('}', start)) == string::npos) {
-                       error << string_compose(_("IO: badly formed string in XML node for inputs \"%1\""), str) << endmsg;
-                       return -1;
-               }
-
-               if ((n = parse_io_string (str.substr (start, end - start), ports)) < 0) {
-                       error << string_compose(_("bad input string in XML node \"%1\""), str) << endmsg;
-
-                       return -1;
-                       
-               } else if (n > 0) {
-
-                       for (int x = 0; x < n; ++x) {
-                               add_port_to_channel (i, ports[x]);
-                       }
-               }
-
-               ostart = end+1;
-               i++;
-       }
-
-       return 0;
+       Glib::Mutex::Lock lm (_ports_mutex);
+       return (std::find (_ports[ch].begin (), _ports[ch].end (), portname) != _ports[ch].end ());
 }
 
-int
-Bundle::parse_io_string (const string& str, vector<string>& ports)
+void
+Bundle::remove_channel (uint32_t ch)
 {
-       string::size_type pos, opos;
-
-       if (str.length() == 0) {
-               return 0;
-       }
+       assert (ch < nchannels ());
 
-       pos = 0;
-       opos = 0;
-
-       ports.clear ();
-
-       while ((pos = str.find_first_of (',', opos)) != string::npos) {
-               ports.push_back (str.substr (opos, pos - opos));
-               opos = pos + 1;
-       }
-       
-       if (opos < str.length()) {
-               ports.push_back (str.substr(opos));
-       }
-
-       return ports.size();
+       Glib::Mutex::Lock lm (_ports_mutex);
+       _ports.erase (_ports.begin () + ch);
 }
-
index 66023f1f4d67979995e0a5efd2675c58d89a286e..ed1064f0e858575a8ef3bb184a085aa35abefa1c 100644 (file)
 #include <ardour/port.h>
 #include <ardour/audio_port.h>
 #include <ardour/midi_port.h>
-#include <ardour/auto_bundle.h>
 #include <ardour/session.h>
 #include <ardour/cycle_timer.h>
 #include <ardour/panner.h>
 #include <ardour/buffer_set.h>
 #include <ardour/meter.h>
 #include <ardour/amp.h>
+#include <ardour/user_bundle.h>
 
 #include "i18n.h"
 
@@ -360,18 +360,17 @@ IO::check_bundles (std::vector<UserBundleInfo>& list, const PortSet& ports)
        
        for (std::vector<UserBundleInfo>::iterator i = list.begin(); i != list.end(); ++i) {
 
-               ChanCount const N = i->bundle->nchannels ();
+               uint32_t const N = i->bundle->nchannels ();
 
-               if (ports.num_ports (default_type()) < N.get (default_type())) {
+               if (ports.num_ports (default_type()) < N) {
                        continue;
                }
 
                bool ok = true;
-               uint32_t n = N.get (default_type());
 
-               for (uint32_t j = 0; j < n; ++j) {
+               for (uint32_t j = 0; j < N; ++j) {
                        /* Every port on bundle channel j must be connected to our input j */
-                       PortList const pl = i->bundle->channel_ports (j);
+                       Bundle::PortList const pl = i->bundle->channel_ports (j);
                        for (uint32_t k = 0; k < pl.size(); ++k) {
                                if (ports.port(j)->connected_to (pl[k]) == false) {
                                        ok = false;
@@ -387,10 +386,8 @@ IO::check_bundles (std::vector<UserBundleInfo>& list, const PortSet& ports)
                if (ok) {
                        new_list.push_back (*i);
                } else {
-                       i->configuration_will_change.disconnect ();
-                       i->configuration_has_changed.disconnect ();
-                       i->ports_will_change.disconnect ();
-                       i->ports_have_changed.disconnect ();
+                       i->configuration_changed.disconnect ();
+                       i->ports_changed.disconnect ();
                }
        }
 
@@ -1681,8 +1678,8 @@ int
 IO::create_ports (const XMLNode& node)
 {
        XMLProperty const * prop;
-       ChanCount num_inputs;
-       ChanCount num_outputs;
+       uint32_t num_inputs = 0;
+       uint32_t num_outputs = 0;
 
        if ((prop = node.property ("input-connection")) != 0) {
 
@@ -1696,7 +1693,7 @@ IO::create_ports (const XMLNode& node)
 
        } else if ((prop = node.property ("inputs")) != 0) {
 
-               num_inputs.set (default_type(), count (prop->value().begin(), prop->value().end(), '{'));
+               num_inputs = count (prop->value().begin(), prop->value().end(), '{');
        }
        
        if ((prop = node.property ("output-connection")) != 0) {
@@ -1711,12 +1708,15 @@ IO::create_ports (const XMLNode& node)
                
        } else if ((prop = node.property ("outputs")) != 0) {
 
-               num_outputs.set (default_type(), count (prop->value().begin(), prop->value().end(), '{'));
+               num_outputs = count (prop->value().begin(), prop->value().end(), '{');
        }
 
        no_panner_reset = true;
 
-       if (ensure_io (num_inputs, num_outputs, true, this)) {
+       if (ensure_io (ChanCount (_default_type, num_inputs),
+                      ChanCount (_default_type, num_outputs),
+                      true, this)) {
+               
                error << string_compose(_("%1: cannot create I/O ports"), _name) << endmsg;
                return -1;
        }
@@ -2065,13 +2065,12 @@ IO::connect_input_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src)
                /* Connect to the bundle, not worrying about any connections
                   that are already made. */
 
-               ChanCount const channels = c->nchannels ();
-               uint32_t cnt = channels.get (default_type());
+               uint32_t cnt = c->nchannels ();
 
                for (uint32_t n = 0; n < cnt; ++n) {
-                       const PortList& pl = c->channel_ports (n);
+                       const Bundle::PortList& pl = c->channel_ports (n);
 
-                       for (PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
+                       for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
 
                          if (!_inputs.port(n)->connected_to (*i)) {
                                        
@@ -2115,14 +2114,13 @@ IO::connect_output_ports_to_bundle (boost::shared_ptr<Bundle> c, void* src)
                /* Connect to the bundle, not worrying about any connections
                   that are already made. */
 
-               ChanCount const channels = c->nchannels ();
-               uint32_t cnt = channels.get (default_type());
+               uint32_t cnt = c->nchannels ();
 
                for (uint32_t n = 0; n < cnt; ++n) {
 
-                       const PortList& pl = c->channel_ports (n);
+                       const Bundle::PortList& pl = c->channel_ports (n);
 
-                       for (PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
+                       for (Bundle::PortList::const_iterator i = pl.begin(); i != pl.end(); ++i) {
 
                                if (!_outputs.port(n)->connected_to (*i)) {
                                                
@@ -2199,28 +2197,14 @@ IO::reset_panners ()
 }
 
 void
-IO::bundle_configuration_will_change ()
-{
-       //XXX
-//     connect_input_ports_to_bundle (_input_bundle, this);
-}
-
-void
-IO::bundle_configuration_has_changed ()
+IO::bundle_configuration_changed ()
 {
        //XXX
 //     connect_input_ports_to_bundle (_input_bundle, this);
 }
 
 void
-IO::bundle_ports_will_change (int ignored)
-{
-//XXX
-//     connect_output_ports_to_bundle (_output_bundle, this);
-}
-
-void
-IO::bundle_ports_have_changed (int ignored)
+IO::bundle_ports_changed (int ignored)
 {
        //XXX
 //     connect_output_ports_to_bundle (_output_bundle, this);
@@ -2611,7 +2595,7 @@ IO::setup_bundles_for_inputs_and_outputs ()
         snprintf(buf, sizeof (buf), _("%s in"), _name.c_str());
         _bundle_for_inputs->set_name (buf);
        uint32_t const ni = inputs().num_ports();
-       _bundle_for_inputs->set_channels (ni);
+       _bundle_for_inputs->set_nchannels (ni);
        for (uint32_t i = 0; i < ni; ++i) {
                _bundle_for_inputs->set_port (i, inputs().port(i)->name());
        }
@@ -2619,7 +2603,7 @@ IO::setup_bundles_for_inputs_and_outputs ()
         snprintf(buf, sizeof (buf), _("%s out"), _name.c_str());
         _bundle_for_outputs->set_name (buf);
        uint32_t const no = outputs().num_ports();
-       _bundle_for_outputs->set_channels (no);
+       _bundle_for_outputs->set_nchannels (no);
        for (uint32_t i = 0; i < no; ++i) {
                _bundle_for_outputs->set_port (i, outputs().port(i)->name());
        }
@@ -2633,8 +2617,8 @@ IO::setup_bundles_for_inputs_and_outputs ()
 void
 IO::create_bundles_for_inputs_and_outputs ()
 {
-       _bundle_for_inputs = boost::shared_ptr<AutoBundle> (new AutoBundle (true));
-        _bundle_for_outputs = boost::shared_ptr<AutoBundle> (new AutoBundle (false));
+       _bundle_for_inputs = boost::shared_ptr<Bundle> (new Bundle (true));
+        _bundle_for_outputs = boost::shared_ptr<Bundle> (new Bundle (false));
         setup_bundles_for_inputs_and_outputs ();
 }
 
@@ -2645,19 +2629,17 @@ IO::create_bundles_for_inputs_and_outputs ()
 void
 IO::maybe_add_input_bundle_to_list (boost::shared_ptr<Bundle> b, std::vector<boost::shared_ptr<Bundle> >* bundles)
 {
-       boost::shared_ptr<AutoBundle> ab = boost::dynamic_pointer_cast<AutoBundle, Bundle> (b);
-
-       if (ab == 0 || ab->ports_are_outputs() == false) {
+       if (b->ports_are_outputs() == false) {
                return;
        }
        
-       if (ab->nchannels().get (default_type()) != n_inputs().n_total ()) {
+       if (b->nchannels() != n_inputs().n_total ()) {
                return;
        }
 
        for (uint32_t i = 0; i < n_inputs().n_total (); ++i) {
 
-               PortList const & pl = b->channel_ports (i);
+               Bundle::PortList const & pl = b->channel_ports (i);
 
                if (pl.empty()) {
                        return;
@@ -2682,7 +2664,7 @@ IO::bundles_connected_to_inputs ()
                bundles.push_back (i->bundle);
        }
 
-       /* Auto bundles */
+       /* Normal bundles */
        _session.foreach_bundle (
                sigc::bind (sigc::mem_fun (*this, &IO::maybe_add_input_bundle_to_list), &bundles)
                );
@@ -2698,18 +2680,17 @@ IO::bundles_connected_to_inputs ()
 void
 IO::maybe_add_output_bundle_to_list (boost::shared_ptr<Bundle> b, std::vector<boost::shared_ptr<Bundle> >* bundles)
 {
-       boost::shared_ptr<AutoBundle> ab = boost::dynamic_pointer_cast<AutoBundle, Bundle> (b);
-       if (ab == 0 || ab->ports_are_inputs() == false) {
+       if (b->ports_are_inputs() == false) {
                return;
        }
 
-       if (ab->nchannels ().get (default_type()) != n_outputs().n_total ()) {
+       if (b->nchannels () != n_outputs().n_total ()) {
                return;
        }
 
        for (uint32_t i = 0; i < n_outputs().n_total (); ++i) {
 
-               PortList const & pl = b->channel_ports (i);
+               Bundle::PortList const & pl = b->channel_ports (i);
 
                if (pl.empty()) {
                        return;
@@ -2747,17 +2728,11 @@ IO::bundles_connected_to_outputs ()
 IO::UserBundleInfo::UserBundleInfo (IO* io, boost::shared_ptr<UserBundle> b)
 {
        bundle = b;
-       configuration_will_change = b->ConfigurationWillChange.connect (
-               sigc::mem_fun (*io, &IO::bundle_configuration_will_change)
-               );
-       configuration_has_changed = b->ConfigurationHasChanged.connect (
-               sigc::mem_fun (*io, &IO::bundle_configuration_has_changed)
-               );
-       ports_will_change = b->PortsWillChange.connect (
-               sigc::mem_fun (*io, &IO::bundle_ports_will_change)
+       configuration_changed = b->ConfigurationChanged.connect (
+               sigc::mem_fun (*io, &IO::bundle_configuration_changed)
                );
-       ports_have_changed = b->PortsHaveChanged.connect (
-               sigc::mem_fun (*io, &IO::bundle_ports_have_changed)
+       ports_changed = b->PortsChanged.connect (
+               sigc::mem_fun (*io, &IO::bundle_ports_changed)
                );
 }
 
index 07bb5ceada7a7e70d4afece7f9a0fc6a03ae4332..ea8b4314813d644a6e4ca2d7f6b939b0cf02ea4a 100644 (file)
@@ -43,6 +43,7 @@
 #include <ardour/audioengine.h>
 #include <ardour/ladspa_plugin.h>
 #include <ardour/buffer_set.h>
+#include <ardour/audio_buffer.h>
 
 #include <pbd/stl_delete.h>
 
index 5b3b2e5f9eda4cd56663be7c442d3c4815c76da4..ebfefeee3624b9ebf96563d2b5f40f36246cb101 100644 (file)
@@ -23,6 +23,8 @@
 #include <ardour/peak.h>
 #include <ardour/dB.h>
 #include <ardour/session.h>
+#include <ardour/audio_buffer.h>
+#include <ardour/midi_buffer.h>
 
 namespace ARDOUR {
 
index 65034aa212b70b7ddb5e5200c35eb69287d65faa..c5e28321bf8acd195ec07960d173be3e24af3b95 100644 (file)
@@ -40,6 +40,7 @@
 #include <ardour/session.h>
 #include <ardour/panner.h>
 #include <ardour/utils.h>
+#include <ardour/audio_buffer.h>
 
 #include <ardour/runtime_functions.h>
 #include <ardour/buffer_set.h>
index 8efef136d1e1abf1802f7bcc70a646aa0c80179a..67ea01b8bfdf0402de53afaa68f5dd51b9028a1a 100644 (file)
@@ -64,7 +64,6 @@
 #include <ardour/processor.h>
 #include <ardour/plugin_insert.h>
 #include <ardour/port_insert.h>
-#include <ardour/auto_bundle.h>
 #include <ardour/slave.h>
 #include <ardour/tempo.h>
 #include <ardour/audio_track.h>
@@ -82,6 +81,7 @@
 #include <ardour/session_directory.h>
 #include <ardour/tape_file_matcher.h>
 #include <ardour/analyser.h>
+#include <ardour/bundle.h>
 
 #ifdef HAVE_LIBLO
 #include <ardour/osc.h>
@@ -601,8 +601,8 @@ Session::when_engine_running ()
                char buf[32];
                snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1);
 
-               shared_ptr<AutoBundle> c (new AutoBundle (buf, true));
-               c->set_channels (1);
+               shared_ptr<Bundle> c (new Bundle (buf, true));
+               c->set_nchannels (1);
                c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
 
                add_bundle (c);
@@ -612,8 +612,8 @@ Session::when_engine_running ()
                char buf[32];
                snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1);
 
-               shared_ptr<AutoBundle> c (new AutoBundle (buf, false));
-               c->set_channels (1);
+               shared_ptr<Bundle> c (new Bundle (buf, false));
+               c->set_nchannels (1);
                c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
 
                add_bundle (c);
@@ -625,8 +625,8 @@ Session::when_engine_running ()
                char buf[32];
                snprintf (buf, sizeof (buf), _("out %" PRIu32 "+%" PRIu32), np+1, np+2);
 
-               shared_ptr<AutoBundle> c (new AutoBundle (buf, true));
-               c->set_channels (2);
+               shared_ptr<Bundle> c (new Bundle (buf, true));
+               c->set_nchannels (2);
                c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
                c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1));
 
@@ -637,8 +637,8 @@ Session::when_engine_running ()
                char buf[32];
                snprintf (buf, sizeof (buf), _("in %" PRIu32 "+%" PRIu32), np+1, np+2);
 
-               shared_ptr<AutoBundle> c (new AutoBundle (buf, false));
-               c->set_channels (2);
+               shared_ptr<Bundle> c (new Bundle (buf, false));
+               c->set_nchannels (2);
                c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
                c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1));
 
@@ -686,14 +686,6 @@ Session::when_engine_running ()
                        _master_out->allow_pan_reset ();
 
                }
-
-               shared_ptr<AutoBundle> c (new AutoBundle (_("Master Out"), true));
-
-               c->set_channels (_master_out->n_inputs().n_total());
-               for (uint32_t n = 0; n < _master_out->n_inputs ().n_total(); ++n) {
-                       c->set_port (n, _master_out->input(n)->name());
-               }
-               add_bundle (c);
        }
 
        BootMessage (_("Setup signal flow and plugins"));
index 0fcd1c95a9d464dc87c79df65f11e679cbc59354..6c6ce18c8bd407ab5fae9df65a69b95975ad8ff4 100644 (file)
@@ -81,7 +81,7 @@
 #include <ardour/io_processor.h>
 #include <ardour/send.h>
 #include <ardour/processor.h>
-#include <ardour/bundle.h>
+#include <ardour/user_bundle.h>
 #include <ardour/slave.h>
 #include <ardour/tempo.h>
 #include <ardour/audio_track.h>
index b9d115bc400c7473db6b32246e4b732d07dad34b..d53bf8b155764c7622fc803bc5e74ef59a61677d 100644 (file)
@@ -23,105 +23,6 @@ ARDOUR::UserBundle::UserBundle (XMLNode const & x, bool i)
        }
 }
 
-ARDOUR::ChanCount
-ARDOUR::UserBundle::nchannels () const
-{
-       Glib::Mutex::Lock lm (_ports_mutex);
-       return ChanCount (type(), _ports.size ());
-}
-
-const ARDOUR::PortList&
-ARDOUR::UserBundle::channel_ports (uint32_t n) const
-{
-       assert (n < nchannels ().get (type()));
-
-       Glib::Mutex::Lock lm (_ports_mutex);
-       return _ports[n];
-}
-
-void
-ARDOUR::UserBundle::add_port_to_channel (uint32_t c, std::string const & p)
-{
-       assert (c < nchannels ().get (type()));
-       
-       PortsWillChange (c);
-
-       {
-               Glib::Mutex::Lock lm (_ports_mutex);
-               _ports[c].push_back (p);
-       }
-       
-       PortsHaveChanged (c);
-}
-
-void
-ARDOUR::UserBundle::remove_port_from_channel (uint32_t c, std::string const & p)
-{
-       assert (c < nchannels ().get (type()));
-
-       PortsWillChange (c);
-
-       {
-               Glib::Mutex::Lock lm (_ports_mutex);
-               PortList::iterator i = std::find (_ports[c].begin(), _ports[c].end(), p);
-               if (i != _ports[c].end()) {
-                       _ports[c].erase (i);
-               }
-       }
-       
-       PortsHaveChanged (c);
-}
-
-bool
-ARDOUR::UserBundle::port_attached_to_channel (uint32_t c, std::string const & p) const
-{
-       assert (c < nchannels ().get (type()));
-
-       Glib::Mutex::Lock lm (_ports_mutex);
-       return std::find (_ports[c].begin(), _ports[c].end(), p) != _ports[c].end();
-}
-
-void
-ARDOUR::UserBundle::add_channel ()
-{
-       ConfigurationWillChange ();
-
-       {
-               Glib::Mutex::Lock lm (_ports_mutex);
-               _ports.resize (_ports.size() + 1);
-       }
-       
-       ConfigurationHasChanged ();
-}
-
-void
-ARDOUR::UserBundle::set_channels (uint32_t n)
-{
-       ConfigurationWillChange ();
-
-       {
-               Glib::Mutex::Lock lm (_ports_mutex);
-               _ports.resize (n);
-       }
-
-       ConfigurationHasChanged ();
-}
-
-void
-ARDOUR::UserBundle::remove_channel (uint32_t r)
-{
-       assert (r < nchannels ().get (type()));
-
-       ConfigurationWillChange ();
-
-       {
-               Glib::Mutex::Lock lm (_ports_mutex);
-               _ports.erase (_ports.begin() + r, _ports.begin() + r + 1);
-       }
-
-       ConfigurationHasChanged ();
-}
-
 int
 ARDOUR::UserBundle::set_state (XMLNode const & node)
 {
@@ -181,17 +82,21 @@ ARDOUR::UserBundle::get_state ()
 
        node->add_property ("name", name ());
 
-       for (std::vector<PortList>::iterator i = _ports.begin(); i != _ports.end(); ++i) {
-
-               XMLNode* c = new XMLNode ("Channel");
+       {
+               Glib::Mutex::Lock lm (_ports_mutex);
 
-               for (PortList::iterator j = i->begin(); j != i->end(); ++j) {
-                       XMLNode* p = new XMLNode ("Port");
-                       p->add_property ("name", *j);
-                       c->add_child_nocopy (*p);
+               for (std::vector<PortList>::iterator i = _ports.begin(); i != _ports.end(); ++i) {
+                       
+                       XMLNode* c = new XMLNode ("Channel");
+                       
+                       for (PortList::iterator j = i->begin(); j != i->end(); ++j) {
+                               XMLNode* p = new XMLNode ("Port");
+                               p->add_property ("name", *j);
+                               c->add_child_nocopy (*p);
+                       }
+                       
+                       node->add_child_nocopy (*c);
                }
-
-               node->add_child_nocopy (*c);
        }
 
        return *node;
index 4e4a76f977a15329cb065665bda4b2a704fa6cf6..7d726e70ee937492778e7dd2bfcf11933f53b31c 100644 (file)
@@ -319,7 +319,7 @@ class MackieControlProtocol
    static const char * default_port_name;
   
        /// The Midi port(s) connected to the units
-       typedef vector<Mackie::MackiePort*> MackiePorts;
+       typedef std::vector<Mackie::MackiePort*> MackiePorts;
        MackiePorts _ports;
   
        /// Sometimes the real port goes away, and we want to contain the breakage