Title: [253628] trunk/Source/WebCore
Revision
253628
Author
[email protected]
Date
2019-12-17 07:27:32 -0800 (Tue, 17 Dec 2019)

Log Message

Update session category in MockAudioSharedUnit as done in CoreAudioSharedUnit
https://bugs.webkit.org/show_bug.cgi?id=205328

Reviewed by Eric Carlson.

We were updating the audio session when starting capturing with the CoreAudioSharedUnit
but not with the MockAudioSharedUnit.
Refactor the code to update the audio session in the base class BaseAudioSharedUnit.
Share more code between start and resume case in BaseAudioSharedUnit.

Covered by platform/ios/mediastream/audio-muted-in-background-tab.html in Debug.

* platform/mediastream/mac/BaseAudioSharedUnit.cpp:
(WebCore::BaseAudioSharedUnit::startProducingData):
(WebCore::BaseAudioSharedUnit::startUnit):
(WebCore::BaseAudioSharedUnit::resume):
* platform/mediastream/mac/BaseAudioSharedUnit.h:
* platform/mediastream/mac/CoreAudioCaptureSource.cpp:
(WebCore::CoreAudioSharedUnit::startInternal):
* platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockAudioSharedUnit::startInternal):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (253627 => 253628)


--- trunk/Source/WebCore/ChangeLog	2019-12-17 14:34:22 UTC (rev 253627)
+++ trunk/Source/WebCore/ChangeLog	2019-12-17 15:27:32 UTC (rev 253628)
@@ -1,3 +1,27 @@
+2019-12-17  youenn fablet  <[email protected]>
+
+        Update session category in MockAudioSharedUnit as done in CoreAudioSharedUnit
+        https://bugs.webkit.org/show_bug.cgi?id=205328
+
+        Reviewed by Eric Carlson.
+
+        We were updating the audio session when starting capturing with the CoreAudioSharedUnit
+        but not with the MockAudioSharedUnit.
+        Refactor the code to update the audio session in the base class BaseAudioSharedUnit.
+        Share more code between start and resume case in BaseAudioSharedUnit.
+
+        Covered by platform/ios/mediastream/audio-muted-in-background-tab.html in Debug.
+
+        * platform/mediastream/mac/BaseAudioSharedUnit.cpp:
+        (WebCore::BaseAudioSharedUnit::startProducingData):
+        (WebCore::BaseAudioSharedUnit::startUnit):
+        (WebCore::BaseAudioSharedUnit::resume):
+        * platform/mediastream/mac/BaseAudioSharedUnit.h:
+        * platform/mediastream/mac/CoreAudioCaptureSource.cpp:
+        (WebCore::CoreAudioSharedUnit::startInternal):
+        * platform/mediastream/mac/MockAudioSharedUnit.mm:
+        (WebCore::MockAudioSharedUnit::startInternal):
+
 2019-12-17  Thibault Saunier  <[email protected]>
 
         [GStreamer][WPE] Fix regressions related to our 'Fix GStreamer capturer mock' patch

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


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2019-12-17 14:34:22 UTC (rev 253627)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.cpp	2019-12-17 15:27:32 UTC (rev 253628)
@@ -30,6 +30,7 @@
 
 #include "CoreAudioCaptureSource.h"
 #include "Logging.h"
+#include "PlatformMediaSessionManager.h"
 
 namespace WebCore {
 
@@ -86,9 +87,21 @@
         cleanupAudioUnit();
         ASSERT(!hasAudioUnit());
     }
+    startUnit();
+}
 
-    if (startInternal())
+OSStatus BaseAudioSharedUnit::startUnit()
+{
+#if PLATFORM(IOS_FAMILY)
+    PlatformMediaSessionManager::sharedManager().sessionCanProduceAudioChanged();
+    ASSERT(AudioSession::sharedSession().category() == AudioSession::PlayAndRecord);
+#endif
+
+    if (auto error = startInternal()) {
         captureFailed();
+        return error;
+    }
+    return 0;
 }
 
 void BaseAudioSharedUnit::prepareForNewCapture()
@@ -159,8 +172,10 @@
     if (!hasAudioUnit())
         return 0;
 
-    if (m_producingCount)
-        startInternal();
+    if (m_producingCount) {
+        if (auto error = startUnit())
+            return error;
+    }
 
     forEachClient([](auto& client) {
         client.notifyMutedChange(false);

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


--- trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2019-12-17 14:34:22 UTC (rev 253627)
+++ trunk/Source/WebCore/platform/mediastream/mac/BaseAudioSharedUnit.h	2019-12-17 15:27:32 UTC (rev 253628)
@@ -91,6 +91,8 @@
     void audioSamplesAvailable(const MediaTime&, const PlatformAudioData&, const AudioStreamDescription&, size_t /*numberOfFrames*/);
 
 private:
+    OSStatus startUnit();
+
     bool m_enableEchoCancellation { true };
     double m_volume { 1 };
     int m_sampleRate;

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


--- trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2019-12-17 14:34:22 UTC (rev 253627)
+++ trunk/Source/WebCore/platform/mediastream/mac/CoreAudioCaptureSource.cpp	2019-12-17 15:27:32 UTC (rev 253628)
@@ -508,11 +508,6 @@
 
     unduck();
 
-#if PLATFORM(IOS_FAMILY)
-    PlatformMediaSessionManager::sharedManager().sessionCanProduceAudioChanged();
-    ASSERT(AudioSession::sharedSession().category() == AudioSession::PlayAndRecord);
-#endif
-
     err = AudioOutputUnitStart(m_ioUnit);
     if (err) {
         RELEASE_LOG_ERROR(WebRTC, "CoreAudioSharedUnit::start(%p) AudioOutputUnitStart failed with error %d (%.4s)", this, (int)err, (char*)&err);

Modified: trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm (253627 => 253628)


--- trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2019-12-17 14:34:22 UTC (rev 253627)
+++ trunk/Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm	2019-12-17 15:27:32 UTC (rev 253628)
@@ -148,9 +148,6 @@
 
 OSStatus MockAudioSharedUnit::startInternal()
 {
-#if PLATFORM(IOS_FAMILY)
-    ASSERT(AudioSession::sharedSession().category() == AudioSession::PlayAndRecord);
-#endif
     if (!m_hasAudioUnit)
         m_hasAudioUnit = true;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to