first pass at making the GUI for a VCA visible
[ardour.git] / libs / ardour / session.cc
index 68c7d3957fdc8f99c5487a57031a4c505b29fb4a..4ff42730ca328b6f95a55a14444df7bf6b70599d 100644 (file)
@@ -36,7 +36,6 @@
 #include <boost/algorithm/string/erase.hpp>
 
 #include "pbd/basename.h"
-#include "pbd/boost_debug.h"
 #include "pbd/convert.h"
 #include "pbd/convert.h"
 #include "pbd/error.h"
@@ -59,6 +58,7 @@
 #include "ardour/audioengine.h"
 #include "ardour/audiofilesource.h"
 #include "ardour/auditioner.h"
+#include "ardour/boost_debug.h"
 #include "ardour/buffer_manager.h"
 #include "ardour/buffer_set.h"
 #include "ardour/bundle.h"
 #include "ardour/track.h"
 #include "ardour/user_bundle.h"
 #include "ardour/utils.h"
+#include "ardour/vca_manager.h"
 
 #include "midi++/port.h"
 #include "midi++/mmc.h"
@@ -301,7 +302,7 @@ Session::Session (AudioEngine &eng,
        , first_file_header_format_reset (true)
        , have_looped (false)
        , _have_rec_enabled_track (false)
-    , _have_rec_disabled_track (true)
+       , _have_rec_disabled_track (true)
        , _step_editors (0)
        , _suspend_timecode_transmission (0)
        ,  _speakers (new Speakers)
@@ -311,6 +312,7 @@ Session::Session (AudioEngine &eng,
        , _scene_changer (0)
        , _midi_ports (0)
        , _mmc (0)
+       , _vca_manager (new VCAManager (*this))
 {
        uint32_t sr = 0;
 
@@ -381,8 +383,9 @@ Session::Session (AudioEngine &eng,
                 */
 
                if (state_tree) {
-                       const XMLProperty* prop;
-                       if ((prop = state_tree->root()->property (X_("sample-rate"))) != 0) {
+                       XMLProperty const * prop;
+                       XMLNode const * root (state_tree->root());
+                       if ((prop = root->property (X_("sample-rate"))) != 0) {
                                sr = atoi (prop->value());
                        }
                }
@@ -560,6 +563,7 @@ Session::immediately_post_engine ()
        }
 
        try {
+               LocaleGuard lg;
                BootMessage (_("Set up LTC"));
                setup_ltc ();
                BootMessage (_("Set up Click"));
@@ -744,6 +748,7 @@ Session::destroy ()
 
        delete midi_clock;
        delete _tempo_map;
+       delete _vca_manager;
 
        /* clear event queue, the session is gone, nobody is interested in
         * those anymore, but they do leak memory if not removed
@@ -783,9 +788,7 @@ Session::destroy ()
 
        DEBUG_TRACE (DEBUG::Destruction, "Session::destroy() done\n");
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-       boost_debug_list_ptrs ();
-#endif
+       BOOST_SHOW_POINTERS ();
 }
 
 void
@@ -1145,9 +1148,8 @@ Session::add_monitor_section ()
                return;
        }
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-       // boost_debug_shared_ptr_mark_interesting (r.get(), "Route");
-#endif
+       BOOST_MARK_ROUTE(r);
+
        try {
                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
                r->input()->ensure_io (_master_out->output()->n_ports(), false, this);
@@ -2424,7 +2426,7 @@ Session::default_track_name_pattern (DataType t)
  */
 list<boost::shared_ptr<MidiTrack> >
 Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost::shared_ptr<PluginInfo> instrument,
-                        TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template)
+                        TrackMode mode, RouteGroup* route_group, uint32_t how_many, string name_template, Plugin::PresetRecord* pset)
 {
        string track_name;
        uint32_t track_id = 0;
@@ -2456,9 +2458,8 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
 
                        track->use_new_diskstream();
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-                       // boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
-#endif
+                       BOOST_MARK_TRACK (track);
+
                        {
                                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
                                if (track->input()->ensure_io (input, false, this)) {
@@ -2516,6 +2517,9 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
                if (instrument) {
                        for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) {
                                PluginPtr plugin = instrument->load (*this);
+                               if (pset) {
+                                       plugin->load_preset (*pset);
+                               }
                                boost::shared_ptr<Processor> p (new PluginInsert (*this, plugin));
                                (*r)->add_processor (p, PreFader);
 
@@ -2527,7 +2531,7 @@ Session::new_midi_track (const ChanCount& input, const ChanCount& output, boost:
 }
 
 RouteList
-Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr<PluginInfo> instrument)
+Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name_template, boost::shared_ptr<PluginInfo> instrument, Plugin::PresetRecord* pset)
 {
        string bus_name;
        uint32_t bus_id = 0;
@@ -2553,9 +2557,8 @@ Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name
                                bus->set_strict_io (true);
                        }
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-                       // boost_debug_shared_ptr_mark_interesting (bus.get(), "Route");
-#endif
+                       BOOST_MARK_ROUTE(bus);
+
                        {
                                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
 
@@ -2605,6 +2608,9 @@ Session::new_midi_route (RouteGroup* route_group, uint32_t how_many, string name
                if (instrument) {
                        for (RouteList::iterator r = ret.begin(); r != ret.end(); ++r) {
                                PluginPtr plugin = instrument->load (*this);
+                               if (pset) {
+                                       plugin->load_preset (*pset);
+                               }
                                boost::shared_ptr<Processor> p (new PluginInsert (*this, plugin));
                                (*r)->add_processor (p, PreFader);
                        }
@@ -2977,9 +2983,8 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
 
                        track->use_new_diskstream();
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-                       // boost_debug_shared_ptr_mark_interesting (track.get(), "Track");
-#endif
+                       BOOST_MARK_TRACK (track);
+
                        {
                                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
 
@@ -3074,9 +3079,8 @@ Session::new_audio_route (int input_channels, int output_channels, RouteGroup* r
                                bus->set_strict_io (true);
                        }
 
-#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
-                       // boost_debug_shared_ptr_mark_interesting (bus.get(), "Route");
-#endif
+                       BOOST_MARK_ROUTE(bus);
+
                        {
                                Glib::Threads::Mutex::Lock lm (AudioEngine::instance()->process_lock ());
 
@@ -3209,6 +3213,7 @@ Session::new_route_from_template (uint32_t how_many, XMLNode& node, const std::s
                        case NewPlaylist:
                                rename_playlist = true;
                                break;
+                       default:
                        case CopyPlaylist:
                        case SharePlaylist:
                                rename_playlist = false;
@@ -3221,13 +3226,13 @@ Session::new_route_from_template (uint32_t how_many, XMLNode& node, const std::s
                        for (XMLNodeList::iterator i = children.begin(); i != children.end(); ++i) {
                                if ((*i)->name() == X_("Processor")) {
                                        /* ForceIDRegeneration does not catch the following */
-                                       XMLProperty* role = (*i)->property (X_("role"));
-                                       XMLProperty* type = (*i)->property (X_("type"));
+                                       XMLProperty const * role = (*i)->property (X_("role"));
+                                       XMLProperty const * type = (*i)->property (X_("type"));
                                        if (role && role->value() == X_("Aux")) {
                                                /* check if the target bus exists.
                                                 * we should not save aux-sends in templates.
                                                 */
-                                               XMLProperty* target = (*i)->property (X_("target"));
+                                               XMLProperty const * target = (*i)->property (X_("target"));
                                                if (!target) {
                                                        (*i)->add_property ("type", "dangling-aux-send");
                                                        continue;
@@ -3556,7 +3561,6 @@ Session::add_internal_send (boost::shared_ptr<Route> dest, boost::shared_ptr<Pro
        graph_reordered ();
 }
 
-
 void
 Session::remove_routes (boost::shared_ptr<RouteList> routes_to_remove)
 {
@@ -5108,7 +5112,7 @@ Session::setup_lua ()
                        "   assert(self.scripts[n] == nil, 'Callback \"'.. n ..'\" already exists.')"
                        "   self.scripts[n] = { ['f'] = f, ['a'] = a }"
                        "   local env = _ENV;  env.f = nil env.io = nil env.os = nil env.loadfile = nil env.require = nil env.dofile = nil env.package = nil env.debug = nil"
-                       "   local env = { print = print, Session = Session, tostring = tostring, assert = assert, ipairs = ipairs, error = error, select = select, string = string, type = type, tonumber = tonumber, collectgarbage = collectgarbage, pairs = pairs, math = math, table = table, pcall = pcall }"
+                       "   local env = { print = print, tostring = tostring, assert = assert, ipairs = ipairs, error = error, select = select, string = string, type = type, tonumber = tonumber, collectgarbage = collectgarbage, pairs = pairs, math = math, table = table, pcall = pcall, Session = Session, PBD = PBD, Timecode = Timecode, Evoral = Evoral, C = C, ARDOUR = ARDOUR }"
                        "   self.instances[n] = load (string.dump(f, true), nil, nil, env)(a)"
                        "   Session:scripts_changed()" // call back
                        "  end"
@@ -5437,6 +5441,16 @@ Session::tempo_map_changed (const PropertyChange&)
        set_dirty ();
 }
 
+void
+Session::gui_tempo_map_changed ()
+{
+       clear_clicks ();
+
+       playlists->update_after_tempo_map_change ();
+
+       _locations->apply (*this, &Session::update_locations_after_tempo_map_change);
+}
+
 void
 Session::update_locations_after_tempo_map_change (const Locations::LocationList& loc)
 {
@@ -5919,7 +5933,6 @@ Session::write_one_track (Track& track, framepos_t start, framepos_t end,
        }
 
        unblock_processing ();
-       itt.done = true;
 
        return result;
 }
@@ -6403,9 +6416,10 @@ Session::unknown_processors () const
 void
 Session::update_latency (bool playback)
 {
+
        DEBUG_TRACE (DEBUG::Latency, string_compose ("JACK latency callback: %1\n", (playback ? "PLAYBACK" : "CAPTURE")));
 
-       if ((_state_of_the_state & (InitialConnecting|Deletion)) || _adding_routes_in_progress) {
+       if ((_state_of_the_state & (InitialConnecting|Deletion)) || _adding_routes_in_progress || _route_deletion_in_progress) {
                return;
        }