Ejemplo n.º 1
0
double
AudioNodeStream::DestinationTimeFromTicks(AudioNodeStream* aDestination,
                                          TrackTicks aPosition)
{
  MOZ_ASSERT(SampleRate() == aDestination->SampleRate());
  StreamTime sourceTime = TicksToTimeRoundDown(SampleRate(), aPosition);
  GraphTime graphTime = StreamTimeToGraphTime(sourceTime);
  StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime);
  return MediaTimeToSeconds(destinationTime);
}
  static int64_t Convert(double aTime, void* aClosure)
  {
    TrackRate sampleRate = IdealAudioRate();

    ConvertTimeToTickHelper* This = static_cast<ConvertTimeToTickHelper*> (aClosure);
    TrackTicks tick = This->mSourceStream->GetCurrentPosition();
    StreamTime streamTime = TicksToTimeRoundDown(sampleRate, tick);
    GraphTime graphTime = This->mSourceStream->StreamTimeToGraphTime(streamTime);
    StreamTime destinationStreamTime = This->mDestinationStream->GraphTimeToStreamTime(graphTime);
    return TimeToTicksRoundDown(sampleRate, destinationStreamTime + SecondsToMediaTime(aTime));
  }
double
WebAudioUtils::StreamPositionToDestinationTime(TrackTicks aSourcePosition,
                                               AudioNodeStream* aSource,
                                               AudioNodeStream* aDestination)
{
  MOZ_ASSERT(aSource->SampleRate() == aDestination->SampleRate());
  StreamTime sourceTime = TicksToTimeRoundDown(aSource->SampleRate(), aSourcePosition);
  GraphTime graphTime = aSource->StreamTimeToGraphTime(sourceTime);
  StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime);
  return MediaTimeToSeconds(destinationTime);
}