Title: [234463] trunk/Source/WebCore
Revision
234463
Author
[email protected]
Date
2018-08-01 11:07:10 -0700 (Wed, 01 Aug 2018)

Log Message

[iOS] Remove the delay before setting audio session category added in r233535
https://bugs.webkit.org/show_bug.cgi?id=188225

Reviewed by Jer Noble.

* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::beginInterruption): scheduleUpdateSessionState -> updateSessionState.
(WebCore::PlatformMediaSessionManager::addSession): Ditto.
(WebCore::PlatformMediaSessionManager::removeSession): Ditto.
(WebCore::PlatformMediaSessionManager::sessionStateChanged): Ditto.
(WebCore::PlatformMediaSessionManager::sessionCanProduceAudioChanged): Ditto.
(WebCore::PlatformMediaSessionManager::updateSessionState): Ditto.
(WebCore::PlatformMediaSessionManager::audioOutputDeviceChanged): Ditto.
(WebCore::PlatformMediaSessionManager::scheduleUpdateSessionState): Deleted.
* platform/audio/PlatformMediaSessionManager.h:

* platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
(PlatformMediaSessionManager::updateSessionState):
(PlatformMediaSessionManager::scheduleUpdateSessionState): Deleted.
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::updateClipRects):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (234462 => 234463)


--- trunk/Source/WebCore/ChangeLog	2018-08-01 18:04:51 UTC (rev 234462)
+++ trunk/Source/WebCore/ChangeLog	2018-08-01 18:07:10 UTC (rev 234463)
@@ -1,3 +1,27 @@
+2018-08-01  Eric Carlson  <[email protected]>
+
+        [iOS] Remove the delay before setting audio session category added in r233535
+        https://bugs.webkit.org/show_bug.cgi?id=188225
+
+        Reviewed by Jer Noble.
+
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::beginInterruption): scheduleUpdateSessionState -> updateSessionState.
+        (WebCore::PlatformMediaSessionManager::addSession): Ditto.
+        (WebCore::PlatformMediaSessionManager::removeSession): Ditto.
+        (WebCore::PlatformMediaSessionManager::sessionStateChanged): Ditto.
+        (WebCore::PlatformMediaSessionManager::sessionCanProduceAudioChanged): Ditto.
+        (WebCore::PlatformMediaSessionManager::updateSessionState): Ditto.
+        (WebCore::PlatformMediaSessionManager::audioOutputDeviceChanged): Ditto.
+        (WebCore::PlatformMediaSessionManager::scheduleUpdateSessionState): Deleted.
+        * platform/audio/PlatformMediaSessionManager.h:
+
+        * platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
+        (PlatformMediaSessionManager::updateSessionState):
+        (PlatformMediaSessionManager::scheduleUpdateSessionState): Deleted.
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::updateClipRects):
+
 2018-08-01  Yusuke Suzuki  <[email protected]>
 
         Add TransformationMatrix::Identity

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (234462 => 234463)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2018-08-01 18:04:51 UTC (rev 234462)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2018-08-01 18:07:10 UTC (rev 234463)
@@ -116,7 +116,7 @@
     forEachSession([type] (PlatformMediaSession& session, size_t) {
         session.beginInterruption(type);
     });
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::endInterruption(PlatformMediaSession::EndInterruptionFlags flags)
@@ -143,7 +143,7 @@
     if (!m_audioHardwareListener)
         m_audioHardwareListener = AudioHardwareListener::create(*this);
 
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::removeSession(PlatformMediaSession& session)
@@ -164,7 +164,7 @@
         m_audioHardwareListener = nullptr;
     }
 
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::addRestriction(PlatformMediaSession::MediaType type, SessionRestrictions restriction)
@@ -250,7 +250,7 @@
 
 void PlatformMediaSessionManager::sessionStateChanged(PlatformMediaSession&)
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::setCurrentSession(PlatformMediaSession& session)
@@ -354,11 +354,11 @@
 
 void PlatformMediaSessionManager::sessionCanProduceAudioChanged(PlatformMediaSession&)
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 #if !PLATFORM(COCOA)
-void PlatformMediaSessionManager::scheduleUpdateSessionState()
+void PlatformMediaSessionManager::updateSessionState()
 {
 }
 #endif
