From d8bbc7858622b6d9c278469aab701ca0b609cddf Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 15 May 2024 05:35:49 +0200 Subject: Merging upstream version 126.0. Signed-off-by: Daniel Baumann --- dom/media/webaudio/MediaStreamAudioSourceNode.cpp | 18 +++++++++++++-- dom/media/webaudio/MediaStreamAudioSourceNode.h | 27 +++++++++++++++++++---- dom/media/webaudio/test/mochitest_audio.toml | 1 - dom/media/webaudio/test/test_mediaDecoding.html | 12 ---------- 4 files changed, 39 insertions(+), 19 deletions(-) (limited to 'dom/media/webaudio') diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp index a915e78859..4ade20d16d 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp @@ -23,12 +23,14 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(MediaStreamAudioSourceNode) tmp->Destroy(); NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputStream) NS_IMPL_CYCLE_COLLECTION_UNLINK(mInputTrack) + NS_IMPL_CYCLE_COLLECTION_UNLINK(mListener) NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(AudioNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(MediaStreamAudioSourceNode, AudioNode) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputStream) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mInputTrack) + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mListener) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(MediaStreamAudioSourceNode) @@ -65,12 +67,13 @@ already_AddRefed MediaStreamAudioSourceNode::Create( void MediaStreamAudioSourceNode::Init(DOMMediaStream& aMediaStream, ErrorResult& aRv) { + mListener = new TrackListener(this); mInputStream = &aMediaStream; AudioNodeEngine* engine = new MediaStreamAudioSourceNodeEngine(this); mTrack = AudioNodeExternalInputTrack::Create(Context()->Graph(), engine); mInputStream->AddConsumerToKeepAlive(ToSupports(this)); - mInputStream->RegisterTrackListener(this); + mInputStream->RegisterTrackListener(mListener); if (mInputStream->Audible()) { NotifyAudible(); } @@ -79,8 +82,9 @@ void MediaStreamAudioSourceNode::Init(DOMMediaStream& aMediaStream, void MediaStreamAudioSourceNode::Destroy() { if (mInputStream) { - mInputStream->UnregisterTrackListener(this); + mInputStream->UnregisterTrackListener(mListener); mInputStream = nullptr; + mListener = nullptr; } DetachFromTrack(); } @@ -275,4 +279,14 @@ JSObject* MediaStreamAudioSourceNode::WrapObject( return MediaStreamAudioSourceNode_Binding::Wrap(aCx, this, aGivenProto); } +NS_IMPL_CYCLE_COLLECTION_INHERITED(MediaStreamAudioSourceNode::TrackListener, + DOMMediaStream::TrackListener, mNode) +NS_IMPL_ADDREF_INHERITED(MediaStreamAudioSourceNode::TrackListener, + DOMMediaStream::TrackListener) +NS_IMPL_RELEASE_INHERITED(MediaStreamAudioSourceNode::TrackListener, + DOMMediaStream::TrackListener) +NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION( + MediaStreamAudioSourceNode::TrackListener) +NS_INTERFACE_MAP_END_INHERITING(DOMMediaStream::TrackListener) + } // namespace mozilla::dom diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.h b/dom/media/webaudio/MediaStreamAudioSourceNode.h index 1875fc2e83..82ef67d4b7 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.h +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h @@ -40,7 +40,6 @@ class MediaStreamAudioSourceNodeEngine final : public AudioNodeEngine { class MediaStreamAudioSourceNode : public AudioNode, - public DOMMediaStream::TrackListener, public PrincipalChangeObserver { public: static already_AddRefed Create( @@ -87,9 +86,28 @@ class MediaStreamAudioSourceNode ErrorResult& aRv); // From DOMMediaStream::TrackListener. - void NotifyTrackAdded(const RefPtr& aTrack) override; - void NotifyTrackRemoved(const RefPtr& aTrack) override; - void NotifyAudible() override; + void NotifyTrackAdded(const RefPtr& aTrack); + void NotifyTrackRemoved(const RefPtr& aTrack); + void NotifyAudible(); + + class TrackListener final : public DOMMediaStream::TrackListener { + public: + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(TrackListener, + DOMMediaStream::TrackListener) + explicit TrackListener(MediaStreamAudioSourceNode* aNode) : mNode(aNode) {} + void NotifyTrackAdded(const RefPtr& aTrack) override { + mNode->NotifyTrackAdded(aTrack); + } + void NotifyTrackRemoved(const RefPtr& aTrack) override { + mNode->NotifyTrackRemoved(aTrack); + } + void NotifyAudible() override { mNode->NotifyAudible(); } + + private: + virtual ~TrackListener() = default; + RefPtr mNode; + }; // From PrincipalChangeObserver. void PrincipalChanged(MediaStreamTrack* aMediaStreamTrack) override; @@ -120,6 +138,7 @@ class MediaStreamAudioSourceNode // On construction we set this to the first audio track of mInputStream. RefPtr mInputTrack; + RefPtr mListener; }; } // namespace mozilla::dom diff --git a/dom/media/webaudio/test/mochitest_audio.toml b/dom/media/webaudio/test/mochitest_audio.toml index 56e612b102..1f037c0ec6 100644 --- a/dom/media/webaudio/test/mochitest_audio.toml +++ b/dom/media/webaudio/test/mochitest_audio.toml @@ -6,7 +6,6 @@ support-files = [ "audio-mono-expected-2.wav", "audio-mono-expected.wav", "audio-quad.wav", - "audio.ogv", "audiovideo.mp4", "audioBufferSourceNodeDetached_worker.js", "corsServer.sjs", diff --git a/dom/media/webaudio/test/test_mediaDecoding.html b/dom/media/webaudio/test/test_mediaDecoding.html index e76a533e4a..c2105b53b9 100644 --- a/dom/media/webaudio/test/test_mediaDecoding.html +++ b/dom/media/webaudio/test/test_mediaDecoding.html @@ -197,18 +197,6 @@ { url: "invalid.txt", valid: false, sampleRate: 44100 }, // A webm file with no audio { url: "noaudio.webm", valid: false, sampleRate: 48000 }, - // A video ogg file with audio - { - url: "audio.ogv", - valid: true, - expectedUrl: "audio-expected.wav", - numberOfChannels: 2, - sampleRate: 44100, - frames: 47680, - duration: 1.0807, - fuzzTolerance: 106, - fuzzToleranceMobile: 3482 - }, { url: "nil-packet.ogg", expectedUrl: null, -- cgit v1.2.3