Fix potential deadlock on session-load
[ardour.git] / libs / ardour / diskstream.cc
index 1e5cc0c7c189e9055868ceba30158224c9633e3b..a81c1e473d2a64548c29a5beb2880fd0f4bd8495 100644 (file)
@@ -46,7 +46,7 @@
 #include "ardour/session.h"
 #include "ardour/track.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 #include <locale.h>
 
 using namespace std;
@@ -260,6 +260,16 @@ Diskstream::set_capture_offset ()
                _capture_offset = 0;
                break;
        }
+#ifdef MIXBUS
+       framecnt_t port_offset;
+       if (_track->mixbus_internal_bounce (port_offset)) {
+               /* _capture_offset may become negative, but the sum
+                * _capture_offset + existing_material_offset
+                * will be postive.
+                */
+               _capture_offset -= port_offset;
+       }
+#endif
 
         DEBUG_TRACE (DEBUG::CaptureAlignment, string_compose ("%1: using IO latency, capture offset set to %2 with style = %3\n", name(), _capture_offset, enum_2_string (_alignment_style)));
 }
@@ -380,7 +390,7 @@ Diskstream::use_playlist (boost::shared_ptr<Playlist> playlist)
                _playlist = playlist;
                _playlist->use();
 
-               if (!in_set_state && recordable()) {
+               if (!in_set_state && destructive() && recordable()) {
                        reset_write_sources (false);
                }
 
@@ -461,7 +471,7 @@ Diskstream::get_state ()
 {
        XMLNode* node = new XMLNode ("Diskstream");
         char buf[64];
-       LocaleGuard lg (X_("C"));
+       LocaleGuard lg;
 
        node->add_property ("flags", enum_2_string (_flags));
        node->add_property ("playlist", _playlist->name());
@@ -568,7 +578,9 @@ Diskstream::playlist_ranges_moved (list< Evoral::RangeMove<framepos_t> > const &
                         continue;
                 }
                 boost::shared_ptr<AutomationList> alist = ac->alist();
-
+               if (!alist->size()) {
+                       continue;
+               }
                 XMLNode & before = alist->get_state ();
                 bool const things_moved = alist->move_ranges (movements);
                 if (things_moved) {
@@ -598,6 +610,9 @@ Diskstream::move_processor_automation (boost::weak_ptr<Processor> p, list< Evora
 
        for (set<Evoral::Parameter>::const_iterator i = a.begin (); i != a.end (); ++i) {
                boost::shared_ptr<AutomationList> al = processor->automation_control(*i)->alist();
+               if (!al->size()) {
+                       continue;
+               }
                XMLNode & before = al->get_state ();
                bool const things_moved = al->move_ranges (movements);
                if (things_moved) {