commit 49d0c6389eea055e94a8fb492bd95de56b9111a4 Author: Arthur Edelstein arthuredelstein@gmail.com Date: Fri May 27 12:39:10 2016 -0700
fixup! Bug 1517: Reduce precision of time for Javascript. --- dom/html/HTMLMediaElement.cpp | 8 +++++++- dom/html/HTMLMediaElement.h | 3 +++ dom/media/DOMMediaStream.cpp | 3 ++- dom/media/webaudio/AudioContext.cpp | 6 ++++-- 4 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 393ddb1..6bd644c 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -1403,7 +1403,7 @@ NS_IMETHODIMP HTMLMediaElement::GetSeeking(bool* aSeeking) }
double -HTMLMediaElement::CurrentTime() const +HTMLMediaElement::CurrentTimeImpl() const { if (MediaStream* stream = GetSrcMediaStream()) { if (mSrcStreamPausedCurrentTime >= 0) { @@ -1419,6 +1419,12 @@ HTMLMediaElement::CurrentTime() const return mDefaultPlaybackStartPosition; }
+double +HTMLMediaElement::CurrentTime() const +{ + return floor(10 * CurrentTimeImpl()) / 10; +} + NS_IMETHODIMP HTMLMediaElement::GetCurrentTime(double* aCurrentTime) { *aCurrentTime = CurrentTime(); diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index ed95ad6..3909e50 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1527,6 +1527,9 @@ private: // initially be set to zero seconds. This time is used to allow the element to // be seeked even before the media is loaded. double mDefaultPlaybackStartPosition; + + // The unrounded current time + double CurrentTimeImpl() const; };
} // namespace dom diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index fc56140..40d09c3 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -448,8 +448,9 @@ DOMMediaStream::CurrentTime() if (!mPlaybackStream) { return 0.0; } - return mPlaybackStream-> + double currentTime = mPlaybackStream-> StreamTimeToSeconds(mPlaybackStream->GetCurrentTime() - mLogicalStreamStartTime); + return floor(10 * currentTime) / 10; }
void diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index 2bb4242..c7c399b 100644 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -672,8 +672,10 @@ double AudioContext::CurrentTime() const { MediaStream* stream = Destination()->Stream(); - return stream->StreamTimeToSeconds(stream->GetCurrentTime() + - Destination()->ExtraCurrentTime()); + double currentTime = stream->StreamTimeToSeconds( + stream->GetCurrentTime() + Destination()->ExtraCurrentTime()); + // Round to the latest 100 ms. + return floor(10 * currentTime) / 10; }
void
tor-commits@lists.torproject.org