From a4d22c5fcdd48de7b69c62e46b3292c8f0025e37 Mon Sep 17 00:00:00 2001 From: Cosmin Sabou Date: Mon, 10 Jun 2019 20:48:26 +0300 Subject: [PATCH] Backed out 2 changesets (bug 1553215) for mda failures on test_audioContextSuspendResumeClose.html. Backed out changeset 71154c8ef814 (bug 1553215) Backed out changeset 80181b642f81 (bug 1553215) --- .../webaudio/MediaElementAudioSourceNode.cpp | 3 +- .../webaudio/MediaStreamAudioSourceNode.cpp | 55 ++----- .../webaudio/MediaStreamAudioSourceNode.h | 22 +-- ...mediaStreamAudioSourceNodeCrossOrigin.html | 71 +++++----- .../mediastreamaudiosourcenode-ctor.html | 73 ---------- .../mediastreamaudiosourcenode-routing.html | 134 ------------------ 6 files changed, 51 insertions(+), 307 deletions(-) delete mode 100644 testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html delete mode 100644 testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html diff --git a/dom/media/webaudio/MediaElementAudioSourceNode.cpp b/dom/media/webaudio/MediaElementAudioSourceNode.cpp index e90124fc3874..ddd1625200b2 100644 --- a/dom/media/webaudio/MediaElementAudioSourceNode.cpp +++ b/dom/media/webaudio/MediaElementAudioSourceNode.cpp @@ -14,8 +14,7 @@ namespace mozilla { namespace dom { MediaElementAudioSourceNode::MediaElementAudioSourceNode(AudioContext* aContext) - : MediaStreamAudioSourceNode(aContext, TrackChangeBehavior::FollowChanges) { -} + : MediaStreamAudioSourceNode(aContext) {} /* static */ already_AddRefed diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp index 8fe3896e0e42..07e99d72adeb 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.cpp +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.cpp @@ -13,7 +13,6 @@ #include "mozilla/CORSMode.h" #include "nsContentUtils.h" #include "nsIScriptError.h" -#include "nsID.h" namespace mozilla { namespace dom { @@ -38,11 +37,9 @@ NS_INTERFACE_MAP_END_INHERITING(AudioNode) NS_IMPL_ADDREF_INHERITED(MediaStreamAudioSourceNode, AudioNode) NS_IMPL_RELEASE_INHERITED(MediaStreamAudioSourceNode, AudioNode) -MediaStreamAudioSourceNode::MediaStreamAudioSourceNode( - AudioContext* aContext, TrackChangeBehavior aBehavior) +MediaStreamAudioSourceNode::MediaStreamAudioSourceNode(AudioContext* aContext) : AudioNode(aContext, 2, ChannelCountMode::Max, - ChannelInterpretation::Speakers), - mBehavior(aBehavior) {} + ChannelInterpretation::Speakers) {} /* static */ already_AddRefed MediaStreamAudioSourceNode::Create( @@ -66,7 +63,7 @@ already_AddRefed MediaStreamAudioSourceNode::Create( } RefPtr node = - new MediaStreamAudioSourceNode(&aAudioContext, LockOnTrackPicked); + new MediaStreamAudioSourceNode(&aAudioContext); node->Init(aOptions.mMediaStream, aRv); if (aRv.Failed()) { @@ -99,7 +96,7 @@ void MediaStreamAudioSourceNode::Init(DOMMediaStream* aMediaStream, if (mInputStream->Active()) { NotifyActive(); } - AttachToRightTrack(mInputStream, aRv); + AttachToFirstTrack(mInputStream); } void MediaStreamAudioSourceNode::Destroy() { @@ -140,35 +137,14 @@ void MediaStreamAudioSourceNode::DetachFromTrack() { } } -static int AudioTrackCompare(const RefPtr& aLhs, - const RefPtr& aRhs) { - nsAutoStringN IDLhs; - nsAutoStringN IDRhs; - aLhs->GetId(IDLhs); - aRhs->GetId(IDRhs); - return NS_ConvertUTF16toUTF8(IDLhs).Compare( - NS_ConvertUTF16toUTF8(IDRhs).get()); -} - -void MediaStreamAudioSourceNode::AttachToRightTrack( - const RefPtr& aMediaStream, ErrorResult& aRv) { +void MediaStreamAudioSourceNode::AttachToFirstTrack( + const RefPtr& aMediaStream) { nsTArray> tracks; aMediaStream->GetAudioTracks(tracks); - if (tracks.IsEmpty() && mBehavior == LockOnTrackPicked) { - aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR); - return; - } - - // Sort the track to have a stable order, on their ID by lexicographic - // ordering on sequences of code unit values. - tracks.Sort(AudioTrackCompare); - for (const RefPtr& track : tracks) { - if (mBehavior == FollowChanges) { - if (track->Ended()) { - continue; - } + if (track->Ended()) { + continue; } AttachToTrack(track); @@ -182,9 +158,6 @@ void MediaStreamAudioSourceNode::AttachToRightTrack( void MediaStreamAudioSourceNode::NotifyTrackAdded( const RefPtr& aTrack) { - if (mBehavior != FollowChanges) { - return; - } if (mInputTrack) { return; } @@ -198,14 +171,12 @@ void MediaStreamAudioSourceNode::NotifyTrackAdded( void MediaStreamAudioSourceNode::NotifyTrackRemoved( const RefPtr& aTrack) { - if (mBehavior == FollowChanges) { - if (aTrack != mInputTrack) { - return; - } - - DetachFromTrack(); - AttachToRightTrack(mInputStream, IgnoreErrors()); + if (aTrack != mInputTrack) { + return; } + + DetachFromTrack(); + AttachToFirstTrack(mInputStream); } void MediaStreamAudioSourceNode::NotifyActive() { diff --git a/dom/media/webaudio/MediaStreamAudioSourceNode.h b/dom/media/webaudio/MediaStreamAudioSourceNode.h index 585bb6ca2233..ee18df8ad026 100644 --- a/dom/media/webaudio/MediaStreamAudioSourceNode.h +++ b/dom/media/webaudio/MediaStreamAudioSourceNode.h @@ -80,10 +80,8 @@ class MediaStreamAudioSourceNode // Detaches from the currently attached track if there is one. void DetachFromTrack(); - // Attaches to the first audio track in the MediaStream, when the tracks are - // ordered by id. - void AttachToRightTrack(const RefPtr& aMediaStream, - ErrorResult& aRv); + // Attaches to the first available audio track in aMediaStream. + void AttachToFirstTrack(const RefPtr& aMediaStream); // From DOMMediaStream::TrackListener. void NotifyTrackAdded(const RefPtr& aTrack) override; @@ -93,27 +91,13 @@ class MediaStreamAudioSourceNode // From PrincipalChangeObserver. void PrincipalChanged(MediaStreamTrack* aMediaStreamTrack) override; - // This allows implementing the correct behaviour for both - // MediaElementAudioSourceNode and MediaStreamAudioSourceNode, that have most - // of their behaviour shared. - enum TrackChangeBehavior { - // MediaStreamAudioSourceNode locks on the track it picked, and never - // changes. - LockOnTrackPicked, - // MediaElementAudioSourceNode can change track, depending on what the - // HTMLMediaElement does. - FollowChanges - }; - protected: - MediaStreamAudioSourceNode(AudioContext* aContext, - TrackChangeBehavior aBehavior); + explicit MediaStreamAudioSourceNode(AudioContext* aContext); void Init(DOMMediaStream* aMediaStream, ErrorResult& aRv); virtual void Destroy(); virtual ~MediaStreamAudioSourceNode(); private: - const TrackChangeBehavior mBehavior; RefPtr mInputPort; RefPtr mInputStream; diff --git a/dom/media/webaudio/test/test_mediaStreamAudioSourceNodeCrossOrigin.html b/dom/media/webaudio/test/test_mediaStreamAudioSourceNodeCrossOrigin.html index d79ce50ab868..777ff56a63a8 100644 --- a/dom/media/webaudio/test/test_mediaStreamAudioSourceNodeCrossOrigin.html +++ b/dom/media/webaudio/test/test_mediaStreamAudioSourceNodeCrossOrigin.html @@ -12,48 +12,45 @@ SimpleTest.waitForExplicitFinish(); var audio = new Audio("http://example.org:80/tests/dom/media/webaudio/test/small-shot.ogg"); -audio.load(); var context = new AudioContext(); -audio.onloadedmetadata = function() { - var node = context.createMediaStreamSource(audio.mozCaptureStreamUntilEnded()); - var sp = context.createScriptProcessor(2048, 1); - node.connect(sp); - var nonzeroSampleCount = 0; - var complete = false; - var iterationCount = 0; +var node = context.createMediaStreamSource(audio.mozCaptureStreamUntilEnded()); +var sp = context.createScriptProcessor(2048, 1); +node.connect(sp); +var nonzeroSampleCount = 0; +var complete = false; +var iterationCount = 0; - // This test ensures we receive at least expectedSampleCount nonzero samples - function processSamples(e) { - if (complete) { - return; - } - - if (iterationCount == 0) { - // Don't start playing the audio until the AudioContext stuff is connected - // and running. - audio.play(); - } - ++iterationCount; - - var buf = e.inputBuffer.getChannelData(0); - var nonzeroSamplesThisBuffer = 0; - for (var i = 0; i < buf.length; ++i) { - if (buf[i] != 0) { - ++nonzeroSamplesThisBuffer; - } - } - is(nonzeroSamplesThisBuffer, 0, - "Checking all samples are zero"); - if (iterationCount >= 20) { - SimpleTest.finish(); - complete = true; - } +// This test ensures we receive at least expectedSampleCount nonzero samples +function processSamples(e) { + if (complete) { + return; } - audio.oncanplaythrough = function() { - sp.onaudioprocess = processSamples; - }; + if (iterationCount == 0) { + // Don't start playing the audio until the AudioContext stuff is connected + // and running. + audio.play(); + } + ++iterationCount; + + var buf = e.inputBuffer.getChannelData(0); + var nonzeroSamplesThisBuffer = 0; + for (var i = 0; i < buf.length; ++i) { + if (buf[i] != 0) { + ++nonzeroSamplesThisBuffer; + } + } + is(nonzeroSamplesThisBuffer, 0, + "Checking all samples are zero"); + if (iterationCount >= 20) { + SimpleTest.finish(); + complete = true; + } } + +audio.oncanplaythrough = function() { + sp.onaudioprocess = processSamples; +}; diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html b/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html deleted file mode 100644 index fea042ca530d..000000000000 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-ctor.html +++ /dev/null @@ -1,73 +0,0 @@ - - - - - MediaStreamAudioSourceNode - - - - -
- - - - diff --git a/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html b/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html deleted file mode 100644 index 8deedfa9efbd..000000000000 --- a/testing/web-platform/tests/webaudio/the-audio-api/the-mediastreamaudiosourcenode-interface/mediastreamaudiosourcenode-routing.html +++ /dev/null @@ -1,134 +0,0 @@ - - - - - MediaStreamAudioSourceNode - - - - -
- - -