Title: [288439] trunk/Source/WebCore
- Revision
- 288439
- Author
- [email protected]
- Date
- 2022-01-24 07:37:20 -0800 (Mon, 24 Jan 2022)
Log Message
Reconfiguring the CoreAudioSharedUnit should take into account that there is a speaker sample producer
https://bugs.webkit.org/show_bug.cgi?id=235397
<rdar://problem/87819949>
Reviewed by Eric Carlson and Geoff Garen.
Address post-commit comments.
Introduce a boolean to make high priority thread callbacks no-ops when reconfiguring the audio unit.
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (288438 => 288439)
--- trunk/Source/WebCore/ChangeLog 2022-01-24 14:26:56 UTC (rev 288438)
+++ trunk/Source/WebCore/ChangeLog 2022-01-24 15:37:20 UTC (rev 288439)
@@ -1,3 +1,16 @@
+2022-01-24 Youenn Fablet <[email protected]>
+
+ Reconfiguring the CoreAudioSharedUnit should take into account that there is a speaker sample producer
+ https://bugs.webkit.org/show_bug.cgi?id=235397
+ <rdar://problem/87819949>
+
+ Reviewed by Eric Carlson and Geoff Garen.
+
+ Address post-commit comments.
+ Introduce a boolean to make high priority thread callbacks no-ops when reconfiguring the audio unit.
+
+ * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+
2022-01-24 Adrian Perez de Castro <[email protected]>
Fix non-unified build after r288432
Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (288438 => 288439)
--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2022-01-24 14:26:56 UTC (rev 288438)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp 2022-01-24 15:37:20 UTC (rev 288439)
@@ -49,6 +49,7 @@
#include <wtf/Lock.h>
#include <wtf/MainThread.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/Scope.h>
#include <pal/cf/AudioToolboxSoftLink.h>
#include <pal/cf/CoreMediaSoftLink.h>
@@ -146,6 +147,7 @@
uint64_t m_microphoneProcsCalledLastTime { 0 };
Timer m_verifyCapturingTimer;
+ bool m_isReconfiguring { false };
Lock m_speakerSamplesProducerLock;
CoreAudioSpeakerSamplesProducer* m_speakerSamplesProducer WTF_GUARDED_BY_LOCK(m_speakerSamplesProducerLock) { nullptr };
};
@@ -354,7 +356,7 @@
OSStatus CoreAudioSharedUnit::provideSpeakerData(AudioUnitRenderActionFlags& flags, const AudioTimeStamp& timeStamp, UInt32 /*inBusNumber*/, UInt32 inNumberFrames, AudioBufferList& ioData)
{
- if (!m_speakerSamplesProducerLock.tryLock()) {
+ if (m_isReconfiguring || !m_speakerSamplesProducerLock.tryLock()) {
AudioSampleBufferList::zeroABL(ioData, static_cast<size_t>(inNumberFrames * m_speakerProcFormat.bytesPerFrame()));
flags = kAudioUnitRenderAction_OutputIsSilence;
return noErr;
@@ -379,6 +381,11 @@
OSStatus CoreAudioSharedUnit::processMicrophoneSamples(AudioUnitRenderActionFlags& ioActionFlags, const AudioTimeStamp& timeStamp, UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList* /*ioData*/)
{
+ ++m_microphoneProcsCalled;
+
+ if (m_isReconfiguring)
+ return false;
+
// Pull through the vpio unit to our mic buffer.
m_microphoneSampleBuffer->reset();
AudioBufferList& bufferList = m_microphoneSampleBuffer->bufferList();
@@ -395,8 +402,6 @@
return err;
}
- ++m_microphoneProcsCalled;
-
if (!isProducingMicrophoneSamples())
return noErr;
@@ -451,19 +456,11 @@
if (!hasAudioUnit())
return 0;
+ m_isReconfiguring = true;
+ auto scope = makeScopeExit([this] { m_isReconfiguring = false; });
+
if (m_ioUnitStarted) {
- CoreAudioSpeakerSamplesProducer* speakerSamplesProducer;
- {
- Locker locker { m_speakerSamplesProducerLock };
- speakerSamplesProducer = m_speakerSamplesProducer;
- m_speakerSamplesProducer = nullptr;
- }
err = PAL::AudioOutputUnitStop(m_ioUnit);
- {
- Locker locker { m_speakerSamplesProducerLock };
- m_speakerSamplesProducer = speakerSamplesProducer;
- }
-
if (err) {
RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::reconfigureAudioUnit(%p) AudioOutputUnitStop failed with error %d (%.4s)", this, (int)err, (char*)&err);
return err;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes