From 6ec133ebde064dc528d8e448cbce40f0d401a7d1 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 15 Aug 2017 23:17:08 +0200 Subject: Separate "add master bus" (and add Lua bindings) This is in preparation for "advanced session setup" allow a SessionSetup Lua script to create the master-bus. --- libs/ardour/ardour/session.h | 1 + libs/ardour/luabindings.cc | 5 +++++ libs/ardour/session.cc | 27 +++++++++++++++++++++++++++ libs/ardour/session_state.cc | 29 ++++++----------------------- 4 files changed, 39 insertions(+), 23 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 1123abd02e..2cc86939d1 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -866,6 +866,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop PBD::Signal0 session_routes_reconnected; /* monitor/master out */ + int add_master_bus (ChanCount const&); void add_monitor_section (); void reset_monitor_section (); diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 021e2b7324..253f88a759 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -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) diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 19ca9ceea9..37d987d547 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -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 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 () { diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index b0b8a46a4b..051eca4b68 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -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 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; -- cgit v1.2.3