Title: [288124] trunk/Source/WebCore
Revision
288124
Author
you...@apple.com
Date
2022-01-18 10:38:29 -0800 (Tue, 18 Jan 2022)

Log Message

Reduce failure timer in CoreAudioSharedUnit in the case we only render audio samples
https://bugs.webkit.org/show_bug.cgi?id=235318

Reviewed by Eric Carlson.

As shown in https://bugs.webkit.org/show_bug.cgi?id=235317, it might be possible for a VPIO that is only used for
audio rendering to fail sometimes. Waiting for 10 seconds in that case is very long, so we reduce the verification delay to 2 seconds.
Manually tested.

* platform/mediastream/mac/BaseAudioSharedUnit.cpp:
* platform/mediastream/mac/BaseAudioSharedUnit.h:
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (288123 => 288124)


--- trunk/Source/WebCore/ChangeLog	2022-01-18 18:29:11 UTC (rev 288123)
+++ trunk/Source/WebCore/ChangeLog	2022-01-18 18:38:29 UTC (rev 288124)
@@ -1,3 +1,18 @@
+2022-01-18  Youenn Fablet  <you...@apple.com>
+
+        Reduce failure timer in CoreAudioSharedUnit in the case we only render audio samples
+        https://bugs.webkit.org/show_bug.cgi?id=235318
+
+        Reviewed by Eric Carlson.
+
+        As shown in https://bugs.webkit.org/show_bug.cgi?id=235317, it might be possible for a VPIO that is only used for
+        audio rendering to fail sometimes. Waiting for 10 seconds in that case is very long, so we reduce the verification delay to 2 seconds.
+        Manually tested.
+
+        * platform/mediastream/mac/BaseAudioSharedUnit.cpp:
+        * platform/mediastream/mac/BaseAudioSharedUnit.h:
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+
 2022-01-18  Alex Christensen  <achristen...@webkit.org>
 
         Remove ImplementationLacksVTable IDL attribute

Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp (288123 => 288124)


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2022-01-18 18:29:11 UTC (rev 288123)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2022-01-18 18:38:29 UTC (rev 288124)
@@ -188,6 +188,12 @@
     cleanupAudioUnit();
 }
 
+void BaseAudioSharedUnit::setIsProducingMicrophoneSamples(bool value)
+{
+    m_isProducingMicrophoneSamples = value;
+    isProducingMicrophoneSamplesChanged();
+}
+
 void BaseAudioSharedUnit::setIsRenderingAudio(bool value)
 {
     m_isRenderingAudio = value;

Modified: trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h (288123 => 288124)


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2022-01-18 18:29:11 UTC (rev 288123)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2022-01-18 18:38:29 UTC (rev 288124)
@@ -102,8 +102,9 @@
     void setIsRenderingAudio(bool);
 
 protected:
-    void setIsProducingMicrophoneSamples(bool value) { m_isProducingMicrophoneSamples = value; }
+    void setIsProducingMicrophoneSamples(bool);
     bool isProducingMicrophoneSamples() const { return m_isProducingMicrophoneSamples; }
+    virtual void isProducingMicrophoneSamplesChanged() { }
 
 private:
     OSStatus startUnit();

Modified: trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp (288123 => 288124)


--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2022-01-18 18:29:11 UTC (rev 288123)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2022-01-18 18:38:29 UTC (rev 288124)
@@ -98,6 +98,7 @@
     OSStatus startInternal() final;
     void stopInternal() final;
     bool isProducingData() const final { return m_ioUnitStarted; }
+    void isProducingMicrophoneSamplesChanged() final;
 
     OSStatus configureSpeakerProc();
     OSStatus configureMicrophoneProc();
@@ -114,6 +115,8 @@
 
     void verifyIsCapturing();
 
+    Seconds verifyCaptureInterval() { return isProducingMicrophoneSamples() ? 10_s : 2_s; }
+
     AudioUnit m_ioUnit { nullptr };
 
     // Only read/modified from the IO thread.
@@ -142,7 +145,6 @@
     uint64_t m_microphoneProcsCalled { 0 };
     uint64_t m_microphoneProcsCalledLastTime { 0 };
     Timer m_verifyCapturingTimer;
-    static constexpr Seconds verifyCaptureInterval = 10_s;
 
     Lock m_speakerSamplesProducerLock;
     CoreAudioSpeakerSamplesProducer* m_speakerSamplesProducer WTF_GUARDED_BY_LOCK(m_speakerSamplesProducerLock) { nullptr };
@@ -507,7 +509,7 @@
 
     m_ioUnitStarted = true;
 
-    m_verifyCapturingTimer.startRepeating(verifyCaptureInterval);
+    m_verifyCapturingTimer.startRepeating(verifyCaptureInterval());
     m_microphoneProcsCalled = 0;
     m_microphoneProcsCalledLastTime = 0;
 
@@ -514,6 +516,13 @@
     return 0;
 }
 
+void CoreAudioSharedUnit::isProducingMicrophoneSamplesChanged()
+{
+    if (!isProducingData())
+        return;
+    m_verifyCapturingTimer.startRepeating(verifyCaptureInterval());
+}
+
 void CoreAudioSharedUnit::verifyIsCapturing()
 {
     if (m_microphoneProcsCalledLastTime != m_microphoneProcsCalled) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to