From d2bcfc07471645214e81b2d7284aabd16c6e25df Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 8 Mar 2011 12:34:25 +0000 Subject: [PATCH] Allow out-of-time-order writes to nascent event list, sorting before merge. Fixes #3537. git-svn-id: svn://localhost/ardour2/branches/3.0@9103 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/evoral/src/ControlList.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 6738e8c1ac..f88bda323e 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -223,6 +223,13 @@ ControlList::write_pass_finished (double when) merge_nascent (when); } + +struct ControlEventTimeComparator { + bool operator() (ControlEvent* a, ControlEvent* b) { + return a->when < b->when; + } +}; + void ControlList::merge_nascent (double when) { @@ -244,6 +251,8 @@ ControlList::merge_nascent (double when) delete ninfo; continue; } + + nascent_events.sort (ControlEventTimeComparator ()); if (ninfo->start_time < 0.0) { ninfo->start_time = nascent_events.front()->when; @@ -372,9 +381,9 @@ ControlList::rt_add (double when, double value) if (lm.locked()) { assert (!nascent.empty()); - if (!nascent.back()->events.empty()) { - assert (when > nascent.back()->events.back()->when); - } + /* we don't worry about adding events out of time order as we will + sort them in merge_nascent. + */ nascent.back()->events.push_back (new ControlEvent (when, value)); } }