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
This commit is contained in:
Karl Tomlinson 2014-06-12 16:44:58 +12:00
Родитель 9c81aeb06f
Коммит a22b5917c4
2 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -556,13 +556,15 @@ AudioNodeStream::TimeFromDestinationTime(AudioNodeStream* aDestination,
MOZ_ASSERT(aDestination->SampleRate() == SampleRate()); MOZ_ASSERT(aDestination->SampleRate() == SampleRate());
double destinationSeconds = std::max(0.0, aSeconds); double destinationSeconds = std::max(0.0, aSeconds);
StreamTime streamTime = SecondsToMediaTime(destinationSeconds); StreamTime streamTime =
aDestination->SecondsToStreamTimeRoundDown(destinationSeconds);
// MediaTime does not have the resolution of double // MediaTime does not have the resolution of double
double offset = destinationSeconds - MediaTimeToSeconds(streamTime); double offset =
destinationSeconds - aDestination->StreamTimeToSeconds(streamTime);
GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime); GraphTime graphTime = aDestination->StreamTimeToGraphTime(streamTime);
StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime); StreamTime thisStreamTime = GraphTimeToStreamTimeOptimistic(graphTime);
double thisSeconds = MediaTimeToSeconds(thisStreamTime) + offset; double thisSeconds = StreamTimeToSeconds(thisStreamTime) + offset;
MOZ_ASSERT(thisSeconds >= 0.0); MOZ_ASSERT(thisSeconds >= 0.0);
return thisSeconds; return thisSeconds;
} }
@ -588,7 +590,7 @@ AudioNodeStream::DestinationTimeFromTicks(AudioNodeStream* aDestination,
StreamTime sourceTime = TicksToTimeRoundDown(SampleRate(), aPosition); StreamTime sourceTime = TicksToTimeRoundDown(SampleRate(), aPosition);
GraphTime graphTime = StreamTimeToGraphTime(sourceTime); GraphTime graphTime = StreamTimeToGraphTime(sourceTime);
StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime); StreamTime destinationTime = aDestination->GraphTimeToStreamTimeOptimistic(graphTime);
return MediaTimeToSeconds(destinationTime); return StreamTimeToSeconds(destinationTime);
} }
} }

Просмотреть файл

@ -534,7 +534,8 @@ AudioContext::DestinationStream() const
double double
AudioContext::CurrentTime() const AudioContext::CurrentTime() const
{ {
return MediaTimeToSeconds(Destination()->Stream()->GetCurrentTime()) + MediaStream* stream = Destination()->Stream();
return stream->StreamTimeToSeconds(stream->GetCurrentTime()) +
ExtraCurrentTime(); ExtraCurrentTime();
} }