change session construction so that the the monitor bus config is derived (once)...
authorPaul Davis <paul@linuxaudiosystems.com>
Sun, 21 Mar 2010 17:02:30 +0000 (17:02 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Sun, 21 Mar 2010 17:02:30 +0000 (17:02 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@6779 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui.cc
gtk2_ardour/ardour_ui.h
gtk2_ardour/startup.cc
gtk2_ardour/startup.h
libs/ardour/ardour/io.h
libs/ardour/ardour/session.h
libs/ardour/io.cc
libs/ardour/session.cc

index b216acae2902052e042813fb360cca43b0696954..716a6820b8ea17acef5b612da52ab11ac35195f0 100644 (file)
@@ -2273,7 +2273,6 @@ int
 ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib::ustring& session_name)
 {
 
-       uint32_t cchns;
        uint32_t mchns;
        AutoConnectOption iconnect;
        AutoConnectOption oconnect;
@@ -2282,7 +2281,6 @@ ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib
 
        if (Profile->get_sae()) {
 
-               cchns = 0;
                mchns = 2;
                iconnect = AutoConnectPhysical;
                oconnect = AutoConnectMaster;
@@ -2293,12 +2291,6 @@ ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib
 
                /* get settings from advanced section of NSD */
 
-               if (_startup->create_control_bus()) {
-                       cchns = (uint32_t) _startup->control_channel_count();
-               } else {
-                       cchns = 0;
-               }
-
                if (_startup->create_master_bus()) {
                        mchns = (uint32_t) _startup->master_channel_count();
                } else {
@@ -2329,7 +2321,7 @@ ARDOUR_UI::build_session_from_nsd (const Glib::ustring& session_path, const Glib
 
        if (build_session (session_path,
                           session_name,
-                          cchns,
+                           _startup->create_control_bus(),
                           mchns,
                           iconnect,
                           oconnect,
@@ -2642,7 +2634,7 @@ ARDOUR_UI::load_session (const Glib::ustring& path, const Glib::ustring& snap_na
 
 int
 ARDOUR_UI::build_session (const Glib::ustring& path, const Glib::ustring& snap_name,
-                         uint32_t control_channels,
+                          bool with_monitor,
                          uint32_t master_channels,
                          AutoConnectOption input_connect,
                          AutoConnectOption output_connect,
@@ -2671,7 +2663,7 @@ ARDOUR_UI::build_session (const Glib::ustring& path, const Glib::ustring& snap_n
 
        try {
                new_session = new Session (*engine, path, snap_name, input_connect, output_connect,
-                                          control_channels, master_channels, nphysin, nphysout, initial_length);
+                                          with_monitor, master_channels, nphysin, nphysout, initial_length);
        }
 
        catch (...) {
index a851e03981f6bb7c382113510248fe5a617f4723..0ae904678d2835c5972e7cd8b8c1b3b7d78191b9 100644 (file)
@@ -125,7 +125,7 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr
        int load_session (const Glib::ustring& path, const Glib::ustring& snapshot, Glib::ustring mix_template = Glib::ustring());
        bool session_loaded;
        int build_session (const Glib::ustring& path, const Glib::ustring& snapshot,
-                          uint32_t ctl_chns,
+                          bool with_monitor,
                           uint32_t master_chns,
                           ARDOUR::AutoConnectOption input_connect,
                           ARDOUR::AutoConnectOption output_connect,
index f6ec9e049007fcb039e417d652c727e2ad48878f..456cb4922e009c34ddc03ff4e6f70a19fc9bc32b 100644 (file)
@@ -812,11 +812,9 @@ ArdourStartup::setup_more_options_page ()
 
        _output_limit_count.set_adjustment (_output_limit_count_adj);
        _input_limit_count.set_adjustment (_input_limit_count_adj);
-       _control_bus_channel_count.set_adjustment (_control_bus_channel_count_adj);
        _master_bus_channel_count.set_adjustment (_master_bus_channel_count_adj);
 
        chan_count_label_1.set_text (_("channels"));
-       chan_count_label_2.set_text (_("channels"));
        chan_count_label_3.set_text (_("channels"));
        chan_count_label_4.set_text (_("channels"));
 
@@ -824,10 +822,6 @@ ArdourStartup::setup_more_options_page ()
        chan_count_label_1.set_padding(0,0);
        chan_count_label_1.set_line_wrap(false);
 
-       chan_count_label_2.set_alignment(0,0.5);
-       chan_count_label_2.set_padding(0,0);
-       chan_count_label_2.set_line_wrap(false);
-
        chan_count_label_3.set_alignment(0,0.5);
        chan_count_label_3.set_padding(0,0);
        chan_count_label_3.set_line_wrap(false);
@@ -847,13 +841,6 @@ ArdourStartup::setup_more_options_page ()
        _create_control_bus.set_active(false);
        _create_control_bus.set_border_width(0);
 
-       _control_bus_channel_count.set_flags(Gtk::CAN_FOCUS);
-       _control_bus_channel_count.set_update_policy(Gtk::UPDATE_ALWAYS);
-       _control_bus_channel_count.set_numeric(true);
-       _control_bus_channel_count.set_digits(0);
-       _control_bus_channel_count.set_wrap(false);
-       _control_bus_channel_count.set_sensitive(false);
-
        _master_bus_channel_count.set_flags(Gtk::CAN_FOCUS);
        _master_bus_channel_count.set_update_policy(Gtk::UPDATE_ALWAYS);
        _master_bus_channel_count.set_numeric(true);
@@ -909,8 +896,6 @@ ArdourStartup::setup_more_options_page ()
        bus_table.attach (_master_bus_channel_count, 1, 2, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
        bus_table.attach (chan_count_label_1, 2, 3, 0, 1, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
        bus_table.attach (_create_control_bus, 0, 1, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       bus_table.attach (_control_bus_channel_count, 1, 2, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 0, 0);
-       bus_table.attach (chan_count_label_2, 2, 3, 1, 2, Gtk::EXPAND|Gtk::FILL, Gtk::EXPAND|Gtk::FILL, 6, 0);
 
        input_port_limit_hbox.pack_start(_limit_input_ports, Gtk::PACK_SHRINK, 6);
        input_port_limit_hbox.pack_start(_input_limit_count, Gtk::PACK_SHRINK, 0);
@@ -1037,12 +1022,6 @@ ArdourStartup::create_control_bus() const
        return _create_control_bus.get_active();
 }
 
-int
-ArdourStartup::control_channel_count() const
-{
-       return _control_bus_channel_count.get_value_as_int();
-}
-
 bool
 ArdourStartup::connect_inputs() const
 {
@@ -1130,13 +1109,16 @@ ArdourStartup::limit_outputs_clicked ()
 void
 ArdourStartup::master_bus_button_clicked ()
 {
-       _master_bus_channel_count.set_sensitive(_create_master_bus.get_active());
+        bool yn = _create_master_bus.get_active();
+
+       _master_bus_channel_count.set_sensitive(yn);
+        _create_control_bus.set_sensitive (yn);
 }
 
 void
 ArdourStartup::monitor_bus_button_clicked ()
 {
-       _control_bus_channel_count.set_sensitive(_create_control_bus.get_active());
+        /* relax */
 }
 
 void
index f0146e2a5e0b6cb16ad10181a6b80d9ab43c3c2a..01fdd853f26e799bb33fc086d725b6ec1d2c9df1 100644 (file)
@@ -45,7 +45,6 @@ class ArdourStartup : public Gtk::Assistant {
        int master_channel_count() const;
 
        bool create_control_bus() const;
-       int control_channel_count() const;
 
        bool connect_inputs() const;
        bool limit_inputs_used_for_connection() const;
@@ -180,7 +179,6 @@ class ArdourStartup : public Gtk::Assistant {
        Gtk::VBox more_options_vbox;
 
        Gtk::Label chan_count_label_1;
-       Gtk::Label chan_count_label_2;
        Gtk::Label chan_count_label_3;
        Gtk::Label chan_count_label_4;
        Gtk::Table advanced_table;
@@ -211,7 +209,6 @@ class ArdourStartup : public Gtk::Assistant {
        Gtk::SpinButton _master_bus_channel_count;
 
        Gtk::CheckButton _create_control_bus;
-       Gtk::SpinButton _control_bus_channel_count;
 
        Gtk::CheckButton _connect_inputs;
        Gtk::CheckButton _limit_input_ports;
index b718cfa5c9aeeed5b22ef460892d481f929a7ff7..a7ba3a23a9c3acd30b9becf166306bcb43b4cd29 100644 (file)
@@ -107,6 +107,7 @@ class IO : public SessionObject, public Latent
        int disconnect (Port *our_port, std::string other_port, void *src);
        int disconnect (void *src);
        bool connected_to (boost::shared_ptr<const IO>) const;
+        bool connected () const;
 
        nframes_t signal_latency() const { return _own_latency; }
        nframes_t latency() const;
index 5cb8cbd78f68e55f7dad86dd8a8571ffffc65015..cb62decafc9eb9b29cb0a2b1f6e194ec9c27620c 100644 (file)
@@ -138,18 +138,18 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        /* creating a new Session */
 
        Session (AudioEngine&,
-                       std::string fullpath,
-                       std::string snapshot_name,
-                       AutoConnectOption input_auto_connect,
-                       AutoConnectOption output_auto_connect,
-                       uint32_t control_out_channels,
-                       uint32_t master_out_channels,
-                       uint32_t n_physical_in,
-                       uint32_t n_physical_out,
-                       nframes_t initial_length);
-
+                 std::string fullpath,
+                 std::string snapshot_name,
+                 AutoConnectOption input_auto_connect,
+                 AutoConnectOption output_auto_connect,
+                 bool with_monitor,
+                 uint32_t master_out_channels,
+                 uint32_t n_physical_in,
+                 uint32_t n_physical_out,
+                 nframes_t initial_length);
+        
        virtual ~Session ();
-
+        
        std::string path() const { return _path; }
        std::string name() const { return _name; }
        std::string snap_name() const { return _current_snapshot_name; }
index b34614e1dd1242b01d94ca581436f0b20916c9fb..9da9bf2a280ae81d378d8df17cb87ccc02e8da42 100644 (file)
@@ -1443,19 +1443,25 @@ IO::set_name_in_state (XMLNode& node, const string& new_name)
        }
 }
 
+bool
+IO::connected () const
+{
+        /* do we have any connections at all? */
+        
+        for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
+                if (p->connected()) {
+                        return true;
+                }
+        }
+        
+        return false;
+}
+
 bool
 IO::connected_to (boost::shared_ptr<const IO> other) const
 {
        if (!other) {
-               /* do we have any connections at all? */
-
-               for (PortSet::const_iterator p = _ports.begin(); p != _ports.end(); ++p) {
-                       if (p->connected()) {
-                               return true;
-                       }
-               }
-
-               return false;
+                return connected ();
        }
 
        assert (_direction != other->direction());
index 1fec3dbcc67a9dd5997a68460ff8142a7f07df24..20e88756ea663c9039277942ea477b3fcfc0cf6f 100644 (file)
@@ -206,7 +206,7 @@ Session::Session (AudioEngine &eng,
                  string snapshot_name,
                  AutoConnectOption input_ac,
                  AutoConnectOption output_ac,
-                 uint32_t control_out_channels,
+                  bool with_monitor,
                  uint32_t master_out_channels,
                  uint32_t requested_physical_in,
                  uint32_t requested_physical_out,
@@ -295,8 +295,8 @@ Session::Session (AudioEngine &eng,
                        output_ac = AutoConnectOption (output_ac & ~AutoConnectMaster);
                }
 
-               if (control_out_channels) {
-                       ChanCount count(DataType::AUDIO, control_out_channels);
+               if (with_monitor) {
+                       ChanCount count(DataType::AUDIO, master_out_channels);
                        Route* rt = new Route (*this, _("monitor"), Route::ControlOut, DataType::AUDIO);
                        boost_debug_shared_ptr_mark_interesting (rt, "Route");
                        shared_ptr<Route> r (rt);
@@ -648,7 +648,9 @@ Session::when_engine_running (bool new_session)
 
        if (new_session && !no_auto_connect()) {
 
-               if (_master_out && Config->get_auto_connect_standard_busses()) {
+                /* don't connect the master bus outputs if there is a monitor bus */
+
+               if (_master_out && Config->get_auto_connect_standard_busses() && !_control_out) {
 
                        /* if requested auto-connect the outputs to the first N physical ports.
                         */
@@ -697,11 +699,10 @@ Session::when_engine_running (bool new_session)
                                }
                        }
 
-                       /* if control out is not connected,
-                          connect control out to physical outs, but use ones after the master if possible
+                       /* if control out is not connected, connect control out to physical outs
                        */
 
-                       if (!_control_out->output()->connected_to (boost::shared_ptr<IO>())) {
+                       if (!_control_out->output()->connected ()) {
 
                                if (!Config->get_monitor_bus_preferred_bundle().empty()) {
 
@@ -716,19 +717,15 @@ Session::when_engine_running (bool new_session)
                                        }
 
                                } else {
-
+                                        
                                        for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
-                                               uint32_t shift = _master_out->n_outputs().get(*t);
                                                uint32_t mod = _engine.n_physical_outputs (*t);
                                                uint32_t limit = _control_out->n_outputs().get(*t);
 
-                                               cerr << "Connecting " << limit << " control out ports, shift is " << shift
-                                                       << " mod is " << mod << endl;
-
                                                for (uint32_t n = 0; n < limit; ++n) {
 
                                                        Port* p = _control_out->output()->ports().port(*t, n);
-                                                       string connect_to = _engine.get_nth_physical_output (*t, (n+shift) % mod);
+                                                       string connect_to = _engine.get_nth_physical_output (*t, (n % mod));
 
                                                        if (!connect_to.empty()) {
                                                                if (_control_out->output()->connect (p, connect_to, this)) {