[iOS] Remove the delay before setting audio session category added in r233535
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2018 18:07:10 +0000 (18:07 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 1 Aug 2018 18:07:10 +0000 (18:07 +0000)
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):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234463 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp

index fba7b7b..e031c72 100644 (file)
@@ -1,3 +1,27 @@
+2018-08-01  Eric Carlson  <eric.carlson@apple.com>
+
+        [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  <utatane.tea@gmail.com>
 
         Add TransformationMatrix::Identity
index f8c531a..9531731 100644 (file)
@@ -116,7 +116,7 @@ void PlatformMediaSessionManager::beginInterruption(PlatformMediaSession::Interr
     forEachSession([type] (PlatformMediaSession& session, size_t) {
         session.beginInterruption(type);
     });
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::endInterruption(PlatformMediaSession::EndInterruptionFlags flags)
@@ -143,7 +143,7 @@ void PlatformMediaSessionManager::addSession(PlatformMediaSession& session)
     if (!m_audioHardwareListener)
         m_audioHardwareListener = AudioHardwareListener::create(*this);
 
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::removeSession(PlatformMediaSession& session)
@@ -164,7 +164,7 @@ void PlatformMediaSessionManager::removeSession(PlatformMediaSession& session)
         m_audioHardwareListener = nullptr;
     }
 
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::addRestriction(PlatformMediaSession::MediaType type, SessionRestrictions restriction)
@@ -250,7 +250,7 @@ void PlatformMediaSessionManager::sessionWillEndPlayback(PlatformMediaSession& s
 
 void PlatformMediaSessionManager::sessionStateChanged(PlatformMediaSession&)
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::setCurrentSession(PlatformMediaSession& session)
@@ -354,11 +354,11 @@ void PlatformMediaSessionManager::sessionIsPlayingToWirelessPlaybackTargetChange
 
 void PlatformMediaSessionManager::sessionCanProduceAudioChanged(PlatformMediaSession&)
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 #if !PLATFORM(COCOA)
-void PlatformMediaSessionManager::scheduleUpdateSessionState()
+void PlatformMediaSessionManager::updateSessionState()
 {
 }
 #endif
@@ -401,7 +401,7 @@ void PlatformMediaSessionManager::systemDidWake()
 
 void PlatformMediaSessionManager::audioOutputDeviceChanged()
 {
-    scheduleUpdateSessionState();
+    updateSessionState();
 }
 
 void PlatformMediaSessionManager::stopAllMediaPlaybackForDocument(const Document* document)
index 0e3dffd..ad36383 100644 (file)
@@ -126,7 +126,7 @@ protected:
 private:
     friend class Internals;
 
-    void scheduleUpdateSessionState();
+    void updateSessionState();
 
     // RemoteCommandListenerClient
     WEBCORE_EXPORT void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
@@ -152,8 +152,6 @@ private:
     bool m_canPlayToTarget { false };
 #endif
 
-    std::unique_ptr<DeferrableOneShotTimer> m_updateStateTimer;
-
     bool m_interrupted { false };
     mutable bool m_isApplicationInBackground { false };
     bool m_willIgnoreSystemInterruptions { false };
index fbf2f29..c958c32 100644 (file)
@@ -37,9 +37,8 @@ using namespace WebCore;
 
 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 @@ void PlatformMediaSessionManager::scheduleUpdateSessionState()
     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);
-            });
-
-            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();
+    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);
 }
 
 #endif // USE(AUDIO_SESSION)