use a lock to set/get AutomationList automation state
authorPaul Davis <paul@linuxaudiosystems.com>
Sat, 12 Aug 2017 18:38:56 +0000 (14:38 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Sat, 12 Aug 2017 18:40:21 +0000 (14:40 -0400)
It isn't 100% clear that we should use the list's data lock, but it seems quite likely
that this is the correct design, because of the interlock between data being present
and automation state

libs/ardour/ardour/automation_list.h
libs/ardour/automation_list.cc

index 46643dc6fa037c7f1640a0dbf73c8728d1bbe3af..359d98856c846cebbf08f6631a137afcc1f08e3e 100644 (file)
@@ -85,7 +85,7 @@ public:
        bool paste (const ControlList&, double, DoubleBeatsFramesConverter const&);
 
        void set_automation_state (AutoState);
-       AutoState automation_state() const { return _state; }
+       AutoState automation_state() const;
        PBD::Signal1<void, AutoState> automation_state_changed;
 
        bool automation_playback() const {
index d92e65288f8c9838dd4a90a75434749feaa6e95b..3ffc040b62a01b475b197dc266b098a67671f404 100644 (file)
@@ -192,16 +192,28 @@ AutomationList::maybe_signal_changed ()
        }
 }
 
+AutoState
+AutomationList::automation_state() const
+{
+       Glib::Threads::RWLock::ReaderLock lm (Evoral::ControlList::_lock);
+       return _state;
+}
+
 void
 AutomationList::set_automation_state (AutoState s)
 {
-       if (s == _state) {
-               return;
-       }
-       _state = s;
-       if (s == Write && _desc.toggled) {
-               snapshot_history (true);
+       {
+               Glib::Threads::RWLock::ReaderLock lm (Evoral::ControlList::_lock);
+
+               if (s == _state) {
+                       return;
+               }
+               _state = s;
+               if (s == Write && _desc.toggled) {
+                       snapshot_history (true);
+               }
        }
+
        automation_state_changed (s); /* EMIT SIGNAL */
 }
 
@@ -588,4 +600,3 @@ AutomationListProperty::clone () const
                boost::shared_ptr<AutomationList> (new AutomationList (*this->_current.get()))
                );
 }
-