Bug 1404977 - Part 14 - Consistently pass the MSG to the AudioDataListener methods to be able to write thread asserts. r?pehrsons
MozReview-Commit-ID: LMmiuemAXF2
--- a/dom/media/MediaStreamGraph.cpp
+++ b/dom/media/MediaStreamGraph.cpp
@@ -985,17 +985,17 @@ void MediaStreamGraphImpl::DeviceChanged
if (!mInputDeviceID) {
return;
}
nsTArray<RefPtr<AudioDataListener>>* listeners =
mInputDeviceUsers.GetValue(mInputDeviceID);
for (auto& listener : *listeners) {
- listener->DeviceChanged();
+ listener->DeviceChanged(this);
}
}
void MediaStreamGraphImpl::DeviceChanged()
{
// This is safe to be called from any thread: this message comes from an
// underlying platform API, and we don't have much guarantees. If it is not
// called from the main thread (and it probably will rarely be), it will post
--- a/dom/media/MediaStreamGraph.h
+++ b/dom/media/MediaStreamGraph.h
@@ -115,22 +115,22 @@ public:
*/
virtual void NotifyInputData(MediaStreamGraph* aGraph,
const AudioDataValue* aBuffer, size_t aFrames,
TrackRate aRate, uint32_t aChannels) = 0;
/**
* Number of audio input channels.
*/
- virtual uint32_t InputChannelCount() = 0;
+ virtual uint32_t InputChannelCount(MediaStreamGraph* aGraph) = 0;
/**
* Called when the underlying audio device has changed.
*/
- virtual void DeviceChanged() = 0;
+ virtual void DeviceChanged(MediaStreamGraph* aGraph) = 0;
};
class AudioDataListener : public AudioDataListenerInterface {
protected:
// Protected destructor, to discourage deletion outside of Release():
virtual ~AudioDataListener() {}
public:
--- a/dom/media/MediaStreamGraphImpl.h
+++ b/dom/media/MediaStreamGraphImpl.h
@@ -475,17 +475,17 @@ public:
uint32_t maxInputChannels = 0;
// When/if we decide to support multiple input device per graph, this needs
// loop over them.
nsTArray<RefPtr<AudioDataListener>>* listeners =
mInputDeviceUsers.GetValue(mInputDeviceID);
MOZ_ASSERT(listeners);
for (const auto& listener : *listeners) {
maxInputChannels =
- std::max(maxInputChannels, listener->InputChannelCount());
+ std::max(maxInputChannels, listener->InputChannelCount(this));
}
return maxInputChannels;
}
CubebUtils::AudioDeviceID InputDeviceID()
{
return mInputDeviceID;
}
--- a/dom/media/webrtc/MediaEngineWebRTC.h
+++ b/dom/media/webrtc/MediaEngineWebRTC.h
@@ -180,19 +180,19 @@ public:
uint32_t aChannels) override;
void NotifyInputData(MediaStreamGraph* aGraph,
const AudioDataValue* aBuffer,
size_t aFrames,
TrackRate aRate,
uint32_t aChannels) override;
- uint32_t InputChannelCount() override;
+ uint32_t InputChannelCount(MediaStreamGraph* aGraph) override;
- void DeviceChanged() override;
+ void DeviceChanged(MediaStreamGraph* aGraph) override;
void Shutdown();
private:
Mutex mMutex;
RefPtr<MediaEngineWebRTCMicrophoneSource> mAudioSource;
};
@@ -249,19 +249,19 @@ public:
// AudioDataListenerInterface methods
void NotifyOutputData(MediaStreamGraph* aGraph,
AudioDataValue* aBuffer, size_t aFrames,
TrackRate aRate, uint32_t aChannels) override;
void NotifyInputData(MediaStreamGraph* aGraph,
const AudioDataValue* aBuffer, size_t aFrames,
TrackRate aRate, uint32_t aChannels) override;
- void DeviceChanged() override;
+ void DeviceChanged(MediaStreamGraph* aGraph) override;
- uint32_t InputChannelCount() override
+ uint32_t InputChannelCount(MediaStreamGraph* aGraph) override
{
return GetRequestedInputChannelCount();
}
dom::MediaSourceEnum GetMediaSource() const override
{
return dom::MediaSourceEnum::Microphone;
}
--- a/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
+++ b/dom/media/webrtc/MediaEngineWebRTCAudio.cpp
@@ -73,28 +73,30 @@ WebRTCAudioDataListener::NotifyInputData
{
MOZ_ASSERT(static_cast<MediaStreamGraphImpl*>(aGraph)->CurrentDriver()->OnThread());
if (mAudioSource) {
mAudioSource->NotifyInputData(aGraph, aBuffer, aFrames, aRate, aChannels);
}
}
void
-WebRTCAudioDataListener::DeviceChanged()
+WebRTCAudioDataListener::DeviceChanged(MediaStreamGraph* aGraph)
{
+ MOZ_ASSERT(static_cast<MediaStreamGraphImpl*>(aGraph)->CurrentDriver()->OnThread());
if (mAudioSource) {
- mAudioSource->DeviceChanged();
+ mAudioSource->DeviceChanged(aGraph);
}
}
uint32_t
-WebRTCAudioDataListener::InputChannelCount()
+WebRTCAudioDataListener::InputChannelCount(MediaStreamGraph* aGraph)
{
+ MOZ_ASSERT(static_cast<MediaStreamGraphImpl*>(aGraph)->CurrentDriver()->OnThread());
if (mAudioSource) {
- return mAudioSource->InputChannelCount();
+ return mAudioSource->InputChannelCount(aGraph);
}
return 0;
}
void
WebRTCAudioDataListener::Shutdown()
{
mAudioSource = nullptr;
@@ -1214,17 +1216,17 @@ do {
#_processing " on device change."); \
return; \
} \
\
} \
} while(0)
void
-MediaEngineWebRTCMicrophoneSource::DeviceChanged()
+MediaEngineWebRTCMicrophoneSource::DeviceChanged(MediaStreamGraph* aGraph)
{
MOZ_ASSERT(!mAllocations.IsEmpty() &&
mAllocations[0].mStream &&
mAllocations[0].mStream->GraphImpl()->CurrentDriver()->OnThread());
// Reset some processing
ResetProcessingIfNeeded(gain_control);
ResetProcessingIfNeeded(echo_cancellation);
ResetProcessingIfNeeded(noise_suppression);