bug 1190291 move mNextStateComputedTime to local variable r=padenot

This commit is contained in:
Karl Tomlinson 2015-07-29 17:13:23 +12:00
parent 6a58379f0a
commit f1ad60438d
2 changed files with 15 additions and 23 deletions

View File

@ -46,7 +46,6 @@ GraphDriver::GraphDriver(MediaStreamGraphImpl* aGraphImpl)
: mIterationStart(0),
mIterationEnd(0),
mStateComputedTime(0),
mNextStateComputedTime(0),
mGraphImpl(aGraphImpl),
mWaitState(WAITSTATE_RUNNING),
mCurrentTimeStamp(TimeStamp::Now()),
@ -57,8 +56,7 @@ GraphDriver::GraphDriver(MediaStreamGraphImpl* aGraphImpl)
void GraphDriver::SetGraphTime(GraphDriver* aPreviousDriver,
GraphTime aLastSwitchNextIterationStart,
GraphTime aLastSwitchNextIterationEnd,
GraphTime aLastSwitchStateComputedTime,
GraphTime aLastSwitchNextStateComputedTime)
GraphTime aLastSwitchStateComputedTime)
{
// We set mIterationEnd here, because the first thing a driver do when it
// does an iteration is to update graph times, so we are in fact setting
@ -67,7 +65,6 @@ void GraphDriver::SetGraphTime(GraphDriver* aPreviousDriver,
mIterationStart = aLastSwitchNextIterationStart;
mIterationEnd = aLastSwitchNextIterationEnd;
mStateComputedTime = aLastSwitchStateComputedTime;
mNextStateComputedTime = aLastSwitchNextStateComputedTime;
STREAM_LOG(LogLevel::Debug, ("Setting previous driver: %p (%s)", aPreviousDriver, aPreviousDriver->AsAudioCallbackDriver() ? "AudioCallbackDriver" : "SystemClockDriver"));
MOZ_ASSERT(!mPreviousDriver);
@ -242,7 +239,7 @@ ThreadedDriver::Revive()
MonitorAutoLock mon(mGraphImpl->GetMonitor());
if (mNextDriver) {
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
mNextDriver->Start();
} else {
@ -295,26 +292,25 @@ ThreadedDriver::RunThread()
STREAM_LOG(LogLevel::Debug, ("Time did not advance"));
}
MOZ_ASSERT(mStateComputedTime == mNextStateComputedTime);
mNextStateComputedTime =
GraphTime nextStateComputedTime =
mGraphImpl->RoundUpToNextAudioBlock(
mIterationEnd + mGraphImpl->MillisecondsToMediaTime(AUDIO_TARGET_MS));
STREAM_LOG(LogLevel::Debug,
("interval[%ld; %ld] state[%ld; %ld]",
(long)mIterationStart, (long)mIterationEnd,
(long)mStateComputedTime, (long)mNextStateComputedTime));
(long)mStateComputedTime, (long)nextStateComputedTime));
mGraphImpl->mFlushSourcesNow = mGraphImpl->mFlushSourcesOnNextIteration;
mGraphImpl->mFlushSourcesOnNextIteration = false;
stillProcessing = mGraphImpl->OneIteration(mIterationStart,
mIterationEnd,
StateComputedTime(),
mNextStateComputedTime);
nextStateComputedTime);
if (mNextDriver && stillProcessing) {
STREAM_LOG(LogLevel::Debug, ("Switching to AudioCallbackDriver"));
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
mNextDriver->Start();
return;
@ -578,7 +574,7 @@ AudioCallbackDriver::Init()
// Fall back to a driver using a normal thread.
mNextDriver = new SystemClockDriver(GraphImpl());
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
DebugOnly<bool> found = mGraphImpl->RemoveMixerCallback(this);
NS_WARN_IF_FALSE(!found, "Mixer callback not added when switching?");
@ -672,7 +668,7 @@ AudioCallbackDriver::Revive()
MonitorAutoLock mon(mGraphImpl->GetMonitor());
if (mNextDriver) {
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
mNextDriver->Start();
} else {
@ -822,12 +818,10 @@ AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames)
// we don't need to run an iteration and if we do so we may overflow.
if (mBuffer.Available()) {
MOZ_ASSERT(mStateComputedTime == mNextStateComputedTime);
// State computed time is decided by the audio callback's buffer length. We
// compute the iteration start and end from there, trying to keep the amount
// of buffering in the graph constant.
mNextStateComputedTime =
GraphTime nextStateComputedTime =
mGraphImpl->RoundUpToNextAudioBlock(mStateComputedTime + mBuffer.Available());
mIterationStart = mIterationEnd;
@ -836,7 +830,7 @@ AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames)
// could use as [mIterationStart; mIterationEnd].
GraphTime inGraph = mStateComputedTime - mIterationStart;
// We want the interval [mIterationStart; mIterationEnd] to be before the
// interval [mStateComputedTime; mNextStateComputedTime]. We also want
// interval [mStateComputedTime; nextStateComputedTime]. We also want
// the distance between these intervals to be roughly equivalent each time, to
// ensure there is no clock drift between current time and state time. Since
// we can't act on the state time because we have to fill the audio buffer, we
@ -845,9 +839,9 @@ AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames)
STREAM_LOG(LogLevel::Debug, ("interval[%ld; %ld] state[%ld; %ld] (frames: %ld) (durationMS: %u) (duration ticks: %ld)\n",
(long)mIterationStart, (long)mIterationEnd,
(long)mStateComputedTime, (long)mNextStateComputedTime,
(long)mStateComputedTime, (long)nextStateComputedTime,
(long)aFrames, (uint32_t)durationMS,
(long)(mNextStateComputedTime - mStateComputedTime)));
(long)(nextStateComputedTime - mStateComputedTime)));
mCurrentTimeStamp = TimeStamp::Now();
@ -859,7 +853,7 @@ AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames)
stillProcessing = mGraphImpl->OneIteration(mIterationStart,
mIterationEnd,
mStateComputedTime,
mNextStateComputedTime);
nextStateComputedTime);
} else {
NS_WARNING("DataCallback buffer filled entirely from scratch buffer, skipping iteration.");
stillProcessing = true;
@ -878,7 +872,7 @@ AudioCallbackDriver::DataCallback(AudioDataValue* aBuffer, long aFrames)
}
STREAM_LOG(LogLevel::Debug, ("Switching to system driver."));
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
mNextDriver->Start();
// Returning less than aFrames starts the draining and eventually stops the
@ -986,7 +980,7 @@ AudioCallbackDriver::DeviceChangedCallback() {
mGraphImpl->mFlushSourcesOnNextIteration = true;
mNextDriver = new SystemClockDriver(GraphImpl());
mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
mStateComputedTime, mNextStateComputedTime);
mStateComputedTime);
mGraphImpl->SetCurrentDriver(mNextDriver);
mNextDriver->Start();
#endif

View File

@ -156,7 +156,6 @@ public:
void SetGraphTime(GraphDriver* aPreviousDriver,
GraphTime aLastSwitchNextIterationStart,
GraphTime aLastSwitchNextIterationEnd,
GraphTime aLastSwitchNextStateComputedTime,
GraphTime aLastSwitchStateComputedTime);
/**
@ -197,7 +196,6 @@ protected:
GraphTime mIterationEnd;
// Time, in the future, for which blocking has been computed.
GraphTime mStateComputedTime;
GraphTime mNextStateComputedTime;
// The MediaStreamGraphImpl that owns this driver. This has a lifetime longer
// than the driver, and will never be null.
MediaStreamGraphImpl* mGraphImpl;