コード例 #1
0
void
ThreadedDriver::RunThread()
{
  AutoProfilerUnregisterThread autoUnregister;

  bool stillProcessing = true;
  while (stillProcessing) {
    GraphTime prevCurrentTime, nextCurrentTime;
    GetIntervalForIteration(prevCurrentTime, nextCurrentTime);

    mStateComputedTime = mNextStateComputedTime;
    mNextStateComputedTime =
      mGraphImpl->RoundUpToNextAudioBlock(
        nextCurrentTime + mGraphImpl->MillisecondsToMediaTime(AUDIO_TARGET_MS));
    STREAM_LOG(PR_LOG_DEBUG,
               ("interval[%ld; %ld] state[%ld; %ld]",
               (long)mIterationStart, (long)mIterationEnd,
               (long)mStateComputedTime, (long)mNextStateComputedTime));

    stillProcessing = mGraphImpl->OneIteration(prevCurrentTime,
                                               nextCurrentTime,
                                               StateComputedTime(),
                                               mNextStateComputedTime);

    if (mNextDriver && stillProcessing) {
      STREAM_LOG(PR_LOG_DEBUG, ("Switching to AudioCallbackDriver"));
      mNextDriver->SetGraphTime(this, mIterationStart, mIterationEnd,
                                 mStateComputedTime, mNextStateComputedTime);
      mGraphImpl->SetCurrentDriver(mNextDriver);
      mNextDriver->Start();
      return;
    }
  }
}
コード例 #2
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;
        }
    }
}