bug 1257718 rename lastEventId to eventIndex r?padenot draft
authorKarl Tomlinson <karlt+@karlt.net>
Fri, 17 Jun 2016 09:36:24 +1200
changeset 380503 c04058c30fef01a90c35e76d98f397bbcad8768b
parent 380502 920df23dda6244eb2579ea67dc4d4315991ce4ba
child 380504 8f1e9208dd2b7d3c50c0b2ddd0f4a3bfa1651f10
push id21234
push userktomlinson@mozilla.com
push dateWed, 22 Jun 2016 05:11:59 +0000
reviewerspadenot
bugs1257718
milestone50.0a1
bug 1257718 rename lastEventId to eventIndex r?padenot This is not necessarily related to the last event and it is not the previous event. MozReview-Commit-ID: 6hhv184BHfg
dom/media/webaudio/AudioEventTimeline.cpp
--- a/dom/media/webaudio/AudioEventTimeline.cpp
+++ b/dom/media/webaudio/AudioEventTimeline.cpp
@@ -136,81 +136,81 @@ AudioEventTimeline::ValidateEvent(AudioT
 // This method computes the AudioParam value at a given time based on the event timeline
 template<class TimeType> void
 AudioEventTimeline::GetValuesAtTimeHelper(TimeType aTime, float* aBuffer,
                                           const size_t aSize)
 {
   MOZ_ASSERT(aBuffer);
   MOZ_ASSERT(aSize);
 
-  size_t lastEventId = 0;
+  size_t eventIndex = 0;
   const AudioTimelineEvent* previous = nullptr;
   const AudioTimelineEvent* next = nullptr;
   bool bailOut = false;
 
   // Let's remove old events except the last one: we need it to calculate some curves.
   while (mEvents.Length() > 1 &&
          aTime > mEvents[1].template Time<TimeType>()) {
     mEvents.RemoveElementAt(0);
   }
 
   for (size_t bufferIndex = 0; bufferIndex < aSize; ++bufferIndex, ++aTime) {
-    for (; !bailOut && lastEventId < mEvents.Length(); ++lastEventId) {
+    for (; !bailOut && eventIndex < mEvents.Length(); ++eventIndex) {
 
 #ifdef DEBUG
-      const AudioTimelineEvent* current = &mEvents[lastEventId];
+      const AudioTimelineEvent* current = &mEvents[eventIndex];
       MOZ_ASSERT(current->mType == AudioTimelineEvent::SetValueAtTime ||
                  current->mType == AudioTimelineEvent::SetTarget ||
                  current->mType == AudioTimelineEvent::LinearRamp ||
                  current->mType == AudioTimelineEvent::ExponentialRamp ||
                  current->mType == AudioTimelineEvent::SetValueCurve);
 #endif
 
-      if (TimesEqual(aTime, mEvents[lastEventId].template Time<TimeType>())) {
+      if (TimesEqual(aTime, mEvents[eventIndex].template Time<TimeType>())) {
         mLastComputedValue = mComputedValue;
         // Find the last event with the same time
-        while (lastEventId < mEvents.Length() - 1 &&
-               TimesEqual(aTime, mEvents[lastEventId + 1].template Time<TimeType>())) {
-          ++lastEventId;
+        while (eventIndex < mEvents.Length() - 1 &&
+               TimesEqual(aTime, mEvents[eventIndex + 1].template Time<TimeType>())) {
+          ++eventIndex;
         }
         break;
       }
 
       previous = next;
-      next = &mEvents[lastEventId];
-      if (aTime < mEvents[lastEventId].template Time<TimeType>()) {
+      next = &mEvents[eventIndex];
+      if (aTime < mEvents[eventIndex].template Time<TimeType>()) {
         bailOut = true;
       }
     }
 
-    if (!bailOut && lastEventId < mEvents.Length()) {
+    if (!bailOut && eventIndex < mEvents.Length()) {
       // The time matches one of the events exactly.
-      MOZ_ASSERT(TimesEqual(aTime, mEvents[lastEventId].template Time<TimeType>()));
+      MOZ_ASSERT(TimesEqual(aTime, mEvents[eventIndex].template Time<TimeType>()));
 
       // SetTarget nodes can be handled no matter what their next node is (if they have one)
-      if (mEvents[lastEventId].mType == AudioTimelineEvent::SetTarget) {
+      if (mEvents[eventIndex].mType == AudioTimelineEvent::SetTarget) {
         // Follow the curve, without regard to the next event, starting at
         // the last value of the last event.
-        aBuffer[bufferIndex] = ExponentialApproach(mEvents[lastEventId].template Time<TimeType>(),
-                                                mLastComputedValue, mEvents[lastEventId].mValue,
-                                                mEvents[lastEventId].mTimeConstant, aTime);
+        aBuffer[bufferIndex] = ExponentialApproach(mEvents[eventIndex].template Time<TimeType>(),
+                                                mLastComputedValue, mEvents[eventIndex].mValue,
+                                                mEvents[eventIndex].mTimeConstant, aTime);
         continue;
       }
 
       // SetValueCurve events can be handled no matter what their event node is (if they have one)
-      if (mEvents[lastEventId].mType == AudioTimelineEvent::SetValueCurve) {
-        aBuffer[bufferIndex] = ExtractValueFromCurve(mEvents[lastEventId].template Time<TimeType>(),
-                                                  mEvents[lastEventId].mCurve,
-                                                  mEvents[lastEventId].mCurveLength,
-                                                  mEvents[lastEventId].mDuration, aTime);
+      if (mEvents[eventIndex].mType == AudioTimelineEvent::SetValueCurve) {
+        aBuffer[bufferIndex] = ExtractValueFromCurve(mEvents[eventIndex].template Time<TimeType>(),
+                                                  mEvents[eventIndex].mCurve,
+                                                  mEvents[eventIndex].mCurveLength,
+                                                  mEvents[eventIndex].mDuration, aTime);
         continue;
       }
 
       // For other event types
-      aBuffer[bufferIndex] = mEvents[lastEventId].mValue;
+      aBuffer[bufferIndex] = mEvents[eventIndex].mValue;
       continue;
     }
 
     // Handle the case where the time is past all of the events
     if (!bailOut) {
       aBuffer[bufferIndex] = GetValuesAtTimeHelperInternal(aTime, next, nullptr);
     } else {
       aBuffer[bufferIndex] = GetValuesAtTimeHelperInternal(aTime, previous, next);