diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-07-14 15:42:10 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-07-14 15:42:10 +0000 |
commit | c3ccff8d059735df1f98d3c4db204b00f3498c49 (patch) | |
tree | 29c58dece1d3f69621f6e5086d604dd0d3e3fcf6 /libs/evoral/src/ControlList.cpp | |
parent | 34c6e03ecf80caeb7988550c24b1301204da6eaf (diff) |
fix up part of the remaining details with automation, so that touch/write over-writes work correctly
git-svn-id: svn://localhost/ardour2/branches/3.0@13041 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/evoral/src/ControlList.cpp')
-rw-r--r-- | libs/evoral/src/ControlList.cpp | 47 |
1 files changed, 17 insertions, 30 deletions
diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 9ae269453d..8e46392469 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -545,17 +545,13 @@ ControlList::start_write_pass (double 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 + of where it should be in a "lazy" way - deferring it until + we actually add the first point (which may never happen). + */ - ControlEvent cp (when, 0.0); - insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); - - if ((*insert_iterator)->when != when) { - /* doesn't point at a control point at precisely this time, - so reset it to the end and we'll find where to insert - if/when a new control event is added. - */ - unlocked_invalidate_insert_iterator (); - } + unlocked_invalidate_insert_iterator (); } void @@ -590,8 +586,7 @@ ControlList::add (double when, double value, bool erase_since_last_add) if (new_write_pass) { - DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 new write pass, insert pos = %2, iter @ end ? %3\n", - this, insert_position, (insert_iterator == _events.end()))); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 new write pass, insert pos = %2\n", this, insert_position)); /* The first addition of a new control event during a * write pass. @@ -600,21 +595,18 @@ ControlList::add (double when, double value, bool erase_since_last_add) * corresponding the value there. */ - if (insert_iterator == _events.end()) { - /* the insert_iterator is not set, figure out where - * it needs to be. - */ - - ControlEvent cp (insert_position, 0.0); - insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); - DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 looked up insert iterator for new write pass\n", this)); - } + /* the insert_iterator is not set, figure out where + * it needs to be. + */ + + ControlEvent cp (insert_position, 0.0); + insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 looked up insert iterator for new write pass\n", this)); double eval_value = unlocked_eval (insert_position); if (insert_iterator == _events.end()) { DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 insert iterator at end, adding eval-value there %2\n", this, eval_value)); - _events.push_back (new ControlEvent (insert_position, eval_value)); /* leave insert iterator at the end */ @@ -698,14 +690,9 @@ ControlList::add (double when, double value, bool erase_since_last_add) } else { - DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 find based on lower bound, erase = %2\n", this, erase_since_last_add)); - - /* the new point is somewhere within the list, - * so figure out where to insert - */ - - ControlEvent cp (when, 0.0); - insert_iterator = lower_bound (_events.begin(), _events.end(), &cp, time_comparator); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 erase %2 from existing iterator (@end ? %3\n", + this, erase_since_last_add, + (insert_iterator == _events.end()))); while (insert_iterator != _events.end()) { if ((*insert_iterator)->when < when) { |