зеркало из https://github.com/mozilla/gecko-dev.git
bug 1190285 share ThreadedDriver interval update code r=padenot
--HG-- extra : rebase_source : bb977d7080dbb69d2c485efdf8148f8933f84b0c
This commit is contained in:
Родитель
4ca41a6841
Коммит
db58db72fb
|
@ -280,13 +280,25 @@ ThreadedDriver::RunThread()
|
|||
|
||||
bool stillProcessing = true;
|
||||
while (stillProcessing) {
|
||||
GraphTime prevCurrentTime, nextCurrentTime;
|
||||
GetIntervalForIteration(prevCurrentTime, nextCurrentTime);
|
||||
mIterationStart = IterationEnd();
|
||||
mIterationEnd += GetIntervalForIteration();
|
||||
|
||||
if (mStateComputedTime < mIterationEnd) {
|
||||
STREAM_LOG(LogLevel::Warning, ("Media graph global underrun detected"));
|
||||
mIterationEnd = mStateComputedTime;
|
||||
}
|
||||
|
||||
if (mIterationStart >= mIterationEnd) {
|
||||
NS_ASSERTION(mIterationStart == mIterationEnd ,
|
||||
"Time can't go backwards!");
|
||||
// This could happen due to low clock resolution, maybe?
|
||||
STREAM_LOG(LogLevel::Debug, ("Time did not advance"));
|
||||
}
|
||||
|
||||
mStateComputedTime = mNextStateComputedTime;
|
||||
mNextStateComputedTime =
|
||||
mGraphImpl->RoundUpToNextAudioBlock(
|
||||
nextCurrentTime + mGraphImpl->MillisecondsToMediaTime(AUDIO_TARGET_MS));
|
||||
mIterationEnd + mGraphImpl->MillisecondsToMediaTime(AUDIO_TARGET_MS));
|
||||
STREAM_LOG(LogLevel::Debug,
|
||||
("interval[%ld; %ld] state[%ld; %ld]",
|
||||
(long)mIterationStart, (long)mIterationEnd,
|
||||
|
@ -294,8 +306,8 @@ ThreadedDriver::RunThread()
|
|||
|
||||
mGraphImpl->mFlushSourcesNow = mGraphImpl->mFlushSourcesOnNextIteration;
|
||||
mGraphImpl->mFlushSourcesOnNextIteration = false;
|
||||
stillProcessing = mGraphImpl->OneIteration(prevCurrentTime,
|
||||
nextCurrentTime,
|
||||
stillProcessing = mGraphImpl->OneIteration(mIterationStart,
|
||||
mIterationEnd,
|
||||
StateComputedTime(),
|
||||
mNextStateComputedTime);
|
||||
|
||||
|
@ -310,30 +322,21 @@ ThreadedDriver::RunThread()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
SystemClockDriver::GetIntervalForIteration(GraphTime& aFrom, GraphTime& aTo)
|
||||
MediaTime
|
||||
SystemClockDriver::GetIntervalForIteration()
|
||||
{
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
aFrom = mIterationStart = IterationEnd();
|
||||
aTo = mIterationEnd = mGraphImpl->SecondsToMediaTime((now - mCurrentTimeStamp).ToSeconds()) + IterationEnd();
|
||||
|
||||
MediaTime interval =
|
||||
mGraphImpl->SecondsToMediaTime((now - mCurrentTimeStamp).ToSeconds());
|
||||
mCurrentTimeStamp = now;
|
||||
|
||||
MOZ_LOG(gMediaStreamGraphLog, LogLevel::Verbose, ("Updating current time to %f (real %f, mStateComputedTime %f)",
|
||||
mGraphImpl->MediaTimeToSeconds(aTo),
|
||||
(now - mInitialTimeStamp).ToSeconds(),
|
||||
mGraphImpl->MediaTimeToSeconds(StateComputedTime())));
|
||||
MOZ_LOG(gMediaStreamGraphLog, LogLevel::Verbose,
|
||||
("Updating current time to %f (real %f, mStateComputedTime %f)",
|
||||
mGraphImpl->MediaTimeToSeconds(IterationEnd() + interval),
|
||||
(now - mInitialTimeStamp).ToSeconds(),
|
||||
mGraphImpl->MediaTimeToSeconds(StateComputedTime())));
|
||||
|
||||
if (mStateComputedTime < aTo) {
|
||||
STREAM_LOG(LogLevel::Warning, ("Media graph global underrun detected"));
|
||||
aTo = mIterationEnd = mStateComputedTime;
|
||||
}
|
||||
|
||||
if (aFrom >= aTo) {
|
||||
NS_ASSERTION(aFrom == aTo , "Time can't go backwards!");
|
||||
// This could happen due to low clock resolution, maybe?
|
||||
STREAM_LOG(LogLevel::Debug, ("Time did not advance"));
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
|
||||
TimeStamp
|
||||
|
@ -426,22 +429,10 @@ OfflineClockDriver::~OfflineClockDriver()
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
OfflineClockDriver::GetIntervalForIteration(GraphTime& aFrom, GraphTime& aTo)
|
||||
MediaTime
|
||||
OfflineClockDriver::GetIntervalForIteration()
|
||||
{
|
||||
aFrom = mIterationStart = IterationEnd();
|
||||
aTo = mIterationEnd = IterationEnd() + mGraphImpl->MillisecondsToMediaTime(mSlice);
|
||||
|
||||
if (mStateComputedTime < aTo) {
|
||||
STREAM_LOG(LogLevel::Warning, ("Media graph global underrun detected"));
|
||||
aTo = mIterationEnd = mStateComputedTime;
|
||||
}
|
||||
|
||||
if (aFrom >= aTo) {
|
||||
NS_ASSERTION(aFrom == aTo , "Time can't go backwards!");
|
||||
// This could happen due to low clock resolution, maybe?
|
||||
STREAM_LOG(LogLevel::Debug, ("Time did not advance"));
|
||||
}
|
||||
return mGraphImpl->MillisecondsToMediaTime(mSlice);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -256,9 +256,10 @@ public:
|
|||
virtual bool OnThread() override { return !mThread || NS_GetCurrentThread() == mThread; }
|
||||
|
||||
/* When the graph wakes up to do an iteration, implementations return the
|
||||
* range of time that will be processed. */
|
||||
virtual void GetIntervalForIteration(GraphTime& aFrom,
|
||||
GraphTime& aTo) = 0;
|
||||
* range of time that will be processed. This is called only once per
|
||||
* iteration; it may determine the interval from state in a previous
|
||||
* call. */
|
||||
virtual MediaTime GetIntervalForIteration() = 0;
|
||||
protected:
|
||||
nsCOMPtr<nsIThread> mThread;
|
||||
};
|
||||
|
@ -272,8 +273,7 @@ class SystemClockDriver : public ThreadedDriver
|
|||
public:
|
||||
explicit SystemClockDriver(MediaStreamGraphImpl* aGraphImpl);
|
||||
virtual ~SystemClockDriver();
|
||||
virtual void GetIntervalForIteration(GraphTime& aFrom,
|
||||
GraphTime& aTo) override;
|
||||
virtual MediaTime GetIntervalForIteration() override;
|
||||
virtual void WaitForNextIteration() override;
|
||||
virtual void WakeUp() override;
|
||||
|
||||
|
@ -292,8 +292,7 @@ class OfflineClockDriver : public ThreadedDriver
|
|||
public:
|
||||
OfflineClockDriver(MediaStreamGraphImpl* aGraphImpl, GraphTime aSlice);
|
||||
virtual ~OfflineClockDriver();
|
||||
virtual void GetIntervalForIteration(GraphTime& aFrom,
|
||||
GraphTime& aTo) override;
|
||||
virtual MediaTime GetIntervalForIteration() override;
|
||||
virtual void WaitForNextIteration() override;
|
||||
virtual void WakeUp() override;
|
||||
virtual TimeStamp GetCurrentTimeStamp() override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче