Bug 1446346 If an AudioContext hasn't been started, do not bother clamping/jittering the CurrentTime r?padenot
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
--- a/dom/media/webaudio/AudioContext.cpp
+++ b/dom/media/webaudio/AudioContext.cpp
@@ -662,16 +662,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());
}