Example #1
0
double
AudioNodeStream::TimeFromDestinationTime(AudioNodeStream* aDestination,
                                         double aSeconds)
{
  MOZ_ASSERT(aDestination->SampleRate() == SampleRate());

  double destinationSeconds = std::max(0.0, aSeconds);
  StreamTime streamTime = SecondsToMediaTime(destinationSeconds);
  // MediaTime does not have the resolution of double
  double offset = destinationSeconds - MediaTimeToSeconds(streamTime);

  GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime);
  StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime);
  double thisSeconds = MediaTimeToSeconds(thisStreamTime) + offset;
  MOZ_ASSERT(thisSeconds >= 0.0);
  return thisSeconds;
}
Example #2
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);
}
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);
}
Example #4
0
double
AudioContext::CurrentTime() const
{
  return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime()) +
      ExtraCurrentTime();
}