diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index 4748fbaf7e01..ba9b4e16dbb0 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -1132,17 +1132,6 @@ void AudioCallbackDriver::CompleteAudioContextOperations( } } -TimeDuration AudioCallbackDriver::AudioOutputLatency() { - uint32_t latency_frames; - int rv = cubeb_stream_get_latency(mAudioStream, &latency_frames); - if (rv || mSampleRate == 0) { - return TimeDuration::FromSeconds(0.0); - } - - return TimeDuration::FromSeconds(static_cast(latency_frames) / - mSampleRate); -} - void AudioCallbackDriver::FallbackToSystemClockDriver() { MOZ_ASSERT(!ThreadRunning()); GraphImpl()->GetMonitor().AssertCurrentThreadOwns(); diff --git a/dom/media/GraphDriver.h b/dom/media/GraphDriver.h index 1be917d207d5..34b23c7a6f76 100644 --- a/dom/media/GraphDriver.h +++ b/dom/media/GraphDriver.h @@ -433,9 +433,6 @@ class AudioCallbackDriver : public GraphDriver, void CompleteAudioContextOperations(AsyncCubebOperation aOperation); - // Returns the output latency for the current audio output stream. - TimeDuration AudioOutputLatency(); - private: /* Remove Mixer callbacks when switching */ void RemoveMixerCallback(); diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index 674a67ac6e5b..ab2dcb3f2fa8 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -957,10 +957,6 @@ void MediaStreamGraphImpl::DeviceChanged() { MediaStreamGraphImpl* mGraphImpl; }; - // Reset the latency, it will get fetched again next time it's queried. - MOZ_ASSERT(NS_IsMainThread()); - mAudioOutputLatency = 0.0; - AppendMessage(MakeUnique(this)); } @@ -3196,8 +3192,7 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested, mCanRunMessagesSynchronously(false) #endif , - mMainThreadGraphTime(0, "MediaStreamGraphImpl::mMainThreadGraphTime"), - mAudioOutputLatency(0.0) { + mMainThreadGraphTime(0, "MediaStreamGraphImpl::mMainThreadGraphTime") { if (mRealtime) { if (aDriverRequested == AUDIO_THREAD_DRIVER) { // Always start with zero input channels, and no particular preferences @@ -3801,29 +3796,6 @@ void MediaStreamGraph::ApplyAudioContextOperation( aDestinationStream, aStreams, aOperation, aPromise, aFlags)); } -double MediaStreamGraph::AudioOutputLatency() { - return static_cast(this)->AudioOutputLatency(); -} - -double MediaStreamGraphImpl::AudioOutputLatency() { - MOZ_ASSERT(NS_IsMainThread()); - if (mAudioOutputLatency != 0.0) { - return mAudioOutputLatency; - } - MonitorAutoLock lock(mMonitor); - if (CurrentDriver()->AsAudioCallbackDriver()) { - mAudioOutputLatency = CurrentDriver() - ->AsAudioCallbackDriver() - ->AudioOutputLatency() - .ToSeconds(); - } else { - // Failure mode: return 0.0 if running on a normal thread. - mAudioOutputLatency = 0.0; - } - - return mAudioOutputLatency; -} - bool MediaStreamGraph::IsNonRealtime() const { return !static_cast(this)->mRealtime; } diff --git a/dom/media/MediaStreamGraph.h b/dom/media/MediaStreamGraph.h index 7df158683b0c..a35032ccbb05 100644 --- a/dom/media/MediaStreamGraph.h +++ b/dom/media/MediaStreamGraph.h @@ -1272,8 +1272,6 @@ class MediaStreamGraph { */ TrackRate GraphRate() const { return mSampleRate; } - double AudioOutputLatency(); - void RegisterCaptureStreamForWindow(uint64_t aWindowId, ProcessedMediaStream* aCaptureStream); void UnregisterCaptureStreamForWindow(uint64_t aWindowId); diff --git a/dom/media/MediaStreamGraphImpl.h b/dom/media/MediaStreamGraphImpl.h index b2cd22b9a688..0e17d6230daa 100644 --- a/dom/media/MediaStreamGraphImpl.h +++ b/dom/media/MediaStreamGraphImpl.h @@ -453,8 +453,6 @@ class MediaStreamGraphImpl : public MediaStreamGraph, uint32_t AudioOutputChannelCount() const { return mOutputChannels; } - double AudioOutputLatency(); - /** * The audio input channel count for a MediaStreamGraph is the max of all the * channel counts requested by the listeners. The max channel count is @@ -952,12 +950,6 @@ class MediaStreamGraphImpl : public MediaStreamGraph, * Read by stable state runnable on main thread. Protected by mMonitor. */ GraphTime mNextMainThreadGraphTime = 0; - - /** - * Cached audio output latency, in seconds. Main thread only. This is reset - * whenever the audio device running this MediaStreamGraph changes. - */ - double mAudioOutputLatency; }; } // namespace mozilla diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index 4dd0654935a9..1398b11904e7 100644 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -36,7 +36,6 @@ #include "mozilla/dom/OscillatorNodeBinding.h" #include "mozilla/dom/PannerNodeBinding.h" #include "mozilla/dom/PeriodicWaveBinding.h" -#include "mozilla/dom/Performance.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/StereoPannerNodeBinding.h" #include "mozilla/dom/WaveShaperNodeBinding.h" @@ -524,30 +523,6 @@ AudioListener* AudioContext::Listener() { return mListener; } -double AudioContext::OutputLatency() { return Graph()->AudioOutputLatency(); } - -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. - aTimeStamp.mContextTime.Construct( - std::max(0.0, CurrentTime() - OutputLatency())); - nsPIDOMWindowInner* parent = GetParentObject(); - Performance* perf = parent ? parent->GetPerformance() : nullptr; - if (perf) { - // Convert to milliseconds. - 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); diff --git a/dom/media/webaudio/AudioContext.h b/dom/media/webaudio/AudioContext.h index a4858a74841b..47124eb76374 100644 --- a/dom/media/webaudio/AudioContext.h +++ b/dom/media/webaudio/AudioContext.h @@ -9,7 +9,6 @@ #include "AudioParamDescriptorMap.h" #include "mozilla/dom/OfflineAudioContextBinding.h" -#include "mozilla/dom/AudioContextBinding.h" #include "MediaBufferDecoder.h" #include "mozilla/Attributes.h" #include "mozilla/DOMEventTargetHelper.h" @@ -193,16 +192,6 @@ class AudioContext final : public DOMEventTargetHelper, AudioContextState State() const { return mAudioContextState; } - double BaseLatency() const { - // Gecko does not do any buffering between rendering the audio and sending - // it to the audio subsystem. - return 0.0; - } - - double OutputLatency(); - - void GetOutputTimestamp(AudioTimestamp& aTimeStamp); - Worklet* GetAudioWorklet(ErrorResult& aRv); bool IsRunning() const; diff --git a/dom/media/webaudio/MediaElementAudioSourceNode.cpp b/dom/media/webaudio/MediaElementAudioSourceNode.cpp index a5a7414c43e4..e90124fc3874 100644 --- a/dom/media/webaudio/MediaElementAudioSourceNode.cpp +++ b/dom/media/webaudio/MediaElementAudioSourceNode.cpp @@ -13,12 +13,9 @@ namespace mozilla { namespace dom { -MediaElementAudioSourceNode::MediaElementAudioSourceNode( - AudioContext* aContext, HTMLMediaElement* aElement) - : MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges), - mElement(aElement) { - MOZ_ASSERT(aElement); - } +MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* aContext) + : MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges) { +} /* static */ already_AddRefed @@ -31,7 +28,7 @@ MediaElementAudioSourceNode::Create( } RefPtr node = - new MediaElementAudioSourceNode(&aAudioContext, aOptions.mMediaElement); + new MediaElementAudioSourceNode(&aAudioContext); RefPtr stream = aOptions.mMediaElement->CaptureAudio( aRv, aAudioContext.Destination()->Stream()->Graph()); @@ -74,9 +71,5 @@ void MediaElementAudioSourceNode::Destroy() { MediaStreamAudioSourceNode::Destroy(); } -HTMLMediaElement* MediaElementAudioSourceNode::MediaElement() { - return mElement; -} - } // namespace dom } // namespace mozilla diff --git a/dom/media/webaudio/MediaElementAudioSourceNode.h b/dom/media/webaudio/MediaElementAudioSourceNode.h index 4eabb043b4f7..adf8673ca689 100644 --- a/dom/media/webaudio/MediaElementAudioSourceNode.h +++ b/dom/media/webaudio/MediaElementAudioSourceNode.h @@ -42,11 +42,8 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode { return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); } - HTMLMediaElement* MediaElement(); - private: - explicit MediaElementAudioSourceNode(AudioContext* aContext, - HTMLMediaElement* aElement); + explicit MediaElementAudioSourceNode(AudioContext* aContext); void Destroy() override; @@ -55,8 +52,6 @@ class MediaElementAudioSourceNode final : public MediaStreamAudioSourceNode { void ListenForAllowedToPlay(const MediaElementAudioSourceOptions& aOptions); MozPromiseRequestHolder mAllowedToPlayRequest; - - RefPtr mElement; }; } // namespace dom diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.h b/dom/media/webaudio/MediaStreamAudioSourceNode.h index 014ef27f272a..585bb6ca2233 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.h +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h @@ -65,8 +65,6 @@ class MediaStreamAudioSourceNode uint16_t NumberOfInputs() const override { return 0; } - DOMMediaStream* GetMediaStream() { return mInputStream; } - const char* NodeType() const override { return "MediaStreamAudioSourceNode"; } virtual const char* CrossOriginErrorString() const { diff --git a/dom/webidl/AudioContext.webidl b/dom/webidl/AudioContext.webidl index 08e7984f2ecc..66fccffb8c57 100644 --- a/dom/webidl/AudioContext.webidl +++ b/dom/webidl/AudioContext.webidl @@ -14,18 +14,12 @@ dictionary AudioContextOptions { float sampleRate = 0; }; -dictionary AudioTimestamp { - double contextTime; - DOMHighResTimeStamp performanceTime; -}; - [Pref="dom.webaudio.enabled", Constructor(optional AudioContextOptions contextOptions = {})] interface AudioContext : BaseAudioContext { - readonly attribute double baseLatency; - readonly attribute double outputLatency; - AudioTimestamp getOutputTimestamp(); + // Bug 1324545: readonly attribute double outputLatency; + // Bug 1324545: AudioTimestamp getOutputTimestamp (); [Throws] Promise suspend(); diff --git a/dom/webidl/BaseAudioContext.webidl b/dom/webidl/BaseAudioContext.webidl index c3848131093c..6d7027d651af 100644 --- a/dom/webidl/BaseAudioContext.webidl +++ b/dom/webidl/BaseAudioContext.webidl @@ -27,6 +27,7 @@ interface BaseAudioContext : EventTarget { readonly attribute AudioContextState state; [Throws, SameObject, SecureContext, Pref="dom.audioworklet.enabled"] readonly attribute AudioWorklet audioWorklet; + // Bug 1324552: readonly attribute double baseLatency; [Throws] Promise resume(); diff --git a/dom/webidl/MediaElementAudioSourceNode.webidl b/dom/webidl/MediaElementAudioSourceNode.webidl index d8009a836350..37de32536d24 100644 --- a/dom/webidl/MediaElementAudioSourceNode.webidl +++ b/dom/webidl/MediaElementAudioSourceNode.webidl @@ -17,7 +17,7 @@ dictionary MediaElementAudioSourceOptions { [Pref="dom.webaudio.enabled", Constructor(AudioContext context, MediaElementAudioSourceOptions options)] interface MediaElementAudioSourceNode : AudioNode { - readonly attribute HTMLMediaElement mediaElement; + }; // Mozilla extensions diff --git a/dom/webidl/MediaStreamAudioSourceNode.webidl b/dom/webidl/MediaStreamAudioSourceNode.webidl index e08620ce70d1..06727a5dadd2 100644 --- a/dom/webidl/MediaStreamAudioSourceNode.webidl +++ b/dom/webidl/MediaStreamAudioSourceNode.webidl @@ -17,8 +17,7 @@ dictionary MediaStreamAudioSourceOptions { [Pref="dom.webaudio.enabled", Constructor(AudioContext context, MediaStreamAudioSourceOptions options)] interface MediaStreamAudioSourceNode : AudioNode { - [BinaryName="GetMediaStream"] - readonly attribute MediaStream mediaStream; + }; // Mozilla extensions diff --git a/testing/web-platform/meta/webaudio/idlharness.https.window.js.ini b/testing/web-platform/meta/webaudio/idlharness.https.window.js.ini index 4eb9066d9610..3b7065b077f9 100644 --- a/testing/web-platform/meta/webaudio/idlharness.https.window.js.ini +++ b/testing/web-platform/meta/webaudio/idlharness.https.window.js.ini @@ -14,9 +14,15 @@ [AudioListener interface: attribute forwardX] expected: FAIL + [MediaStreamAudioSourceNode interface: attribute mediaStream] + expected: FAIL + [AudioParam interface: calling cancelAndHoldAtTime(double) on new AudioBufferSourceNode(context).playbackRate with too few arguments must throw TypeError] expected: FAIL + [AudioContext interface: context must inherit property "getOutputTimestamp()" with the proper type] + expected: FAIL + [AudioListener interface: context.listener must inherit property "forwardX" with the proper type] expected: FAIL @@ -35,6 +41,12 @@ [AudioListener interface: context.listener must inherit property "positionY" with the proper type] expected: FAIL + [MediaElementAudioSourceNode interface: new MediaElementAudioSourceNode(context, {mediaElement: new Audio}) must inherit property "mediaElement" with the proper type] + expected: FAIL + + [AudioContext interface: operation getOutputTimestamp()] + expected: FAIL + [Stringification of new AudioProcessingEvent('', {\n playbackTime: 0, inputBuffer: buffer, outputBuffer: buffer\n })] expected: FAIL @@ -62,6 +74,12 @@ [AudioListener interface: context.listener must inherit property "forwardY" with the proper type] expected: FAIL + [AudioContext interface: context must inherit property "baseLatency" with the proper type] + expected: FAIL + + [MediaElementAudioSourceNode interface: attribute mediaElement] + expected: FAIL + [AudioListener interface: context.listener must inherit property "positionX" with the proper type] expected: FAIL @@ -80,12 +98,21 @@ [AudioParamMap must be primary interface of worklet_node.parameters] expected: FAIL + [AudioContext interface: context must inherit property "outputLatency" with the proper type] + expected: FAIL + [OfflineAudioContext interface: operation suspend(double)] expected: FAIL + [AudioContext interface: attribute baseLatency] + expected: FAIL + [AudioParam interface: new AudioBufferSourceNode(context).playbackRate must inherit property "cancelAndHoldAtTime(double)" with the proper type] expected: FAIL + [AudioContext interface: attribute outputLatency] + expected: FAIL + [AudioListener interface: attribute upX] expected: FAIL diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-getoutputtimestamp.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-getoutputtimestamp.html.ini new file mode 100644 index 000000000000..abdb861f9365 --- /dev/null +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontext-getoutputtimestamp.html.ini @@ -0,0 +1,2 @@ +[audiocontext-getoutputtimestamp.html] + expected: ERROR diff --git a/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html.ini b/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html.ini index b754aaf343fe..ceba861957ab 100644 --- a/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html.ini +++ b/testing/web-platform/meta/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html.ini @@ -1,4 +1,16 @@ [audiocontextoptions.html] + [X default baseLatency is not greater than 0. Got undefined.] + expected: FAIL + + [X balanced baseLatency is not greater than or equal to undefined. Got undefined.] + expected: FAIL + + [X playback baseLatency is not greater than or equal to undefined. Got undefined.] + expected: FAIL + + [< [test-audiocontextoptions-latencyHint-basic\] 3 out of 9 assertions were failed.] + expected: FAIL + [X double-constructor baseLatency small is not less than or equal to undefined. Got undefined.] expected: FAIL diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html b/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html index b556e31b5e0d..bee1aa835bf6 100644 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html +++ b/testing/web-platform/tests/webaudio/the-audio-api/the-audiocontext-interface/audiocontextoptions.html @@ -35,7 +35,7 @@ `context.sampleRate (${context.sampleRate} Hz)`).beGreaterThan(0); defaultLatency = context.baseLatency; - should(defaultLatency, 'default baseLatency').beGreaterThanOrEqualTo(0); + should(defaultLatency, 'default baseLatency').beGreaterThan(0); // Verify that an AudioContext can be created with the expected // latency types. @@ -130,7 +130,7 @@ should(context1.baseLatency, 'high latency context baseLatency') .beEqualTo(context2.baseLatency); should(context1.baseLatency, 'high latency context baseLatency') - .beGreaterThanOrEqualTo(interactiveLatency); + .beGreaterThan(interactiveLatency); closingPromises.push(context1.close()); closingPromises.push(context2.close());