Bug 1446346 - If an AudioContext hasn't been started, do not bother clamping/jittering the CurrentTime. r=padenot, a=RyanVM
authorTom Ritter <tom@mozilla.com>
Wed, 11 Apr 2018 11:34:57 -0500
changeset 802190 d06fb3839361bda1f0c4af69fe6aec7846dc00b4
parent 802189 eeedbadc7a25f7989aaa0d9234efbbcfa8486f21
child 802191 c7e494e5888d67d5822143985fca6fd42c303b90
push id111850
push userbmo:tom@mozilla.com
push dateThu, 31 May 2018 16:41:37 +0000
reviewerspadenot, RyanVM
bugs1446346
milestone60.0.2
Bug 1446346 - If an AudioContext hasn't been started, do not bother clamping/jittering the CurrentTime. r=padenot, a=RyanVM This will resolve several intermittments that were occuring because we would occasionally get unlucky and have a jitter midpoint of 0, making an unstarted AudioContext report a CurrentTime of 100us (or 1ms - whatever our clamp value was.) MozReview-Commit-ID: 45zXLbB93wP
dom/media/webaudio/AudioContext.cpp
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -648,16 +648,22 @@ AudioContext::DestinationStream() const
   }
   return nullptr;
 }
 
 double
 AudioContext::CurrentTime()
 {
   MediaStream* stream = Destination()->Stream();
+
+  if (!mIsStarted &&
+    stream->StreamTimeToSeconds(stream->GetCurrentTime()) == 0) {
+      return 0;
+  }
+
   // The value of a MediaStream's CurrentTime will always advance forward; it will never
   // reset (even if one rewinds a video.) Therefore we can use a single Random Seed
   // initialized at the same time as the object.
   return nsRFPService::ReduceTimePrecisionAsSecs(
     stream->StreamTimeToSeconds(stream->GetCurrentTime()),
     GetRandomTimelineSeed());
 }