Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp

Issue 2623563002: Sort event list if any event time was clamped (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
index 182465bd71f14cdad4b01231585a49e0326eef01..5a5448d901ce3a5300f79910aa774055975cf4c1 100644
--- a/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.cpp
@@ -471,6 +471,7 @@ float AudioParamTimeline::valuesForFrameRangeImpl(size_t startFrame,
int numberOfEvents = m_events.size();
if (numberOfEvents > 0) {
+ bool clampedSomeEventTime = false;
double currentTime = startFrame / sampleRate;
// Look at all the events in the timeline and check to see if any needs
@@ -482,8 +483,10 @@ float AudioParamTimeline::valuesForFrameRangeImpl(size_t startFrame,
// in the past so clamp the event time to the current time (start of
// the rendering quantum).
if (event.needsTimeClampCheck()) {
- if (event.time() < currentTime)
+ if (event.time() < currentTime) {
event.setTime(currentTime);
+ clampedSomeEventTime = true;
+ }
// In all cases, we can clear the flag because the event is either
// in the future, or we've already checked it (just now).
@@ -491,6 +494,14 @@ float AudioParamTimeline::valuesForFrameRangeImpl(size_t startFrame,
}
}
+ if (clampedSomeEventTime) {
+ // If we clamped some event time to current time, we need to
+ // sort the event list in time order again, but it must be
+ // stable!
+ std::stable_sort(m_events.begin(), m_events.end(),
+ ParamEvent::eventPreceeds);
+ }
+
// Optimize the case where the last event is in the past.
ParamEvent& lastEvent = m_events[m_events.size() - 1];
ParamEvent::Type lastEventType = lastEvent.getType();
@@ -646,6 +657,7 @@ float AudioParamTimeline::valuesForFrameRangeImpl(size_t startFrame,
float value2 = nextEvent ? nextEvent->value() : value1;
double time2 = nextEvent ? nextEvent->time() : endFrame / sampleRate + 1;
+ DCHECK_GE(time2, time1);
double deltaTime = time2 - time1;
float k = deltaTime > 0 ? 1 / deltaTime : 0;
« no previous file with comments | « third_party/WebKit/Source/modules/webaudio/AudioParamTimeline.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698