Separate "add master bus" (and add Lua bindings)
authorRobin Gareus <robin@gareus.org>
Tue, 15 Aug 2017 21:17:08 +0000 (23:17 +0200)
committerRobin Gareus <robin@gareus.org>
Tue, 15 Aug 2017 22:51:20 +0000 (00:51 +0200)
This is in preparation for "advanced session setup" allow a SessionSetup
Lua script to create the master-bus.

libs/ardour/ardour/session.h
libs/ardour/luabindings.cc
libs/ardour/session.cc
libs/ardour/session_state.cc

index 1123abd02ebae48e1d0c71ed8313f7e833edd3b1..2cc86939d1b3fe90b410239ef230ac775b63e607 100644 (file)
@@ -866,6 +866,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        PBD::Signal0<void> session_routes_reconnected;
 
        /* monitor/master out */
+       int add_master_bus (ChanCount const&);
 
        void add_monitor_section ();
        void reset_monitor_section ();
index 021e2b73241a9710d2118f3d61bc38010f78da1b..253f88a759a2cdf1c00c1df4b4dd425b2b91470f 100644 (file)
@@ -1970,6 +1970,11 @@ LuaBindings::common (lua_State* L)
                .addFunction ("new_audio_route", &Session::new_audio_route)
                .addFunction ("new_midi_track", &Session::new_midi_track)
                .addFunction ("new_midi_route", &Session::new_midi_route)
+
+               .addFunction ("add_master_bus", &Session::add_master_bus)
+               .addFunction ("add_monitor_section", &Session::add_monitor_section)
+               .addFunction ("remove_monitor_section", &Session::remove_monitor_section)
+
                .addFunction ("get_routes", &Session::get_routes)
                .addFunction ("get_tracks", &Session::get_tracks)
                .addFunction ("get_stripables", (StripableList (Session::*)() const)&Session::get_stripables)
index 19ca9ceea9d2e13cd03fcdf17b2d0db29b6223f4..37d987d54725b1996f537ffc845e891c67c5fefb 100644 (file)
@@ -1495,6 +1495,33 @@ Session::reset_monitor_section ()
        }
 }
 
+int
+Session::add_master_bus (ChanCount const& count)
+{
+       if (master_out ()) {
+               return -1;
+       }
+
+       RouteList rl;
+
+       boost::shared_ptr<Route> r (new Route (*this, _("Master"), PresentationInfo::MasterOut, DataType::AUDIO));
+       if (r->init ()) {
+               return -1;
+       }
+
+       BOOST_MARK_ROUTE(r);
+
+       {
+               Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
+               r->input()->ensure_io (count, false, this);
+               r->output()->ensure_io (count, false, this);
+       }
+
+       rl.push_back (r);
+       add_routes (rl, false, false, false, PresentationInfo::max_order);
+       return 0;
+}
+
 void
 Session::hookup_io ()
 {
index b0b8a46a4b506a59654315f63e744cfef49c62a4..051eca4b688d6ed2cab5b331f11b772e03dd4ac3 100644 (file)
@@ -659,33 +659,16 @@ Session::create (const string& session_template, BusProfile* bus_profile)
        if (bus_profile) {
                RouteList rl;
                ChanCount count(DataType::AUDIO, bus_profile->master_out_channels);
+               if (bus_profile->master_out_channels) {
+                       int rv = add_master_bus (count);
 
-               // Waves Tracks: always create master bus for Tracks
-               if (ARDOUR::Profile->get_trx() || bus_profile->master_out_channels) {
-                       boost::shared_ptr<Route> r (new Route (*this, _("Master"), PresentationInfo::MasterOut, DataType::AUDIO));
-                       if (r->init ()) {
-                               return -1;
+                       if (rv) {
+                               return rv;
                        }
 
-                       BOOST_MARK_ROUTE(r);
-
-                       {
-                               Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
-                               r->input()->ensure_io (count, false, this);
-                               r->output()->ensure_io (count, false, this);
-                       }
-
-                       rl.push_back (r);
-
+                       if (Config->get_use_monitor_bus())
+                               add_monitor_section ();
                }
-
-               if (!rl.empty()) {
-                       add_routes (rl, false, false, false, PresentationInfo::max_order);
-               }
-       }
-
-       if (Config->get_use_monitor_bus() && bus_profile) {
-               add_monitor_section ();
        }
 
        return 0;