Bug 1228226 - Fix clicks with new playing AudioContext; r=padenot

When switching from the SystemClockDriver to another driver, for instance,
during a page reload or reopening a closed tab, the first iteration will
execute on the SystemClockDriver which can cause clicking when the switch
actually occurs if part of the ramp up is lost. This changes the iteration
time period so that no time advances when a switch from the SystemClockDriver
is in progress.

MozReview-Commit-ID: 8uEBsJc0vPR

--HG--
extra : rebase_source : be9fe176533a4027db47ccc4ff568e89624e711f
This commit is contained in:
Dan Minor 2016-09-26 14:04:56 -04:00
parent c85b098ed5
commit 34b4dad43f

View File

@ -1255,8 +1255,6 @@ MediaStreamGraphImpl::UpdateGraph(GraphTime aEndBlockingDecisions)
// been woken up right after having been to sleep.
MOZ_ASSERT(aEndBlockingDecisions >= mStateComputedTime);
UpdateStreamOrder();
bool ensureNextIteration = false;
// Grab pending stream input and compute blocking time
@ -1405,7 +1403,22 @@ MediaStreamGraphImpl::OneIteration(GraphTime aStateEnd)
// Process graph message from the main thread for this iteration.
RunMessagesInQueue();
UpdateStreamOrder();
bool switchingFromSystemClockDriver = false;
{
MonitorAutoLock mon(mMonitor);
switchingFromSystemClockDriver = CurrentDriver()->AsSystemClockDriver() && CurrentDriver()->Switching();
}
GraphTime stateEnd = std::min(aStateEnd, mEndTime);
// See Bug 1228226 - If we're switching from the SystemClockDriver, we
// don't want time to advance until after the switch.
if (switchingFromSystemClockDriver) {
stateEnd = mProcessedTime;
}
UpdateGraph(stateEnd);
mStateComputedTime = stateEnd;