b=972678 round double times to ticks consistently and round to nearest r=padenot

--HG--
extra : transplant_source : Q%B5%155%81%7C%8BQ4%EB%BD%E9h%A7%8E%94%C9%EC%A2q
This commit is contained in:
Karl Tomlinson 2014-02-17 09:47:19 +13:00
parent 9635368701
commit 07b1c1b640

View File

@ -519,10 +519,20 @@ TrackTicks
AudioNodeStream::TicksFromDestinationTime(MediaStream* aDestination,
double aSeconds)
{
StreamTime streamTime = std::max<MediaTime>(0, SecondsToMediaTime(aSeconds));
MOZ_ASSERT(aDestination->AsAudioNodeStream() &&
aDestination->AsAudioNodeStream()->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);
TrackTicks ticks = TimeToTicksRoundUp(SampleRate(), thisStreamTime);
double thisSeconds = MediaTimeToSeconds(thisStreamTime) + offset;
MOZ_ASSERT(thisSeconds >= 0.0);
// Round to nearest
TrackTicks ticks = thisSeconds * SampleRate() + 0.5;
return ticks;
}