summaryrefslogtreecommitdiff
path: root/libs/evoral
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-07-24 20:54:32 +0200
committerRobin Gareus <robin@gareus.org>2017-07-24 21:00:12 +0200
commita41198305ebb727e02a2b9e0d973b963f51b93fe (patch)
tree6c136c1dc8882747f8446c8189bea52c991306b2 /libs/evoral
parent8c260a647a72e63bb16b1f7d2e732ae286edb38d (diff)
Update WritePass logic + AutomationList Undo
Fixes various issues when changing AutomationState while rolling.
Diffstat (limited to 'libs/evoral')
-rw-r--r--libs/evoral/evoral/ControlList.hpp3
-rw-r--r--libs/evoral/src/ControlList.cpp42
2 files changed, 34 insertions, 11 deletions
diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp
index 4aececf40d..3d70fbdda4 100644
--- a/libs/evoral/evoral/ControlList.hpp
+++ b/libs/evoral/evoral/ControlList.hpp
@@ -307,6 +307,7 @@ public:
bool in_write_pass () const;
bool in_new_write_pass () { return new_write_pass; }
+ PBD::Signal0<void> WritePassStarted;
/** Emitted when mark_dirty() is called on this object */
mutable PBD::Signal0<void> Dirty;
/** Emitted when our interpolation style changes */
@@ -359,6 +360,8 @@ private:
void unlocked_remove_duplicates ();
void unlocked_invalidate_insert_iterator ();
void add_guard_point (double when, double offset);
+
+ bool is_sorted () const;
};
} // namespace Evoral
diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp
index 0bba1dba11..801d8562c4 100644
--- a/libs/evoral/src/ControlList.cpp
+++ b/libs/evoral/src/ControlList.cpp
@@ -119,7 +119,7 @@ ControlList::ControlList (const ControlList& other, double start, double end)
copy_events (*(section.get()));
}
- new_write_pass = false;
+ new_write_pass = true;
_in_write_pass = false;
did_write_during_pass = false;
insert_position = -1;
@@ -346,6 +346,8 @@ ControlList::thin (double thinning_factor)
return;
}
+ assert (is_sorted ());
+
bool changed = false;
{
@@ -457,8 +459,6 @@ ControlList::start_write_pass (double when)
DEBUG_TRACE (DEBUG::ControlList, string_compose ("%1: setup write pass @ %2\n", this, when));
- new_write_pass = true;
- did_write_during_pass = false;
insert_position = when;
/* leave the insert iterator invalid, so that we will do the lookup
@@ -519,12 +519,20 @@ ControlList::add_guard_point (double when, double offset)
}
}
+ /* don't do this again till the next write pass,
+ * unless we're not in a write-pass (transport stopped)
+ */
+ if (_in_write_pass && new_write_pass) {
+ WritePassStarted (); /* EMIT SIGNAL w/WriteLock */
+ new_write_pass = false;
+ }
+
when += offset;
ControlEvent cp (when, 0.0);
most_recent_insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
- double eval_value = unlocked_eval (insert_position);
+ double eval_value = unlocked_eval (when);
if (most_recent_insert_iterator == _events.end()) {
@@ -564,13 +572,6 @@ ControlList::add_guard_point (double when, double offset)
++most_recent_insert_iterator;
}
-
- /* don't do this again till the next write pass,
- * unless we're not in a write-pass (transport stopped)
- */
- if (_in_write_pass) {
- new_write_pass = false;
- }
}
bool
@@ -745,6 +746,7 @@ ControlList::add (double when, double value, bool with_guards, bool with_initial
const ControlEvent cp (when, 0.0);
most_recent_insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator);
}
+ WritePassStarted (); /* EMIT SIGNAL w/WriteLock */
new_write_pass = false;
} else if (_in_write_pass &&
@@ -1983,6 +1985,24 @@ ControlList::operator!= (ControlList const & other) const
);
}
+bool
+ControlList::is_sorted () const
+{
+ Glib::Threads::RWLock::ReaderLock lm (_lock);
+ if (_events.size () == 0) {
+ return true;
+ }
+ const_iterator i = _events.begin();
+ const_iterator n = i;
+ while (++n != _events.end ()) {
+ if (event_time_less_than(*n,*i)) {
+ return false;
+ }
+ ++i;
+ }
+ return true;
+}
+
void
ControlList::dump (ostream& o)
{