author | Paul Adenot <paul@paul.cx> |
Fri, 12 Jul 2019 11:27:25 +0000 (2019-07-12) | |
changeset 482569 | c96e81ba64f307b402fc6df24a3e7c256ea854a3 |
parent 482568 | de7190bf40fd3c940929365df71cfc2401f47cac |
child 482570 | b94a7e373671d9de449c05cef676e5391a4854db |
push id | 36284 |
push user | apavel@mozilla.com |
push date | Fri, 12 Jul 2019 21:43:58 +0000 (2019-07-12) |
treeherder | mozilla-central@cd685b4cff6d [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | tjr |
bugs | 1564422 |
milestone | 70.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -519,48 +519,65 @@ already_AddRefed<PeriodicWave> AudioCont AudioListener* AudioContext::Listener() { if (!mListener) { mListener = new AudioListener(this); } return mListener; } -double AudioContext::OutputLatency() { return Graph()->AudioOutputLatency(); } +double AudioContext::OutputLatency() { + // When reduceFingerprinting is enabled, return a latency figure that is + // fixed, but plausible for the platform. + double latency_s = 0.0; + if (nsRFPService::IsResistFingerprintingEnabled()) { +#ifdef XP_MACOSX + latency_s = 512. / mSampleRate; +#elif MOZ_WIDGET_ANDROID + latency_s = 0.020; +#elif XP_WIN + latency_s = 0.04; +#else // Catchall for other OSes, including Linux. + latency_s = 0.025; +#endif + } else { + return Graph()->AudioOutputLatency(); + } + return latency_s; +} void AudioContext::GetOutputTimestamp(AudioTimestamp& aTimeStamp) { if (!Destination()) { aTimeStamp.mContextTime.Construct(0.0); aTimeStamp.mPerformanceTime.Construct(0.0); return; } // The currentTime currently being output is the currentTime minus the audio - // output latency. + // output latency. The resolution of CurrentTime() is already reduced. aTimeStamp.mContextTime.Construct( std::max(0.0, CurrentTime() - OutputLatency())); nsPIDOMWindowInner* parent = GetParentObject(); Performance* perf = parent ? parent->GetPerformance() : nullptr; if (perf) { - // Convert to milliseconds. + // perf->Now() already has reduced resolution here, no need to do it again. aTimeStamp.mPerformanceTime.Construct( std::max(0., perf->Now() - (OutputLatency() * 1000.))); } else { aTimeStamp.mPerformanceTime.Construct(0.0); } } Worklet* AudioContext::GetAudioWorklet(ErrorResult& aRv) { if (!mWorklet) { mWorklet = AudioWorkletImpl::CreateWorklet(this, aRv); } return mWorklet; } - bool AudioContext::IsRunning() const { return mAudioContextState == AudioContextState::Running; } already_AddRefed<Promise> AudioContext::DecodeAudioData( const ArrayBuffer& aBuffer, const Optional<OwningNonNull<DecodeSuccessCallback>>& aSuccessCallback, const Optional<OwningNonNull<DecodeErrorCallback>>& aFailureCallback,