diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index 47ecede69859..e6fbfd46ba85 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3585,7 +3585,7 @@ HTMLMediaElement::MozCaptureStream(ErrorResult& aRv) } MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(graphDriverType, mAudioChannel, window); + MediaStreamGraph::GetInstance(graphDriverType, window); RefPtr stream = CaptureStreamInternal(StreamCaptureBehavior::CONTINUE_WHEN_ENDED, @@ -3618,7 +3618,7 @@ HTMLMediaElement::MozCaptureStreamUntilEnded(ErrorResult& aRv) } MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(graphDriverType, mAudioChannel, window); + MediaStreamGraph::GetInstance(graphDriverType, window); RefPtr stream = CaptureStreamInternal(StreamCaptureBehavior::FINISH_WHEN_ENDED, @@ -5158,11 +5158,6 @@ void HTMLMediaElement::SetupSrcMediaStreamPlayback(DOMMediaStream* aStream) return; } - RefPtr stream = GetSrcMediaStream(); - if (stream) { - stream->SetAudioChannelType(mAudioChannel); - } - UpdateSrcMediaStreamPlaying(); // If we pause this media element, track changes in the underlying stream @@ -7252,8 +7247,7 @@ HTMLMediaElement::AudioCaptureStreamChange(bool aCapture) uint64_t id = window->WindowID(); MediaStreamGraph* msg = - MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, - mAudioChannel, window); + MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, window); if (GetSrcMediaStream()) { mCaptureStreamPort = msg->ConnectToCaptureStream(id, GetSrcMediaStream()); diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index bb9fcbc32def..3a11079bc6fb 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -15,6 +15,7 @@ #include "mozilla/CORSMode.h" #include "DecoderTraits.h" #include "nsIAudioChannelAgent.h" +#include "mozilla/dom/AudioChannelBinding.h" #include "mozilla/Attributes.h" #include "mozilla/dom/TextTrackManager.h" #include "mozilla/WeakPtr.h" diff --git a/dom/media/CanvasCaptureMediaStream.cpp b/dom/media/CanvasCaptureMediaStream.cpp index 365f6a92e628..fe9aec6c0b7e 100644 --- a/dom/media/CanvasCaptureMediaStream.cpp +++ b/dom/media/CanvasCaptureMediaStream.cpp @@ -279,9 +279,7 @@ CanvasCaptureMediaStream::CreateSourceStream(nsPIDOMWindowInner* aWindow, { RefPtr stream = new CanvasCaptureMediaStream(aWindow, aCanvas); MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER, - AudioChannel::Normal, - aWindow); + MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER, aWindow); stream->InitSourceStream(graph); return stream.forget(); } diff --git a/dom/media/DOMMediaStream.cpp b/dom/media/DOMMediaStream.cpp index 2a1071df0488..33add55fc080 100644 --- a/dom/media/DOMMediaStream.cpp +++ b/dom/media/DOMMediaStream.cpp @@ -563,8 +563,7 @@ DOMMediaStream::Constructor(const GlobalObject& aGlobal, if (!newStream->GetPlaybackStream()) { MOZ_ASSERT(aTracks.IsEmpty()); MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER, - AudioChannel::Normal, ownerWindow); + MediaStreamGraph::GetInstance(MediaStreamGraph::SYSTEM_THREAD_DRIVER, ownerWindow); newStream->InitPlaybackStreamCommon(graph); } diff --git a/dom/media/GraphDriver.cpp b/dom/media/GraphDriver.cpp index a4b72d8147db..0c7b72b250a1 100644 --- a/dom/media/GraphDriver.cpp +++ b/dom/media/GraphDriver.cpp @@ -565,7 +565,6 @@ AudioCallbackDriver::AudioCallbackDriver(MediaStreamGraphImpl* aGraphImpl) , mIterationDurationMS(MEDIA_GRAPH_TARGET_PERIOD_MS) , mStarted(false) , mAudioInput(nullptr) - , mAudioChannel(aGraphImpl->AudioChannel()) , mAddedMixer(false) , mInCallback(false) , mMicrophoneActive(false) diff --git a/dom/media/GraphDriver.h b/dom/media/GraphDriver.h index f6954c2da8f0..98bea2218ec5 100644 --- a/dom/media/GraphDriver.h +++ b/dom/media/GraphDriver.h @@ -525,8 +525,6 @@ private: nsCOMPtr mInitShutdownThread; /* This must be accessed with the graph monitor held. */ AutoTArray mPromisesForOperation; - /* This is set during initialization, and can be read safely afterwards. */ - dom::AudioChannel mAudioChannel; /* Used to queue us to add the mixer callback on first run. */ bool mAddedMixer; diff --git a/dom/media/MediaManager.cpp b/dom/media/MediaManager.cpp index aad59d5181d1..820fdff2834f 100644 --- a/dom/media/MediaManager.cpp +++ b/dom/media/MediaManager.cpp @@ -1062,8 +1062,7 @@ public: mAudioDevice ? MediaStreamGraph::AUDIO_THREAD_DRIVER : MediaStreamGraph::SYSTEM_THREAD_DRIVER; MediaStreamGraph* msg = - MediaStreamGraph::GetInstance(graphDriverType, - dom::AudioChannel::Normal, window); + MediaStreamGraph::GetInstance(graphDriverType, window); RefPtr domStream; RefPtr stream; @@ -3719,8 +3718,7 @@ SourceListener::StopSharing() MOZ_RELEASE_ASSERT(window); window->SetAudioCapture(false); MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, - dom::AudioChannel::Normal, window); + MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, window); graph->UnregisterCaptureStreamForWindow(windowID); mStream->Destroy(); } diff --git a/dom/media/MediaStreamGraph.cpp b/dom/media/MediaStreamGraph.cpp index c4357dc59257..23944d56a768 100644 --- a/dom/media/MediaStreamGraph.cpp +++ b/dom/media/MediaStreamGraph.cpp @@ -19,7 +19,6 @@ #include "TrackUnionStream.h" #include "ImageContainer.h" #include "AudioCaptureStream.h" -#include "AudioChannelService.h" #include "AudioNodeStream.h" #include "AudioNodeExternalInputStream.h" #include "MediaStreamListener.h" @@ -59,7 +58,7 @@ enum SourceMediaStream::TrackCommands : uint32_t { }; /** - * A hash table containing the graph instances, one per AudioChannel. + * A hash table containing the graph instances, one per document. */ static nsDataHashtable gGraphs; @@ -1912,7 +1911,6 @@ MediaStream::MediaStream() , mMainThreadDestroyed(false) , mNrOfMainThreadUsers(0) , mGraph(nullptr) - , mAudioChannelType(dom::AudioChannel::Normal) { MOZ_COUNT_CTOR(MediaStream); } @@ -1997,7 +1995,6 @@ MediaStream::SetGraphImpl(MediaStreamGraphImpl* aGraph) { MOZ_ASSERT(!mGraph, "Should only be called once"); mGraph = aGraph; - mAudioChannelType = aGraph->AudioChannel(); mTracks.InitGraphRate(aGraph->GraphRate()); } @@ -3444,7 +3441,6 @@ ProcessedMediaStream::DestroyImpl() MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested, TrackRate aSampleRate, - dom::AudioChannel aChannel, AbstractThread* aMainThread) : MediaStreamGraph(aSampleRate) , mPortCount(0) @@ -3473,7 +3469,6 @@ MediaStreamGraphImpl::MediaStreamGraphImpl(GraphDriverType aDriverRequested, #ifdef DEBUG , mCanRunMessagesSynchronously(false) #endif - , mAudioChannel(aChannel) { if (mRealtime) { if (aDriverRequested == AUDIO_THREAD_DRIVER) { @@ -3509,12 +3504,10 @@ MediaStreamGraphImpl::Destroy() } static -uint32_t ChannelAndWindowToHash(dom::AudioChannel aChannel, - nsPIDOMWindowInner* aWindow) +uint32_t WindowToHash(nsPIDOMWindowInner* aWindow) { uint32_t hashkey = 0; - hashkey = AddToHash(hashkey, static_cast(aChannel)); hashkey = AddToHash(hashkey, aWindow); return hashkey; @@ -3522,20 +3515,17 @@ uint32_t ChannelAndWindowToHash(dom::AudioChannel aChannel, MediaStreamGraph* MediaStreamGraph::GetInstance(MediaStreamGraph::GraphDriverType aGraphDriverRequested, - dom::AudioChannel aChannel, nsPIDOMWindowInner* aWindow) { NS_ASSERTION(NS_IsMainThread(), "Main thread only"); - uint32_t channel = static_cast(aChannel); MediaStreamGraphImpl* graph = nullptr; - // We hash the AudioChannel and the nsPIDOMWindowInner together to form a key - // to the gloabl MediaStreamGraph hashtable. Effectively, this means there is - // a graph per document and AudioChannel. + // We hash the nsPIDOMWindowInner to form a key to the gloabl + // MediaStreamGraph hashtable. Effectively, this means there is a graph per + // document. - - uint32_t hashkey = ChannelAndWindowToHash(aChannel, aWindow); + uint32_t hashkey = WindowToHash(aWindow); if (!gGraphs.Get(hashkey, &graph)) { if (!gMediaStreamGraphShutdownBlocker) { @@ -3583,14 +3573,12 @@ MediaStreamGraph::GetInstance(MediaStreamGraph::GraphDriverType aGraphDriverRequ } graph = new MediaStreamGraphImpl(aGraphDriverRequested, CubebUtils::PreferredSampleRate(), - aChannel, mainThread); gGraphs.Put(hashkey, graph); LOG(LogLevel::Debug, - ("Starting up MediaStreamGraph %p for channel %s and window %p", - graph, AudioChannelValues::strings[channel].value, aWindow)); + ("Starting up MediaStreamGraph %p for window %p", graph, aWindow)); } return graph; @@ -3606,7 +3594,6 @@ MediaStreamGraph::CreateNonRealtimeInstance(TrackRate aSampleRate, MediaStreamGraphImpl* graph = new MediaStreamGraphImpl( OFFLINE_THREAD_DRIVER, aSampleRate, - AudioChannel::Normal, parentObject->AbstractMainThreadFor(TaskCategory::Other)); LOG(LogLevel::Debug, ("Starting up Offline MediaStreamGraph %p", graph)); diff --git a/dom/media/MediaStreamGraph.h b/dom/media/MediaStreamGraph.h index b9569b66ca6b..183088a73667 100644 --- a/dom/media/MediaStreamGraph.h +++ b/dom/media/MediaStreamGraph.h @@ -14,7 +14,6 @@ #include "mozilla/LinkedList.h" #include "mozilla/Mutex.h" #include "mozilla/TaskQueue.h" -#include "mozilla/dom/AudioChannelBinding.h" #include "nsAutoPtr.h" #include "nsAutoRef.h" #include "nsIRunnable.h" @@ -527,9 +526,6 @@ public: virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const; virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; - void SetAudioChannelType(dom::AudioChannel aType) { mAudioChannelType = aType; } - dom::AudioChannel AudioChannelType() const { return mAudioChannelType; } - bool IsSuspended() { return mSuspendedCount > 0; } void IncrementSuspendCount(); void DecrementSuspendCount(); @@ -662,8 +658,6 @@ protected: // Our media stream graph. null if destroyed on the graph thread. MediaStreamGraphImpl* mGraph; - - dom::AudioChannel mAudioChannelType; }; /** @@ -1275,7 +1269,6 @@ public: // Main thread only static MediaStreamGraph* GetInstance(GraphDriverType aGraphDriverRequested, - dom::AudioChannel aChannel, nsPIDOMWindowInner* aWindow); static MediaStreamGraph* CreateNonRealtimeInstance( TrackRate aSampleRate, diff --git a/dom/media/MediaStreamGraphImpl.h b/dom/media/MediaStreamGraphImpl.h index 84cc3f9f79b3..c8be7167ea1a 100644 --- a/dom/media/MediaStreamGraphImpl.h +++ b/dom/media/MediaStreamGraphImpl.h @@ -94,7 +94,7 @@ public: * file. It's not in the anonymous namespace because MediaStream needs to * be able to friend it. * - * There can be multiple MediaStreamGraph per process: one per AudioChannel. + * There can be multiple MediaStreamGraph per process: one per document. * Additionaly, each OfflineAudioContext object creates its own MediaStreamGraph * object too. */ @@ -119,7 +119,6 @@ public: */ explicit MediaStreamGraphImpl(GraphDriverType aGraphDriverRequested, TrackRate aSampleRate, - dom::AudioChannel aChannel, AbstractThread* aWindow); /** @@ -820,8 +819,6 @@ public: RefPtr mFarendObserverRef; #endif - dom::AudioChannel AudioChannel() const { return mAudioChannel; } - // used to limit graph shutdown time nsCOMPtr mShutdownTimer; @@ -855,8 +852,6 @@ private: */ bool mCanRunMessagesSynchronously; #endif - - dom::AudioChannel mAudioChannel; }; } // namespace mozilla diff --git a/dom/media/webaudio/AudioContext.cpp b/dom/media/webaudio/AudioContext.cpp index 085430a9ef92..4935ba55f089 100644 --- a/dom/media/webaudio/AudioContext.cpp +++ b/dom/media/webaudio/AudioContext.cpp @@ -129,7 +129,6 @@ static float GetSampleRateForAudioContext(bool aIsOffline, float aSampleRate) AudioContext::AudioContext(nsPIDOMWindowInner* aWindow, bool aIsOffline, - AudioChannel aChannel, uint32_t aNumberOfChannels, uint32_t aLength, float aSampleRate) @@ -149,7 +148,7 @@ AudioContext::AudioContext(nsPIDOMWindowInner* aWindow, // Note: AudioDestinationNode needs an AudioContext that must already be // bound to the window. - mDestination = new AudioDestinationNode(this, aIsOffline, aChannel, + mDestination = new AudioDestinationNode(this, aIsOffline, aNumberOfChannels, aLength, aSampleRate); // The context can't be muted until it has a destination. @@ -207,8 +206,7 @@ AudioContext::Constructor(const GlobalObject& aGlobal, } RefPtr object = - new AudioContext(window, false, - AudioChannelService::GetDefaultAudioChannel()); + new AudioContext(window, false); aRv = object->Init(); if (NS_WARN_IF(aRv.Failed())) { return nullptr; @@ -244,7 +242,6 @@ AudioContext::Constructor(const GlobalObject& aGlobal, RefPtr object = new AudioContext(window, true, - AudioChannel::Normal, aNumberOfChannels, aLength, aSampleRate); diff --git a/dom/media/webaudio/AudioContext.h b/dom/media/webaudio/AudioContext.h index b1c43fa1e0cf..e47f524e2b6e 100644 --- a/dom/media/webaudio/AudioContext.h +++ b/dom/media/webaudio/AudioContext.h @@ -7,7 +7,6 @@ #ifndef AudioContext_h_ #define AudioContext_h_ -#include "mozilla/dom/AudioChannelBinding.h" #include "MediaBufferDecoder.h" #include "mozilla/Attributes.h" #include "mozilla/DOMEventTargetHelper.h" @@ -121,7 +120,6 @@ class AudioContext final : public DOMEventTargetHelper, { AudioContext(nsPIDOMWindowInner* aParentWindow, bool aIsOffline, - AudioChannel aChannel, uint32_t aNumberOfChannels = 0, uint32_t aLength = 0, float aSampleRate = 0.0f); diff --git a/dom/media/webaudio/AudioDestinationNode.cpp b/dom/media/webaudio/AudioDestinationNode.cpp index 4d21e4de3090..42e789640a43 100644 --- a/dom/media/webaudio/AudioDestinationNode.cpp +++ b/dom/media/webaudio/AudioDestinationNode.cpp @@ -323,7 +323,6 @@ NS_IMPL_RELEASE_INHERITED(AudioDestinationNode, AudioNode) AudioDestinationNode::AudioDestinationNode(AudioContext* aContext, bool aIsOffline, - AudioChannel aChannel, uint32_t aNumberOfChannels, uint32_t aLength, float aSampleRate) : AudioNode(aContext, aIsOffline ? aNumberOfChannels : 2, @@ -340,7 +339,7 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext, aIsOffline ? MediaStreamGraph::CreateNonRealtimeInstance(aSampleRate, window) : MediaStreamGraph::GetInstance( - MediaStreamGraph::AUDIO_THREAD_DRIVER, aChannel, window); + MediaStreamGraph::AUDIO_THREAD_DRIVER, window); AudioNodeEngine* engine = aIsOffline ? new OfflineDestinationNodeEngine(this, aNumberOfChannels, aLength, aSampleRate) : @@ -357,11 +356,6 @@ AudioDestinationNode::AudioDestinationNode(AudioContext* aContext, if (!aIsOffline) { graph->NotifyWhenGraphStarted(mStream); } - - if (aChannel != AudioChannel::Normal) { - ErrorResult rv; - SetMozAudioChannelType(aChannel, rv); - } } AudioDestinationNode::~AudioDestinationNode() @@ -615,10 +609,6 @@ AudioDestinationNode::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& a CheckAudioChannelPermissions(aValue)) { mAudioChannel = aValue; - if (mStream) { - mStream->SetAudioChannelType(mAudioChannel); - } - if (mAudioChannelAgent) { CreateAudioChannelAgent(); } diff --git a/dom/media/webaudio/AudioDestinationNode.h b/dom/media/webaudio/AudioDestinationNode.h index c5b4bd5f9cdf..f4b6595d432c 100644 --- a/dom/media/webaudio/AudioDestinationNode.h +++ b/dom/media/webaudio/AudioDestinationNode.h @@ -25,7 +25,6 @@ public: // whether it's in offline mode. AudioDestinationNode(AudioContext* aContext, bool aIsOffline, - AudioChannel aChannel = AudioChannel::Normal, uint32_t aNumberOfChannels = 0, uint32_t aLength = 0, float aSampleRate = 0.0f); diff --git a/dom/media/webspeech/synth/nsSpeechTask.cpp b/dom/media/webspeech/synth/nsSpeechTask.cpp index 24dfff3ebcb9..adb48c28b1b1 100644 --- a/dom/media/webspeech/synth/nsSpeechTask.cpp +++ b/dom/media/webspeech/synth/nsSpeechTask.cpp @@ -171,7 +171,7 @@ nsSpeechTask::InitDirectAudio() // nullptr as final argument here means that this is not tied to a window. // This is a global MSG. mStream = MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, - AudioChannel::Normal, nullptr)-> + nullptr)-> CreateSourceStream(); mIndirectAudio = false; mInited = true; diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp index 00ba4477a82d..6e913cecc0e1 100644 --- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp +++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp @@ -379,8 +379,7 @@ already_AddRefed PeerConnectionImpl::MakeMediaStream() { MediaStreamGraph* graph = - MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, - AudioChannel::Normal, GetWindow()); + MediaStreamGraph::GetInstance(MediaStreamGraph::AUDIO_THREAD_DRIVER, GetWindow()); RefPtr stream = DOMMediaStream::CreateSourceStreamAsInput(GetWindow(), graph);