dramatically speed up the addition of large numbers of busses + tracks. consists...
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 4 Dec 2012 14:32:28 +0000 (14:32 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 4 Dec 2012 14:32:28 +0000 (14:32 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13595 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/editor_routes.cc
gtk2_ardour/editor_routes.h
gtk2_ardour/editor_summary.cc
gtk2_ardour/mixer_ui.cc
libs/ardour/ardour/session.h
libs/ardour/audioengine.cc
libs/ardour/session.cc
libs/ardour/session_state.cc

index acbbb697f2f4a7207a9b259123682026d9a5b274..e1a8bc645030bf6d3c9edbe5672ce1094c71fb93 100644 (file)
@@ -69,6 +69,7 @@ EditorRoutes::EditorRoutes (Editor* e)
        : EditorComponent (e)
         , _ignore_reorder (false)
         , _no_redisplay (false)
+        , _adding_routes (false)
         , _menu (0)
         , old_focus (0)
         , selection_countdown (0)
@@ -600,9 +601,12 @@ void
 EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
 {
        TreeModel::Row row;
+       PBD::Unwinder<bool> at (_adding_routes, true);
 
        suspend_redisplay ();
 
+       _display.set_model (Glib::RefPtr<ListStore>());
+
        for (list<RouteTimeAxisView*>::iterator x = routes.begin(); x != routes.end(); ++x) {
 
                boost::shared_ptr<MidiTrack> midi_trk = boost::dynamic_pointer_cast<MidiTrack> ((*x)->route());
@@ -653,6 +657,7 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
                (*x)->route()->solo_isolated_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_isolate_display, this), gui_context());
                (*x)->route()->solo_safe_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_solo_safe_display, this), gui_context());
                (*x)->route()->active_changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&EditorRoutes::update_active_display, this), gui_context ());
+
        }
 
        update_rec_display ();
@@ -662,7 +667,9 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
        update_solo_safe_display ();
        update_input_active_display ();
        update_active_display ();
+
        resume_redisplay ();
+       _display.set_model (_model);
 
        /* now update route order keys from the treeview/track display order */
 
@@ -672,7 +679,9 @@ EditorRoutes::routes_added (list<RouteTimeAxisView*> routes)
 void
 EditorRoutes::handle_gui_changes (string const & what, void*)
 {
-       ENSURE_GUI_THREAD (*this, &EditorRoutes::handle_gui_changes, what, src)
+       if (_adding_routes) {
+               return;
+       }
 
        if (what == "track_height") {
                /* Optional :make tracks change height while it happens, instead
index 4933a9496fe88c36a8bad01a6117d73a30e59c19..6118a2b057ba26fcc0019c63536be7c47c45b806 100644 (file)
@@ -154,6 +154,7 @@ private:
 
        bool _ignore_reorder;
        bool _no_redisplay;
+        bool _adding_routes;
 
        Gtk::Menu* _menu;
         Gtk::Widget* old_focus;
index 1d7440115e8580c5be2a0955996ff13f4bf95d16..e7ddb650ed17803e8ed425d5823c853b32780037 100644 (file)
@@ -689,8 +689,6 @@ EditorSummary::set_editor (double const x, double const y)
                   is merely pending but not executing.  But c'est la vie.
                */
                
-               cerr << "Editor pending idle already queued\n";
-
                return;
        }
 
index 18ad28d7744258d8100af4c98e622244b15d0aaa..560c37bb1d76cfa5a755a0896e72bf08d1cbfcf1 100644 (file)
@@ -311,9 +311,10 @@ Mixer_UI::add_strips (RouteList& routes)
 {
        MixerStrip* strip;
 
-       {
-               Unwinder<bool> uw (no_track_list_redisplay, true);
-               
+       try {
+               no_track_list_redisplay = true;
+               track_display.set_model (Glib::RefPtr<ListStore>());
+
                for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
                        boost::shared_ptr<Route> route = (*x);
                        
@@ -345,7 +346,7 @@ Mixer_UI::add_strips (RouteList& routes)
                        
                        strip = new MixerStrip (*this, _session, route);
                        strips.push_back (strip);
-                       
+
                        Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
                        
                        if (strip->width_owner() != strip) {
@@ -365,8 +366,13 @@ Mixer_UI::add_strips (RouteList& routes)
                        strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
                        strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
                }
+
+       } catch (...) {
        }
 
+       no_track_list_redisplay = false;
+       track_display.set_model (track_model);
+       
        sync_order_keys_from_treeview ();
        redisplay_track_list ();
 }
index 9b25f29c8f3b2d504f04bc78ae9516d6d5c7f125..5e75b4980bf76ed759830b57c56fa78f60864796 100644 (file)
@@ -1269,6 +1269,8 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
        SerializedRCUManager<RouteList>  routes;
 
        void add_routes (RouteList&, bool input_auto_connect, bool output_auto_connect, bool save);
+        void add_routes_inner (RouteList&, bool input_auto_connect, bool output_auto_connect);
+        bool _adding_routes_in_progress;
        uint32_t destructive_index;
 
        boost::shared_ptr<Route> XMLRouteFactory (const XMLNode&, int);
index 69d232079ca79fa988f305f901eea064bd1668e6..90ff62f2a10e5f01cbe342857cf466469bc26e3c 100644 (file)
@@ -227,8 +227,8 @@ AudioEngine::stop (bool forever)
                        disconnect_from_jack ();
                } else {
                        jack_deactivate (_priv_jack);
-                       Stopped(); /* EMIT SIGNAL */
                        MIDI::JackMIDIPort::JackHalted (); /* EMIT SIGNAL */
+                       Stopped(); /* EMIT SIGNAL */
                }
        }
 
@@ -1162,8 +1162,8 @@ AudioEngine::halted (void *arg)
         ae->_jack = 0;
 
        if (was_running) {
-               ae->Halted(""); /* EMIT SIGNAL */
                MIDI::JackMIDIPort::JackHalted (); /* EMIT SIGNAL */
+               ae->Halted(""); /* EMIT SIGNAL */
        }
 }
 
@@ -1410,8 +1410,8 @@ AudioEngine::disconnect_from_jack ()
 
        if (_running) {
                _running = false;
-               Stopped(); /* EMIT SIGNAL */
                MIDI::JackMIDIPort::JackHalted (); /* EMIT SIGNAL */
+               Stopped(); /* EMIT SIGNAL */
        }
 
        return 0;
index da5f956c4bca67b13ec96520e1928e9c49078a94..80eab3571f7d9500e602aa13a8c22602491c1253 100644 (file)
@@ -2135,6 +2135,31 @@ Session::new_route_from_template (uint32_t how_many, const std::string& template
 
 void
 Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output_auto_connect, bool save)
+{
+       try {
+               PBD::Unwinder<bool> aip (_adding_routes_in_progress, true);
+               add_routes_inner (new_routes, input_auto_connect, output_auto_connect);
+
+       } catch (...) {
+               error << _("Adding new tracks/busses failed") << endmsg;
+       }
+
+       graph_reordered ();
+
+       update_latency (true);
+       update_latency (false);
+               
+       set_dirty();
+       
+       if (save) {
+               save_state (_current_snapshot_name);
+       }
+       
+       RouteAdded (new_routes); /* EMIT SIGNAL */
+}
+
+void
+Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool output_auto_connect)
 {
         ChanCount existing_inputs;
         ChanCount existing_outputs;
@@ -2191,6 +2216,7 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output
                        }
                }
 
+
                if (input_auto_connect || output_auto_connect) {
                        auto_connect_route (r, existing_inputs, existing_outputs, true, input_auto_connect);
                }
@@ -2199,7 +2225,7 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output
                   reasonable defaults because they also affect the remote control
                   ID in most situations.
                */
-               
+
                if (!r->has_order_key (EditorSort)) {
                        if (r->is_hidden()) {
                                /* use an arbitrarily high value */
@@ -2215,31 +2241,18 @@ Session::add_routes (RouteList& new_routes, bool input_auto_connect, bool output
        }
 
        if (_monitor_out && IO::connecting_legal) {
-
-               {
-                       Glib::Threads::Mutex::Lock lm (_engine.process_lock());         
-                       
-                       for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) {
-                               if ((*x)->is_monitor()) {
-                                       /* relax */
-                               } else if ((*x)->is_master()) {
+               Glib::Threads::Mutex::Lock lm (_engine.process_lock());         
+               
+               for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) {
+                       if ((*x)->is_monitor()) {
+                               /* relax */
+                       } else if ((*x)->is_master()) {
                                        /* relax */
-                               } else {
-                                       (*x)->enable_monitor_send ();
-                               }
+                       } else {
+                               (*x)->enable_monitor_send ();
                        }
                }
-
-               resort_routes ();
        }
-
-       set_dirty();
-
-       if (save) {
-               save_state (_current_snapshot_name);
-       }
-
-       RouteAdded (new_routes); /* EMIT SIGNAL */
 }
 
 void
@@ -3551,7 +3564,7 @@ Session::graph_reordered ()
           from a set_state() call or creating new tracks. Ditto for deletion.
        */
 
-       if (_state_of_the_state & (InitialConnecting|Deletion)) {
+       if ((_state_of_the_state & (InitialConnecting|Deletion)) || _adding_routes_in_progress) {
                return;
        }
 
@@ -4531,7 +4544,7 @@ 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)) {
+       if ((_state_of_the_state & (InitialConnecting|Deletion)) || _adding_routes_in_progress) {
                return;
        }
 
index 74257ef4826d919123e931cc6c28f97416031e0b..a1f457393a13617f0970c3b3daac36474121d799 100644 (file)
@@ -206,6 +206,7 @@ Session::first_stage_init (string fullpath, string snapshot_name)
        _play_range = false;
        _exporting = false;
        pending_abort = false;
+       _adding_routes_in_progress = false;
        destructive_index = 0;
        first_file_data_format_reset = true;
        first_file_header_format_reset = true;