summaryrefslogtreecommitdiffstats
path: root/dom/media/webaudio
diff options
context:
space:
mode:
Diffstat (limited to 'dom/media/webaudio')
-rw-r--r--dom/media/webaudio/MediaStreamAudioSourceNode.cpp18
-rw-r--r--dom/media/webaudio/MediaStreamAudioSourceNode.h27
-rw-r--r--dom/media/webaudio/test/mochitest_audio.toml1
-rw-r--r--dom/media/webaudio/test/test_mediaDecoding.html12
4 files changed, 39 insertions, 19 deletions
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> 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<MediaStreamTrack> {
public:
static already_AddRefed<MediaStreamAudioSourceNode> Create(
@@ -87,9 +86,28 @@ class MediaStreamAudioSourceNode
ErrorResult& aRv);
// From DOMMediaStream::TrackListener.
- void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack) override;
- void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& aTrack) override;
- void NotifyAudible() override;
+ void NotifyTrackAdded(const RefPtr<MediaStreamTrack>& aTrack);
+ void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& 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<MediaStreamTrack>& aTrack) override {
+ mNode->NotifyTrackAdded(aTrack);
+ }
+ void NotifyTrackRemoved(const RefPtr<MediaStreamTrack>& aTrack) override {
+ mNode->NotifyTrackRemoved(aTrack);
+ }
+ void NotifyAudible() override { mNode->NotifyAudible(); }
+
+ private:
+ virtual ~TrackListener() = default;
+ RefPtr<MediaStreamAudioSourceNode> mNode;
+ };
// From PrincipalChangeObserver<MediaStreamTrack>.
void PrincipalChanged(MediaStreamTrack* aMediaStreamTrack) override;
@@ -120,6 +138,7 @@ class MediaStreamAudioSourceNode
// On construction we set this to the first audio track of mInputStream.
RefPtr<MediaStreamTrack> mInputTrack;
+ RefPtr<TrackListener> 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,