Title: [234531] branches/safari-606-branch/Source/WebCore
Revision
234531
Author
[email protected]
Date
2018-08-02 18:16:44 -0700 (Thu, 02 Aug 2018)

Log Message

Cherry-pick r234463. rdar://problem/42882308

    [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):

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

Modified Paths

Diff

Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (234530 => 234531)


--- branches/safari-606-branch/Source/WebCore/ChangeLog	2018-08-03 01:11:46 UTC (rev 234530)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog	2018-08-03 01:16:44 UTC (rev 234531)
@@ -1,3 +1,56 @@
+2018-08-02  Babak Shafiei  <[email protected]>
+
+        Cherry-pick r234463. rdar://problem/42882308
+
+    [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):
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234463 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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  Babak Shafiei  <[email protected]>
 
         Cherry-pick r234466. rdar://problem/42843690

Modified: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (234530 => 234531)


--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2018-08-03 01:11:46 UTC (rev 234530)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2018-08-03 01:16:44 UTC (rev 234531)
@@ -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: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (234530 => 234531)


--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2018-08-03 01:11:46 UTC (rev 234530)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2018-08-03 01:16:44 UTC (rev 234531)
@@ -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: branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp (234530 => 234531)


--- branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp	2018-08-03 01:11:46 UTC (rev 234530)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp	2018-08-03 01:16:44 UTC (rev 234531)
@@ -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