FreeBSD Bugzilla – Attachment 227789 Details for
Bug 257639
www/firefox: broken mic in WebRTC in 91.0
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
v2 (use "git am")
v2.patch (text/plain), 26.24 KB, created by
Ghost
on 2021-09-09 17:45:52 UTC
(
hide
)
Description:
v2 (use "git am")
Filename:
MIME Type:
Creator:
Ghost
Created:
2021-09-09 17:45:52 UTC
Size:
26.24 KB
patch
obsolete
>From df6498be7bba5dfc554a6bf062d9574bfe65cc07 Mon Sep 17 00:00:00 2001 >From: Evgeniy Khramtsov <evgeniy@khramtsov.org> >Date: Thu, 9 Sep 2021 18:04:46 +0300 >Subject: [PATCH] www/firefox: unbreak WebRTC microphone after 2d661b18c2c37a > >Upstream bug 1702646 regressed microphone in WebRTC with >Firefox 91, revert some of changesets to unbreak it. > >PR: 257639 >Reported by: VVD <vvd@unislabs.com> >Reported by: Aleksandr Konkov <konkovaa@hotmail.com> >Approved by: ? >Tested by: ? >--- > www/firefox/Makefile | 2 +- > www/firefox/files/patch-bug1702646 | 584 +++++++++++++++++++++++++++++ > 2 files changed, 585 insertions(+), 1 deletion(-) > create mode 100644 www/firefox/files/patch-bug1702646 > >diff --git a/www/firefox/Makefile b/www/firefox/Makefile >index 5bda986e7c34..9772f8c97ba7 100644 >--- a/www/firefox/Makefile >+++ b/www/firefox/Makefile >@@ -2,7 +2,7 @@ > > PORTNAME= firefox > DISTVERSION= 92.0 >-PORTREVISION= 2 >+PORTREVISION= 3 > PORTEPOCH= 2 > CATEGORIES= www > MASTER_SITES= MOZILLA/${PORTNAME}/releases/${DISTVERSION}/source \ >diff --git a/www/firefox/files/patch-bug1702646 b/www/firefox/files/patch-bug1702646 >new file mode 100644 >index 000000000000..232b59027dbf >--- /dev/null >+++ b/www/firefox/files/patch-bug1702646 >@@ -0,0 +1,584 @@ >+From 80112dfa8aef0f6391e629c3b1e67c6bb1d8554c Mon Sep 17 00:00:00 2001 >+From: Evgeniy Khramtsov <evgeniy@khramtsov.org> >+Date: Thu, 9 Sep 2021 17:52:48 +0300 >+Subject: [PATCH] Revert bug 1702646 >+ >+Revert changesets: >+https://github.com/mozilla/gecko-dev/commit/0a9065018a56a7812b15411051143c2c8f7b1a08 >+https://github.com/mozilla/gecko-dev/commit/d2f2ea20bbc9e1e7bc6858ea19d689624f27055a >+https://github.com/mozilla/gecko-dev/commit/c95e8979b6b673658cdc51313d01db388bc3ff5d >+https://github.com/mozilla/gecko-dev/commit/1f72372ece815dd5c59e9a34ca0754ea84124713 >+ >+1f* is the first bad changeset, it cannot be reverted alone cleanly. >+ >+See: >+https://bugzilla.mozilla.org/show_bug.cgi?id=1702646 >+https://bugzilla.mozilla.org/show_bug.cgi?id=1725810 >+https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257639 >+--- >+ dom/media/AudioSegment.h | 45 ------- >+ dom/media/MediaTrackGraph.cpp | 63 +++------- >+ dom/media/MediaTrackGraph.h | 14 +-- >+ dom/media/MediaTrackGraphImpl.h | 35 ++++-- >+ dom/media/gtest/TestAudioInputProcessing.cpp | 10 +- >+ dom/media/webrtc/MediaEngineWebRTCAudio.cpp | 119 +++++++++---------- >+ dom/media/webrtc/MediaEngineWebRTCAudio.h | 15 ++- >+ 7 files changed, 116 insertions(+), 185 deletions(-) >+ >+diff --git dom/media/AudioSegment.h dom/media/AudioSegment.h >+index 4ec71c92bc..a0aee574e5 100644 >+--- dom/media/AudioSegment.h >++++ dom/media/AudioSegment.h >+@@ -377,51 +377,6 @@ class AudioSegment : public MediaSegmentBase<AudioSegment, AudioChunk> { >+ chunk->mBufferFormat = AUDIO_FORMAT_S16; >+ chunk->mPrincipalHandle = aPrincipalHandle; >+ } >+- void AppendSegment(const AudioSegment* aSegment, >+- const PrincipalHandle& aPrincipalHandle) { >+- MOZ_ASSERT(aSegment); >+- >+- for (const AudioChunk& c : aSegment->mChunks) { >+- AudioChunk* chunk = AppendChunk(c.GetDuration()); >+- chunk->mBuffer = c.mBuffer; >+- chunk->mChannelData = c.mChannelData; >+- chunk->mBufferFormat = c.mBufferFormat; >+- chunk->mPrincipalHandle = aPrincipalHandle; >+- } >+- } >+- template <typename T> >+- void AppendFromInterleavedBuffer(const T* aBuffer, size_t aFrames, >+- uint32_t aChannels, >+- const PrincipalHandle& aPrincipalHandle) { >+- MOZ_ASSERT(aChannels >= 1 && aChannels <= 8, "Support up to 8 channels"); >+- >+- CheckedInt<size_t> bufferSize(sizeof(T)); >+- bufferSize *= aFrames; >+- bufferSize *= aChannels; >+- RefPtr<SharedBuffer> buffer = SharedBuffer::Create(bufferSize); >+- AutoTArray<const T*, 8> channels; >+- if (aChannels == 1) { >+- PodCopy(static_cast<T*>(buffer->Data()), aBuffer, aFrames); >+- channels.AppendElement(static_cast<T*>(buffer->Data())); >+- } else { >+- channels.SetLength(aChannels); >+- AutoTArray<T*, 8> writeChannels; >+- writeChannels.SetLength(aChannels); >+- T* samples = static_cast<T*>(buffer->Data()); >+- >+- size_t offset = 0; >+- for (uint32_t i = 0; i < aChannels; ++i) { >+- channels[i] = writeChannels[i] = samples + offset; >+- offset += aFrames; >+- } >+- >+- DeinterleaveAndConvertBuffer(aBuffer, aFrames, aChannels, >+- writeChannels.Elements()); >+- } >+- >+- MOZ_ASSERT(aChannels == channels.Length()); >+- AppendFrames(buffer.forget(), channels, aFrames, aPrincipalHandle); >+- } >+ // Consumes aChunk, and returns a pointer to the persistent copy of aChunk >+ // in the segment. >+ AudioChunk* AppendAndConsumeChunk(AudioChunk&& aChunk) { >+diff --git dom/media/MediaTrackGraph.cpp dom/media/MediaTrackGraph.cpp >+index 3b5d376028..d97eb12b90 100644 >+--- dom/media/MediaTrackGraph.cpp >++++ dom/media/MediaTrackGraph.cpp >+@@ -62,27 +62,23 @@ LazyLogModule gMediaTrackGraphLog("MediaTrackGraph"); >+ */ >+ static nsTHashMap<nsUint32HashKey, MediaTrackGraphImpl*> gGraphs; >+ >+-void NativeInputTrack::AudioDataBuffers::SetOutputData(AudioDataValue* aBuffer, >+- size_t aFrames, >+- uint32_t aChannels, >+- TrackRate aRate) { >+- mOutputData = Some(BufferInfo{aBuffer, aFrames, aChannels, aRate}); >++void NativeInputTrack::AudioDataBuffers::SetOutputData( >++ const AudioDataValue* aBuffer, size_t aFrames, uint32_t aChannels) { >++ mOutputData.Set(aBuffer, aFrames, aChannels); >+ } >+ >+-void NativeInputTrack::AudioDataBuffers::SetInputData(AudioDataValue* aBuffer, >+- size_t aFrames, >+- uint32_t aChannels, >+- TrackRate aRate) { >+- mInputData = Some(BufferInfo{aBuffer, aFrames, aChannels, aRate}); >++void NativeInputTrack::AudioDataBuffers::SetInputData( >++ const AudioDataValue* aBuffer, size_t aFrames, uint32_t aChannels) { >++ mInputData.Set(aBuffer, aFrames, aChannels); >+ } >+ >+ void NativeInputTrack::AudioDataBuffers::Clear(Scope aScope) { >+ if (aScope & Scope::Input) { >+- mInputData.take(); >++ mInputData.Clear(); >+ } >+ >+ if (aScope & Scope::Output) { >+- mOutputData.take(); >++ mOutputData.Clear(); >+ } >+ } >+ >+@@ -120,33 +116,12 @@ void NativeInputTrack::ProcessInput(GraphTime aFrom, GraphTime aTo, >+ uint32_t aFlags) { >+ MOZ_ASSERT(mGraph->OnGraphThreadOrNotRunning()); >+ TRACE_COMMENT("NativeInputTrack %p", this); >+- >+- if (!mDataHolder || !mDataHolder->mInputData) { >+- return; >+- } >+- >+- // One NotifyInputData might have multiple following ProcessInput calls, but >+- // we only process one input per NotifyInputData call. >+- NativeInputTrack::AudioDataBuffers::BufferInfo inputInfo = >+- mDataHolder->mInputData.extract(); >+- >+- MOZ_ASSERT(mInputChannels == inputInfo.mChannels); >+- MOZ_ASSERT(inputInfo.mChannels >= 1 && inputInfo.mChannels <= 8, >+- "Support up to 8 channels"); >+- >+- GetData<AudioSegment>()->Clear(); >+- GetData<AudioSegment>()->AppendFromInterleavedBuffer( >+- inputInfo.mBuffer, inputInfo.mFrames, inputInfo.mChannels, >+- PRINCIPAL_HANDLE_NONE); >+- >+- LOG(LogLevel::Verbose, >+- ("NativeInputTrack %p Appending %zu frames of raw audio", this, >+- inputInfo.mFrames)); >++ // TODO: Put input data to mSegment >+ } >+ >+ uint32_t NativeInputTrack::NumberOfChannels() const { >+ MOZ_ASSERT(mGraph->OnGraphThreadOrNotRunning()); >+- return mInputChannels; >++ return mDataHolder ? mDataHolder->mInputData.mChannels : 0; >+ } >+ >+ void NativeInputTrack::InitDataHolderIfNeeded() { >+@@ -162,9 +137,11 @@ void NativeInputTrack::NotifyOutputData(MediaTrackGraphImpl* aGraph, >+ MOZ_ASSERT(aGraph->OnGraphThreadOrNotRunning()); >+ MOZ_ASSERT(aGraph == mGraph, "Receive output data from another graph"); >+ MOZ_ASSERT(mDataHolder); >+- mDataHolder->SetOutputData(aBuffer, aFrames, aChannels, aRate); >++ mDataHolder->SetOutputData(aBuffer, aFrames, aChannels); >+ for (auto& listener : mDataUsers) { >+- listener->NotifyOutputData(aGraph, mDataHolder->mOutputData.value()); >++ listener->NotifyOutputData(aGraph, mDataHolder->mOutputData.mBuffer, >++ mDataHolder->mOutputData.mFrames, aRate, >++ mDataHolder->mOutputData.mChannels); >+ } >+ } >+ >+@@ -173,7 +150,6 @@ void NativeInputTrack::NotifyInputStopped(MediaTrackGraphImpl* aGraph) { >+ MOZ_ASSERT(aGraph == mGraph, >+ "Receive input stopped signal from another graph"); >+ MOZ_ASSERT(mDataHolder); >+- mInputChannels = 0; >+ mDataHolder->Clear(AudioDataBuffers::Scope::Input); >+ for (auto& listener : mDataUsers) { >+ listener->NotifyInputStopped(aGraph); >+@@ -189,14 +165,11 @@ void NativeInputTrack::NotifyInputData(MediaTrackGraphImpl* aGraph, >+ MOZ_ASSERT(aGraph == mGraph, "Receive input data from another graph"); >+ >+ MOZ_ASSERT(mDataHolder); >+- MOZ_ASSERT(aChannels); >+- if (!mInputChannels) { >+- mInputChannels = aChannels; >+- } >+- mDataHolder->SetInputData(const_cast<AudioDataValue*>(aBuffer), aFrames, >+- aChannels, aRate); >++ mDataHolder->SetInputData(aBuffer, aFrames, aChannels); >+ for (auto& listener : mDataUsers) { >+- listener->NotifyInputData(aGraph, mDataHolder->mInputData.value(), >++ listener->NotifyInputData(aGraph, mDataHolder->mInputData.mBuffer, >++ mDataHolder->mInputData.mFrames, aRate, >++ mDataHolder->mInputData.mChannels, >+ aAlreadyBuffered); >+ } >+ } >+diff --git dom/media/MediaTrackGraph.h dom/media/MediaTrackGraph.h >+index d85cb502b9..6d92f01b48 100644 >+--- dom/media/MediaTrackGraph.h >++++ dom/media/MediaTrackGraph.h >+@@ -107,14 +107,6 @@ class AudioDataListenerInterface { >+ virtual ~AudioDataListenerInterface() = default; >+ >+ public: >+- // Information for the interleaved buffer coming from the audio callbacks >+- struct BufferInfo { >+- AudioDataValue* mBuffer = nullptr; >+- size_t mFrames = 0; >+- uint32_t mChannels = 0; >+- TrackRate mRate = 0; >+- }; >+- >+ /* These are for cubeb audio input & output streams: */ >+ /** >+ * Output data to speakers, for use as the "far-end" data for echo >+@@ -122,7 +114,8 @@ class AudioDataListenerInterface { >+ * chunks. >+ */ >+ virtual void NotifyOutputData(MediaTrackGraphImpl* aGraph, >+- BufferInfo aInfo) = 0; >++ AudioDataValue* aBuffer, size_t aFrames, >++ TrackRate aRate, uint32_t aChannels) = 0; >+ /** >+ * An AudioCallbackDriver with an input stream signaling that it has stopped >+ * for any reason and the AudioDataListener will not be notified of input data >+@@ -134,7 +127,8 @@ class AudioDataListenerInterface { >+ * guaranteed to be in any particular size chunks. >+ */ >+ virtual void NotifyInputData(MediaTrackGraphImpl* aGraph, >+- const BufferInfo aInfo, >++ const AudioDataValue* aBuffer, size_t aFrames, >++ TrackRate aRate, uint32_t aChannels, >+ uint32_t aAlreadyBuffered) = 0; >+ >+ /** >+diff --git dom/media/MediaTrackGraphImpl.h dom/media/MediaTrackGraphImpl.h >+index 8baeb25a7d..52c08112b5 100644 >+--- dom/media/MediaTrackGraphImpl.h >++++ dom/media/MediaTrackGraphImpl.h >+@@ -75,13 +75,32 @@ class NativeInputTrack : public ProcessedMediaTrack { >+ nsTArray<RefPtr<AudioDataListener>> mDataUsers; >+ >+ private: >++ struct BufferInfo { >++ AudioDataValue* mBuffer = nullptr; >++ size_t mFrames = 0; >++ uint32_t mChannels = 0; >++ >++ void Set(const AudioDataValue* aBuffer, size_t aFrames, >++ uint32_t aChannels) { >++ mBuffer = const_cast<AudioDataValue*>(aBuffer); >++ mFrames = aFrames; >++ mChannels = aChannels; >++ } >++ >++ void Clear() { >++ mBuffer = nullptr; >++ mFrames = 0; >++ mChannels = 0; >++ } >++ }; >++ >+ class AudioDataBuffers { >+ public: >+ AudioDataBuffers() = default; >+- void SetOutputData(AudioDataValue* aBuffer, size_t aFrames, >+- uint32_t aChannels, TrackRate aRate); >+- void SetInputData(AudioDataValue* aBuffer, size_t aFrames, >+- uint32_t aChannels, TrackRate aRate); >++ void SetOutputData(const AudioDataValue* aBuffer, size_t aFrames, >++ uint32_t aChannels); >++ void SetInputData(const AudioDataValue* aBuffer, size_t aFrames, >++ uint32_t aChannels); >+ >+ enum Scope : unsigned char { >+ Input = 0x01, >+@@ -89,20 +108,16 @@ class NativeInputTrack : public ProcessedMediaTrack { >+ }; >+ void Clear(Scope aScope); >+ >+- typedef AudioDataListenerInterface::BufferInfo BufferInfo; >+ // Storing the audio output data coming from NotifyOutputData >+- Maybe<BufferInfo> mOutputData; >++ BufferInfo mOutputData; >+ // Storing the audio input data coming from NotifyInputData >+- Maybe<BufferInfo> mInputData; >++ BufferInfo mInputData; >+ }; >+ >+ // Only accessed on the graph thread. >+ // Storing the audio data coming from GraphDriver directly. >+ Maybe<AudioDataBuffers> mDataHolder; >+ >+- // Only accessed on the graph thread. >+- uint32_t mInputChannels = 0; >+- >+ // Only accessed on the main thread. >+ // When this becomes zero, this NativeInputTrack is no longer needed. >+ int32_t mUserCount = 0; >+diff --git dom/media/gtest/TestAudioInputProcessing.cpp dom/media/gtest/TestAudioInputProcessing.cpp >+index ed5d14fcb8..c78a56080a 100644 >+--- dom/media/gtest/TestAudioInputProcessing.cpp >++++ dom/media/gtest/TestAudioInputProcessing.cpp >+@@ -70,11 +70,8 @@ TEST(TestAudioInputProcessing, UnaccountedPacketizerBuffering) >+ processedTime = 0; >+ nextTime = MediaTrackGraphImpl::RoundUpToEndOfAudioBlock(nrFrames); >+ generator.GenerateInterleaved(buffer.Elements(), nrFrames); >+- aip->NotifyInputData(graph, >+- AudioInputProcessing::BufferInfo{ >+- buffer.Elements(), nrFrames, channels, rate}, >++ aip->NotifyInputData(graph, buffer.Elements(), nrFrames, rate, channels, >+ nextTime - nrFrames); >+- aip->ProcessInput(graph, nullptr); >+ aip->Pull(graph, processedTime, nextTime, segment.GetDuration(), &segment, >+ true, &ended); >+ EXPECT_EQ(aip->NumBufferedFrames(graph), 24U); >+@@ -90,11 +87,8 @@ TEST(TestAudioInputProcessing, UnaccountedPacketizerBuffering) >+ processedTime = nextTime; >+ nextTime = MediaTrackGraphImpl::RoundUpToEndOfAudioBlock(2 * nrFrames); >+ generator.GenerateInterleaved(buffer.Elements(), nrFrames); >+- aip->NotifyInputData(graph, >+- AudioInputProcessing::BufferInfo{ >+- buffer.Elements(), nrFrames, channels, rate}, >++ aip->NotifyInputData(graph, buffer.Elements(), nrFrames, rate, channels, >+ nextTime - (2 * nrFrames)); >+- aip->ProcessInput(graph, nullptr); >+ aip->Pull(graph, processedTime, nextTime, segment.GetDuration(), &segment, >+ true, &ended); >+ EXPECT_EQ(aip->NumBufferedFrames(graph), 120U); >+diff --git dom/media/webrtc/MediaEngineWebRTCAudio.cpp dom/media/webrtc/MediaEngineWebRTCAudio.cpp >+index fb59fc195f..9c2d1f2ff2 100644 >+--- dom/media/webrtc/MediaEngineWebRTCAudio.cpp >++++ dom/media/webrtc/MediaEngineWebRTCAudio.cpp >+@@ -867,20 +867,21 @@ void AudioInputProcessing::Pull(MediaTrackGraphImpl* aGraph, GraphTime aFrom, >+ } >+ >+ void AudioInputProcessing::NotifyOutputData(MediaTrackGraphImpl* aGraph, >+- BufferInfo aInfo) { >++ AudioDataValue* aBuffer, >++ size_t aFrames, TrackRate aRate, >++ uint32_t aChannels) { >+ MOZ_ASSERT(aGraph->OnGraphThread()); >+ MOZ_ASSERT(mEnabled); >+ >+- if (!mPacketizerOutput || >+- mPacketizerOutput->mPacketSize != aInfo.mRate / 100u || >+- mPacketizerOutput->mChannels != aInfo.mChannels) { >++ if (!mPacketizerOutput || mPacketizerOutput->mPacketSize != aRate / 100u || >++ mPacketizerOutput->mChannels != aChannels) { >+ // It's ok to drop the audio still in the packetizer here: if this changes, >+ // we changed devices or something. >+ mPacketizerOutput = MakeUnique<AudioPacketizer<AudioDataValue, float>>( >+- aInfo.mRate / 100, aInfo.mChannels); >++ aRate / 100, aChannels); >+ } >+ >+- mPacketizerOutput->Input(aInfo.mBuffer, aInfo.mFrames); >++ mPacketizerOutput->Input(aBuffer, aFrames); >+ >+ while (mPacketizerOutput->PacketsAvailable()) { >+ uint32_t samplesPerPacket = >+@@ -899,11 +900,11 @@ void AudioInputProcessing::NotifyOutputData(MediaTrackGraphImpl* aGraph, >+ uint32_t channelCountFarend = 0; >+ uint32_t framesPerPacketFarend = 0; >+ >+- // Downmix from aInfo.mChannels to MAX_CHANNELS if needed. We always have >+- // floats here, the packetized performed the conversion. >+- if (aInfo.mChannels > MAX_CHANNELS) { >++ // Downmix from aChannels to MAX_CHANNELS if needed. We always have floats >++ // here, the packetized performed the conversion. >++ if (aChannels > MAX_CHANNELS) { >+ AudioConverter converter( >+- AudioConfig(aInfo.mChannels, 0, AudioConfig::FORMAT_FLT), >++ AudioConfig(aChannels, 0, AudioConfig::FORMAT_FLT), >+ AudioConfig(MAX_CHANNELS, 0, AudioConfig::FORMAT_FLT)); >+ framesPerPacketFarend = mPacketizerOutput->mPacketSize; >+ framesPerPacketFarend = >+@@ -913,9 +914,9 @@ void AudioInputProcessing::NotifyOutputData(MediaTrackGraphImpl* aGraph, >+ deinterleavedPacketDataChannelPointers.SetLength(MAX_CHANNELS); >+ } else { >+ interleavedFarend = packet; >+- channelCountFarend = aInfo.mChannels; >++ channelCountFarend = aChannels; >+ framesPerPacketFarend = mPacketizerOutput->mPacketSize; >+- deinterleavedPacketDataChannelPointers.SetLength(aInfo.mChannels); >++ deinterleavedPacketDataChannelPointers.SetLength(aChannels); >+ } >+ >+ MOZ_ASSERT(interleavedFarend && >+@@ -941,7 +942,7 @@ void AudioInputProcessing::NotifyOutputData(MediaTrackGraphImpl* aGraph, >+ >+ // Having the same config for input and output means we potentially save >+ // some CPU. >+- StreamConfig inputConfig(aInfo.mRate, channelCountFarend, false); >++ StreamConfig inputConfig(aRate, channelCountFarend, false); >+ StreamConfig outputConfig = inputConfig; >+ >+ // Passing the same pointers here saves a copy inside this function. >+@@ -1078,34 +1079,45 @@ void AudioInputProcessing::PacketizeAndProcess(MediaTrackGraphImpl* aGraph, >+ } >+ } >+ >+-void AudioInputProcessing::ProcessInput(MediaTrackGraphImpl* aGraph, >+- const AudioSegment* aSegment) { >+- MOZ_ASSERT(aGraph); >+- MOZ_ASSERT(aGraph->OnGraphThread()); >+- >+- if (mEnded || !mEnabled || !mLiveFramesAppended || !mInputData) { >++template <typename T> >++void AudioInputProcessing::InsertInGraph(MediaTrackGraphImpl* aGraph, >++ const T* aBuffer, size_t aFrames, >++ uint32_t aChannels) { >++ if (mEnded) { >+ return; >+ } >+ >+- // One NotifyInputData might have multiple following ProcessInput calls, but >+- // we only process one input per NotifyInputData call. >+- BufferInfo inputInfo = mInputData.extract(); >++ MOZ_ASSERT(aChannels >= 1 && aChannels <= 8, "Support up to 8 channels"); >+ >+- // If some processing is necessary, packetize and insert in the WebRTC.org >+- // code. Otherwise, directly insert the mic data in the MTG, bypassing all >+- // processing. >+- if (PassThrough(aGraph)) { >+- if (aSegment) { >+- mSegment.AppendSegment(aSegment, mPrincipal); >+- } else { >+- mSegment.AppendFromInterleavedBuffer(inputInfo.mBuffer, inputInfo.mFrames, >+- inputInfo.mChannels, mPrincipal); >+- } >++ CheckedInt<size_t> bufferSize(sizeof(T)); >++ bufferSize *= aFrames; >++ bufferSize *= aChannels; >++ RefPtr<SharedBuffer> buffer = SharedBuffer::Create(bufferSize); >++ AutoTArray<const T*, 8> channels; >++ if (aChannels == 1) { >++ PodCopy(static_cast<T*>(buffer->Data()), aBuffer, aFrames); >++ channels.AppendElement(static_cast<T*>(buffer->Data())); >+ } else { >+- MOZ_ASSERT(aGraph->GraphRate() == inputInfo.mRate); >+- PacketizeAndProcess(aGraph, inputInfo.mBuffer, inputInfo.mFrames, >+- inputInfo.mRate, inputInfo.mChannels); >++ channels.SetLength(aChannels); >++ AutoTArray<T*, 8> write_channels; >++ write_channels.SetLength(aChannels); >++ T* samples = static_cast<T*>(buffer->Data()); >++ >++ size_t offset = 0; >++ for (uint32_t i = 0; i < aChannels; ++i) { >++ channels[i] = write_channels[i] = samples + offset; >++ offset += aFrames; >++ } >++ >++ DeinterleaveAndConvertBuffer(aBuffer, aFrames, aChannels, >++ write_channels.Elements()); >+ } >++ >++ LOG_FRAME("AudioInputProcessing %p Appending %zu frames of raw audio", this, >++ aFrames); >++ >++ MOZ_ASSERT(aChannels == channels.Length()); >++ mSegment.AppendFrames(buffer.forget(), channels, aFrames, mPrincipal); >+ } >+ >+ void AudioInputProcessing::NotifyInputStopped(MediaTrackGraphImpl* aGraph) { >+@@ -1119,13 +1131,14 @@ void AudioInputProcessing::NotifyInputStopped(MediaTrackGraphImpl* aGraph) { >+ if (mPacketizerInput) { >+ mPacketizerInput->Clear(); >+ } >+- mInputData.take(); >+ } >+ >+ // Called back on GraphDriver thread! >+ // Note this can be called back after ::Stop() >+ void AudioInputProcessing::NotifyInputData(MediaTrackGraphImpl* aGraph, >+- const BufferInfo aInfo, >++ const AudioDataValue* aBuffer, >++ size_t aFrames, TrackRate aRate, >++ uint32_t aChannels, >+ uint32_t aAlreadyBuffered) { >+ MOZ_ASSERT(aGraph->OnGraphThread()); >+ TRACE(); >+@@ -1139,7 +1152,14 @@ void AudioInputProcessing::NotifyInputData(MediaTrackGraphImpl* aGraph, >+ mLiveBufferingAppended = aAlreadyBuffered; >+ } >+ >+- mInputData = Some(aInfo); >++ // If some processing is necessary, packetize and insert in the WebRTC.org >++ // code. Otherwise, directly insert the mic data in the MTG, bypassing all >++ // processing. >++ if (PassThrough(aGraph)) { >++ InsertInGraph<AudioDataValue>(aGraph, aBuffer, aFrames, aChannels); >++ } else { >++ PacketizeAndProcess(aGraph, aBuffer, aFrames, aRate, aChannels); >++ } >+ } >+ >+ #define ResetProcessingIfNeeded(_processing) \ >+@@ -1173,7 +1193,6 @@ void AudioInputProcessing::DeviceChanged(MediaTrackGraphImpl* aGraph) { >+ void AudioInputProcessing::End() { >+ mEnded = true; >+ mSegment.Clear(); >+- mInputData.take(); >+ } >+ >+ TrackTime AudioInputProcessing::NumBufferedFrames( >+@@ -1230,28 +1249,6 @@ void AudioInputTrack::DestroyImpl() { >+ void AudioInputTrack::ProcessInput(GraphTime aFrom, GraphTime aTo, >+ uint32_t aFlags) { >+ TRACE_COMMENT("AudioInputTrack %p", this); >+- >+- // Check if there is a connected NativeInputTrack >+- NativeInputTrack* source = nullptr; >+- if (!mInputs.IsEmpty()) { >+- for (const MediaInputPort* input : mInputs) { >+- MOZ_ASSERT(input->GetSource()); >+- if (input->GetSource()->AsNativeInputTrack()) { >+- source = input->GetSource()->AsNativeInputTrack(); >+- break; >+- } >+- } >+- } >+- >+- // Push the input data from the connected NativeInputTrack to mInputProcessing >+- if (source) { >+- MOZ_ASSERT(source->GraphImpl() == GraphImpl()); >+- MOZ_ASSERT(source->mSampleRate == mSampleRate); >+- MOZ_ASSERT(GraphImpl()->GraphRate() == mSampleRate); >+- mInputProcessing->ProcessInput(GraphImpl(), >+- source->GetData<AudioSegment>()); >+- } >+- >+ bool ended = false; >+ mInputProcessing->Pull( >+ GraphImpl(), aFrom, aTo, TrackTimeToGraphTime(GetEnd()), >+diff --git dom/media/webrtc/MediaEngineWebRTCAudio.h dom/media/webrtc/MediaEngineWebRTCAudio.h >+index 46a66d9a7a..408bbc6b6e 100644 >+--- dom/media/webrtc/MediaEngineWebRTCAudio.h >++++ dom/media/webrtc/MediaEngineWebRTCAudio.h >+@@ -141,9 +141,13 @@ class AudioInputProcessing : public AudioDataListener { >+ GraphTime aTrackEnd, AudioSegment* aSegment, >+ bool aLastPullThisIteration, bool* aEnded); >+ >+- void NotifyOutputData(MediaTrackGraphImpl* aGraph, BufferInfo aInfo) override; >++ void NotifyOutputData(MediaTrackGraphImpl* aGraph, AudioDataValue* aBuffer, >++ size_t aFrames, TrackRate aRate, >++ uint32_t aChannels) override; >+ void NotifyInputStopped(MediaTrackGraphImpl* aGraph) override; >+- void NotifyInputData(MediaTrackGraphImpl* aGraph, const BufferInfo aInfo, >++ void NotifyInputData(MediaTrackGraphImpl* aGraph, >++ const AudioDataValue* aBuffer, size_t aFrames, >++ TrackRate aRate, uint32_t aChannels, >+ uint32_t aAlreadyBuffered) override; >+ bool IsVoiceInput(MediaTrackGraphImpl* aGraph) const override { >+ // If we're passing data directly without AEC or any other process, this >+@@ -163,8 +167,9 @@ class AudioInputProcessing : public AudioDataListener { >+ >+ void Disconnect(MediaTrackGraphImpl* aGraph) override; >+ >+- // aSegment stores the unprocessed non-interleaved audio input data from mic >+- void ProcessInput(MediaTrackGraphImpl* aGraph, const AudioSegment* aSegment); >++ template <typename T> >++ void InsertInGraph(MediaTrackGraphImpl* aGraph, const T* aBuffer, >++ size_t aFrames, uint32_t aChannels); >+ >+ void PacketizeAndProcess(MediaTrackGraphImpl* aGraph, >+ const AudioDataValue* aBuffer, size_t aFrames, >+@@ -242,8 +247,6 @@ class AudioInputProcessing : public AudioDataListener { >+ bool mEnabled; >+ // Whether or not we've ended and removed the AudioInputTrack. >+ bool mEnded; >+- // Store the unprocessed interleaved audio input data >+- Maybe<BufferInfo> mInputData; >+ }; >+ >+ // MediaTrack subclass tailored for MediaEngineWebRTCMicrophoneSource. >+-- >+2.32.0 >+ >-- >2.32.0 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
2khramtsov
:
maintainer-approval?
Actions:
View
|
Diff
Attachments on
bug 257639
:
227770
| 227789