@@ -401,7 +401,7 @@
 
 void PlatformMediaSessionManager::audioOutputDeviceChanged()
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::stopAllMediaPlaybackForDocument(const Document* document)

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (234462 => 234463)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2018-08-01 18:04:51 UTC (rev 234462)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2018-08-01 18:07:10 UTC (rev 234463)
@@ -126,7 +126,7 @@
 private:
     friend class Internals;
 
-    void scheduleUpdateSessionState();
+    void updateSessionState();
 
     // RemoteCommandListenerClient
     WEBCORE_EXPORT void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
@@ -152,8 +152,6 @@
     bool m_canPlayToTarget { false };
 #endif
 
-    std::unique_ptr<DeferrableOneShotTimer> m_updateStateTimer;
-
     bool m_interrupted { false };
     mutable bool m_isApplicationInBackground { false };
     bool m_willIgnoreSystemInterruptions { false };

Modified: trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp (234462 => 234463)


--- trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp	2018-08-01 18:04:51 UTC (rev 234462)
+++ trunk/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp	2018-08-01 18:07:10 UTC (rev 234463)
@@ -37,9 +37,8 @@
 
 static const size_t kWebAudioBufferSize = 128;
 static const size_t kLowPowerVideoBufferSize = 4096;
-static const Seconds updateSessionStateDelay { 100_ms };
 
-void PlatformMediaSessionManager::scheduleUpdateSessionState()
+void PlatformMediaSessionManager::updateSessionState()
 {
     LOG(Media, "PlatformMediaSessionManager::scheduleUpdateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(PlatformMediaSession::Video), count(PlatformMediaSession::Audio), count(PlatformMediaSession::WebAudio));
 
@@ -65,34 +64,25 @@
     if (!DeprecatedGlobalSettings::shouldManageAudioSessionCategory())
         return;
 
-    if (!m_updateStateTimer) {
-        auto updateSessionState = [this] () mutable {
+    bool hasWebAudioType = false;
+    bool hasAudibleAudioOrVideoMediaType = false;
+    bool hasAudioCapture = anyOfSessions([&hasWebAudioType, &hasAudibleAudioOrVideoMediaType] (PlatformMediaSession& session, size_t) mutable {
+        auto type = session.mediaType();
+        if (type == PlatformMediaSession::WebAudio)
+            hasWebAudioType = true;
+        if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.state() == PlatformMediaSession::Playing)
+            hasAudibleAudioOrVideoMediaType = true;
+        return (type == PlatformMediaSession::MediaStreamCapturingAudio);
+    });
 
-            bool hasWebAudioType = false;
-            bool hasAudibleAudioOrVideoMediaType = false;
-            bool hasAudioCapture = anyOfSessions([&hasWebAudioType, &hasAudibleAudioOrVideoMediaType] (PlatformMediaSession& session, size_t) mutable {
-                auto type = session.mediaType();
-                if (type == PlatformMediaSession::WebAudio)
-                    hasWebAudioType = true;
-                if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.state() == PlatformMediaSession::Playing)
-                    hasAudibleAudioOrVideoMediaType = true;
-                return (type == PlatformMediaSession::MediaStreamCapturingAudio);
-            });
-
-            if (hasAudioCapture)
-                AudioSession::sharedSession().setCategory(AudioSession::PlayAndRecord);
-            else if (hasAudibleAudioOrVideoMediaType)
-                AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback);
-            else if (hasWebAudioType)
-                AudioSession::sharedSession().setCategory(AudioSession::AmbientSound);
-            else
-                AudioSession::sharedSession().setCategory(AudioSession::None);
-        };
-
-        m_updateStateTimer = std::make_unique<DeferrableOneShotTimer>(WTFMove(updateSessionState), updateSessionStateDelay);
-    }
-
-    m_updateStateTimer->restart();
+    if (hasAudioCapture)
+        AudioSession::sharedSession().setCategory(AudioSession::PlayAndRecord);
+    else if (hasAudibleAudioOrVideoMediaType)
+        AudioSession::sharedSession().setCategory(AudioSession::MediaPlayback);
+    else if (hasWebAudioType)
+        AudioSession::sharedSession().setCategory(AudioSession::AmbientSound);
+    else
+        AudioSession::sharedSession().setCategory(AudioSession::None);
 }
 
 #endif // USE(AUDIO_SESSION)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to