From a22b5917c4659e59a6f7958ef5712c5910d6d61c Mon Sep 17 00:00:00 2001 From: Karl Tomlinson Date: Thu, 12 Jun 2014 16:44:58 +1200 Subject: [PATCH] b=1023697 use MediaStream to convert between stream time and seconds in Web Audio r=roc --HG-- extra : transplant_source : %FE%C77k/%25%B4%25F%FB1%EAAqn%CA%DEH%06%C0 --- content/media/AudioNodeStream.cpp | 10 ++++++---- content/media/webaudio/AudioContext.cpp | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/content/media/AudioNodeStream.cpp b/content/media/AudioNodeStream.cpp index 928e74774fcd..ddab6143e391 100644 --- a/content/media/AudioNodeStream.cpp +++ b/content/media/AudioNodeStream.cpp @@ -556,13 +556,15 @@ AudioNodeStream::TimeFromDestinationTime(AudioNodeStream* aDestination, MOZ_ASSERT(aDestination->SampleRate() == SampleRate()); double destinationSeconds = std::max(0.0, aSeconds); - StreamTime streamTime = SecondsToMediaTime(destinationSeconds); + StreamTime streamTime = + aDestination->SecondsToStreamTimeRoundDown(destinationSeconds); // MediaTime does not have the resolution of double - double offset = destinationSeconds - MediaTimeToSeconds(streamTime); + double offset = + destinationSeconds - aDestination->StreamTimeToSeconds(streamTime); GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime); StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime); - double thisSeconds = MediaTimeToSeconds(thisStreamTime) + offset; + double thisSeconds = StreamTimeToSeconds(thisStreamTime) + offset; MOZ_ASSERT(thisSeconds >= 0.0); return thisSeconds; } @@ -588,7 +590,7 @@ AudioNodeStream::DestinationTimeFromTicks(AudioNodeStream* aDestination, StreamTime sourceTime = TicksToTimeRoundDown(SampleRate(), aPosition); GraphTime graphTime = StreamTimeToGraphTime(sourceTime); StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime); - return MediaTimeToSeconds(destinationTime); + return StreamTimeToSeconds(destinationTime); } } diff --git a/content/media/webaudio/AudioContext.cpp b/content/media/webaudio/AudioContext.cpp index 62ccd3d1b399..52976550e733 100644 --- a/content/media/webaudio/AudioContext.cpp +++ b/content/media/webaudio/AudioContext.cpp @@ -534,7 +534,8 @@ AudioContext::DestinationStream() const double AudioContext::CurrentTime() const { - return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime()) + + MediaStream* stream = Destination()->Stream(); + return stream->StreamTimeToSeconds(stream->GetCurrentTime()) + ExtraCurrentTime(); }