void
AudioNodeStream::SetStreamTimeParameterImpl(uint32_t aIndex, MediaStream* aRelativeToStream,
                                            double aStreamTime)
{
  StreamTime streamTime = std::max<MediaTime>(0, SecondsToMediaTime(aStreamTime));
  GraphTime graphTime = aRelativeToStream->StreamTimeToGraphTime(streamTime);
  StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime);
  TrackTicks ticks = TimeToTicksRoundDown(IdealAudioRate(), thisStreamTime);
  mEngine->SetStreamTimeParameter(aIndex, ticks);
}
示例#2
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;
}
示例#3
0
double
AudioNodeStream::FractionalTicksFromDestinationTime(AudioNodeStream* aDestination,
                                                    double aSeconds)
{
  MOZ_ASSERT(aDestination->SampleRate() == SampleRate());
  MOZ_ASSERT(SampleRate() == GraphRate());

  double destinationSeconds = std::max(0.0, aSeconds);
  double destinationFractionalTicks = destinationSeconds * SampleRate();
  MOZ_ASSERT(destinationFractionalTicks < STREAM_TIME_MAX);
  StreamTime destinationStreamTime = destinationFractionalTicks; // round down
  // MediaTime does not have the resolution of double
  double offset = destinationFractionalTicks - destinationStreamTime;

  GraphTime graphTime =
    aDestination->StreamTimeToGraphTime(destinationStreamTime);
  StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime);
  double thisFractionalTicks = thisStreamTime + offset;
  MOZ_ASSERT(thisFractionalTicks >= 0.0);
  return thisFractionalTicks;
}