Commit 32550fff authored by Raymond Toy's avatar Raymond Toy Committed by Commit Bot

Optimize AudioParam if some events are in the future

If the first event in the timeline starts after the current
render quantum and the event is a setTarget, setValue, or
setValueCurve, we don't need to do sample-accurate processing
because they haven't started yet.

Bug: 1013539
Change-Id: If62c6c0e12b8f76c5f3d6db6216c929c775c39ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1856874Reviewed-by: default avatarAndrew MacPherson <andrew.macpherson@soundtrap.com>
Commit-Queue: Raymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706930}
parent ee666ded
......@@ -621,6 +621,25 @@ bool AudioParamTimeline::HasValues(size_t current_frame,
if (n_events == 0)
return false;
// Handle the case where the first event (of certain types) is in the
// future. Then, no sample-accurate processing is needed because the event
// hasn't started.
if (events_[0]->Time() >
(current_frame + audio_utilities::kRenderQuantumFrames) / sample_rate) {
switch (events_[0]->GetType()) {
case ParamEvent::kSetTarget:
case ParamEvent::kSetValue:
case ParamEvent::kSetValueCurve:
// If the first event is one of these types, and the event starts
// after the end of the current render quantum, we don't need to do
// the slow sample-accurate path.
return false;
default:
// Handle other event types below.
break;
}
}
// If there are at least 2 events in the timeline, assume there are timeline
// values. This could be optimized to be more careful, but checking is
// complicated and keeping this consistent with |ValuesForFrameRangeImpl()|
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment