示例#1
0
void
SystemClockDriver::GetIntervalForIteration(GraphTime& aFrom, GraphTime& aTo)
{
  TimeStamp now = TimeStamp::Now();
  aFrom = mIterationStart = IterationEnd();
  aTo = mIterationEnd = mGraphImpl->SecondsToMediaTime((now - mCurrentTimeStamp).ToSeconds()) + IterationEnd();

  mCurrentTimeStamp = now;

  PR_LOG(gMediaStreamGraphLog, PR_LOG_DEBUG+1, ("Updating current time to %f (real %f, mStateComputedTime %f)",
         mGraphImpl->MediaTimeToSeconds(aTo),
         (now - mInitialTimeStamp).ToSeconds(),
         mGraphImpl->MediaTimeToSeconds(StateComputedTime())));

  if (mStateComputedTime < aTo) {
    STREAM_LOG(PR_LOG_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(PR_LOG_DEBUG, ("Time did not advance"));
  }
}
示例#2
0
void
OfflineClockDriver::GetIntervalForIteration(GraphTime& aFrom, GraphTime& aTo)
{
  aFrom = mIterationStart = IterationEnd();
  aTo = mIterationEnd = IterationEnd() + mGraphImpl->MillisecondsToMediaTime(mSlice);

  if (mStateComputedTime < aTo) {
    STREAM_LOG(PR_LOG_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(PR_LOG_DEBUG, ("Time did not advance"));
  }
}
示例#3
0
void
ThreadedDriver::RunThread()
{
    AutoProfilerUnregisterThread autoUnregister;

    bool stillProcessing = true;
    while (stillProcessing) {
        mIterationStart = IterationEnd();
        mIterationEnd += GetIntervalForIteration();

        GraphTime stateComputedTime = StateComputedTime();
        if (stateComputedTime < mIterationEnd) {
            STREAM_LOG(LogLevel::Warning, ("Media graph global underrun detected"));
            mIterationEnd = stateComputedTime;
        }

        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"));
        }

        GraphTime nextStateComputedTime =
            mGraphImpl->RoundUpToNextAudioBlock(
                mIterationEnd + mGraphImpl->MillisecondsToMediaTime(AUDIO_TARGET_MS));
        if (nextStateComputedTime < stateComputedTime) {
            // A previous driver may have been processing further ahead of
            // iterationEnd.
            STREAM_LOG(LogLevel::Warning,
                       ("Prevent state from going backwards. interval[%ld; %ld] state[%ld; %ld]",
                        (long)mIterationStart, (long)mIterationEnd,
                        (long)stateComputedTime, (long)nextStateComputedTime));
            nextStateComputedTime = stateComputedTime;
        }
        STREAM_LOG(LogLevel::Debug,
                   ("interval[%ld; %ld] state[%ld; %ld]",
                    (long)mIterationStart, (long)mIterationEnd,
                    (long)stateComputedTime, (long)nextStateComputedTime));

        stillProcessing = mGraphImpl->OneIteration(nextStateComputedTime);

        if (mNextDriver && stillProcessing) {
            STREAM_LOG(LogLevel::Debug, ("Switching to AudioCallbackDriver"));
            mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd);
            mGraphImpl->SetCurrentDriver(mNextDriver);
            mNextDriver->Start();
            return;
        }
    }
}
示例#4
0
MediaTime
SystemClockDriver::GetIntervalForIteration()
{
    TimeStamp now = TimeStamp::Now();
    MediaTime interval =
        mGraphImpl->SecondsToMediaTime((now - mCurrentTimeStamp).ToSeconds());
    mCurrentTimeStamp = now;

    MOZ_LOG(gMediaStreamGraphLog, LogLevel::Verbose,
            ("Updating current time to %f (real %f, StateComputedTime() %f)",
             mGraphImpl->MediaTimeToSeconds(IterationEnd() + interval),
             (now - mInitialTimeStamp).ToSeconds(),
             mGraphImpl->MediaTimeToSeconds(StateComputedTime())));

    return interval;
}
示例#5
0
GraphTime
SystemClockDriver::GetCurrentTime()
{
  return IterationEnd();
}