a few strategic LocaleGuards..
authorRobin Gareus <robin@gareus.org>
Sat, 7 May 2016 15:16:59 +0000 (17:16 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 7 May 2016 15:16:59 +0000 (17:16 +0200)
..to prevent switching forth and back during  individual
::state(), ::set_state() when loading/saving the session or locating.

libs/ardour/route.cc
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/ardour/session_transport.cc

index 06a45457851436f8ccbb02562b93b411f543f9d1..79799ce807b9b48b88b2739539055f923da03d10 100644 (file)
@@ -2704,6 +2704,7 @@ Route::get_template()
 XMLNode&
 Route::state(bool full_state)
 {
+       LocaleGuard lg;
        if (!_session._template_state_dir.empty()) {
                assert (!full_state); // only for templates
                foreach_processor (sigc::bind (sigc::mem_fun (*this, &Route::set_plugin_state_dir), _session._template_state_dir));
index 1e19b71755a6b9d9fa7e67f6e40bd84402bce510..cddd85902e6e50afdec609bc3f5125230042ba0c 100644 (file)
@@ -561,6 +561,7 @@ Session::immediately_post_engine ()
        }
 
        try {
+               LocaleGuard lg;
                BootMessage (_("Set up LTC"));
                setup_ltc ();
                BootMessage (_("Set up Click"));
index 764ce16f260c6cd0c659f3503c85fc45dc6b3d8b..05cf89ff0a165fddcc7b19b7617c8ec803a68197 100644 (file)
@@ -1037,6 +1037,7 @@ Session::get_template()
 XMLNode&
 Session::state (bool full_state)
 {
+       LocaleGuard lg;
        XMLNode* node = new XMLNode("Session");
        XMLNode* child;
 
@@ -1298,6 +1299,7 @@ Session::get_control_protocol_state ()
 int
 Session::set_state (const XMLNode& node, int version)
 {
+       LocaleGuard lg;
        XMLNodeList nlist;
        XMLNode* child;
        XMLProperty const * prop;
index f1486ada78144abc89636c940f4d92d9f0b4a5e0..47e0baaf5f03f9b3ec04fdfa8459687ff678871c 100644 (file)
@@ -373,6 +373,12 @@ Session::butler_transport_work ()
        }
 
        if (ptw & PostTransportAdjustPlaybackBuffering) {
+               /* non_realtime_locate() calls Automatable::transport_located()
+                * for every route. This eventually calls
+                * ARDOUR::AutomationList::state () which has a LocaleGuard,
+                * and would switch locales forth/back every time.
+                */
+               LocaleGuard lg;
                for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
                        boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
                        if (tr) {
@@ -421,7 +427,7 @@ Session::butler_transport_work ()
                /* don't seek if locate will take care of that in non_realtime_stop() */
 
                if (!(ptw & PostTransportLocate)) {
-
+                       LocaleGuard lg; // see note for non_realtime_locate() above
                        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
                                (*i)->non_realtime_locate (_transport_frame);
 
@@ -530,9 +536,12 @@ Session::non_realtime_locate ()
        }
 
 
-       boost::shared_ptr<RouteList> rl = routes.reader();
-       for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-               (*i)->non_realtime_locate (_transport_frame);
+       {
+               LocaleGuard lg; // see note for non_realtime_locate() above
+               boost::shared_ptr<RouteList> rl = routes.reader();
+               for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+                       (*i)->non_realtime_locate (_transport_frame);
+               }
        }
 
        _scene_changer->locate (_transport_frame);
@@ -789,15 +798,18 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
 
        /* this for() block can be put inside the previous if() and has the effect of ... ??? what */
 
-       DEBUG_TRACE (DEBUG::Transport, X_("Butler PTW: locate\n"));
-       for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-               DEBUG_TRACE (DEBUG::Transport, string_compose ("Butler PTW: locate on %1\n", (*i)->name()));
-               (*i)->non_realtime_locate (_transport_frame);
+       {
+               LocaleGuard lg; // see note for non_realtime_locate() above
+               DEBUG_TRACE (DEBUG::Transport, X_("Butler PTW: locate\n"));
+               for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+                       DEBUG_TRACE (DEBUG::Transport, string_compose ("Butler PTW: locate on %1\n", (*i)->name()));
+                       (*i)->non_realtime_locate (_transport_frame);
 
-               if (on_entry != g_atomic_int_get (&_butler->should_do_transport_work)) {
-                       finished = false;
-                       /* we will be back */
-                       return;
+                       if (on_entry != g_atomic_int_get (&_butler->should_do_transport_work)) {
+                               finished = false;
+                               /* we will be back */
+                               return;
+                       }
                }
        }