Fix MIDI selection/tool issues (issue #0002415 and other bugs).
[ardour.git] / libs / ardour / automation_event.cc
index ccf3c35104920d5bd590d7c5bedf5ed5bf905298..af390953f424aa660b773efa64501a130e2f85f4 100644 (file)
@@ -55,6 +55,7 @@ static void dumpit (const AutomationList& al, string prefix = "")
 }
 #endif
 
+/* XXX: min_val max_val redundant? (param.min() param.max()) */
 AutomationList::AutomationList (Parameter id, double min_val, double max_val, double default_val)
        : _parameter(id)
        , _interpolation(Linear)
@@ -395,6 +396,7 @@ AutomationList::fast_simple_add (double when, double value)
 {
        /* to be used only for loading pre-sorted data from saved state */
        _events.insert (_events.end(), new ControlEvent (when, value));
+       assert(_events.back());
 }
 
 void
@@ -685,7 +687,7 @@ AutomationList::truncate_end (double last_coordinate)
        {
                Glib::Mutex::Lock lm (_lock);
                ControlEvent cp (last_coordinate, 0);
-               list<ControlEvent*>::reverse_iterator i;
+               AutomationList::reverse_iterator i;
                double last_val;
 
                if (_events.empty()) {
@@ -754,7 +756,7 @@ AutomationList::truncate_end (double last_coordinate)
                        uint32_t sz = _events.size();
                        
                        while (i != _events.rend() && sz > 2) {
-                               list<ControlEvent*>::reverse_iterator tmp;
+                               AutomationList::reverse_iterator tmp;
                                
                                tmp = i;
                                ++tmp;
@@ -851,7 +853,7 @@ AutomationList::truncate_start (double overall_length)
                        i = _events.begin();
                        
                        while (i != _events.end() && !_events.empty()) {
-                               list<ControlEvent*>::iterator tmp;
+                               AutomationList::iterator tmp;
                                
                                tmp = i;
                                ++tmp;
@@ -948,6 +950,9 @@ AutomationList::unlocked_eval (double x) const
                return multipoint_eval (x);
                break;
        }
+
+       /*NOTREACHED*/ /* stupid gcc */
+       return 0.0;
 }
 
 double
@@ -1206,7 +1211,7 @@ AutomationList::rt_safe_earliest_event_linear_unlocked (double start, double end
 
                x = first->when + (y - first->value) / (double)slope;
                
-               while ((inclusive && x < start) || x <= start && y != next->value) {
+               while ((inclusive && x < start) || (x <= start && y != next->value)) {
                        
                        if (first->value < next->value) // ramping up
                                y += 1.0;