Title: [290039] branches/safari-613.1.17.0-branch/Source/WebCore
Revision
290039
Author
alanc...@apple.com
Date
2022-02-17 11:51:09 -0800 (Thu, 17 Feb 2022)

Log Message

Cherry-pick r289942. rdar://problem/88827167

    [Cocoa] Update audio session category before setting NowPlaying status
    https://bugs.webkit.org/show_bug.cgi?id=236620
    rdar://88827167

    Reviewed by Jer Noble.

    NowPlaying doesn't update correctly when the audio category changes from Ambient
    to Playback after becoming active, so always set the category first.

    Tested manually.

    * platform/audio/PlatformMediaSession.cpp:
    (WebCore::PlatformMediaSession::clientWillBeginPlayback): Set "preparingToPlay"
    before calling `sessionWillBeginPlayback` so `updateSessionState` can tell that
    playback is about to begin.
    * platform/audio/PlatformMediaSession.h:

    * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
    (WebCore::MediaSessionManagerCocoa::updateSessionState): Consider a session to
    potentially have audio if it is preparing to play.

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

Modified Paths

Diff

Modified: branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog (290038 => 290039)


--- branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog	2022-02-17 19:38:57 UTC (rev 290038)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/ChangeLog	2022-02-17 19:51:09 UTC (rev 290039)
@@ -1,3 +1,54 @@
+2022-02-17  Russell Epstein  <repst...@apple.com>
+
+        Cherry-pick r289942. rdar://problem/88827167
+
+    [Cocoa] Update audio session category before setting NowPlaying status
+    https://bugs.webkit.org/show_bug.cgi?id=236620
+    rdar://88827167
+    
+    Reviewed by Jer Noble.
+    
+    NowPlaying doesn't update correctly when the audio category changes from Ambient
+    to Playback after becoming active, so always set the category first.
+    
+    Tested manually.
+    
+    * platform/audio/PlatformMediaSession.cpp:
+    (WebCore::PlatformMediaSession::clientWillBeginPlayback): Set "preparingToPlay"
+    before calling `sessionWillBeginPlayback` so `updateSessionState` can tell that
+    playback is about to begin.
+    * platform/audio/PlatformMediaSession.h:
+    
+    * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+    (WebCore::MediaSessionManagerCocoa::updateSessionState): Consider a session to
+    potentially have audio if it is preparing to play.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@289942 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-02-16  Eric Carlson  <eric.carl...@apple.com>
+
+            [Cocoa] Update audio session category before setting NowPlaying status
+            https://bugs.webkit.org/show_bug.cgi?id=236620
+            rdar://88827167
+
+            Reviewed by Jer Noble.
+
+            NowPlaying doesn't update correctly when the audio category changes from Ambient
+            to Playback after becoming active, so always set the category first.
+
+            Tested manually.
+
+            * platform/audio/PlatformMediaSession.cpp:
+            (WebCore::PlatformMediaSession::clientWillBeginPlayback): Set "preparingToPlay"
+            before calling `sessionWillBeginPlayback` so `updateSessionState` can tell that
+            playback is about to begin.
+            * platform/audio/PlatformMediaSession.h:
+
+            * platform/audio/cocoa/MediaSessionManagerCocoa.mm:
+            (WebCore::MediaSessionManagerCocoa::updateSessionState): Consider a session to
+            potentially have audio if it is preparing to play.
+
 2022-02-16  Russell Epstein  <repst...@apple.com>
 
         Revert r289924. rdar://problem/82142820

Modified: branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (290038 => 290039)


--- branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2022-02-17 19:38:57 UTC (rev 290038)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2022-02-17 19:51:09 UTC (rev 290039)
@@ -32,6 +32,7 @@
 #include "MediaPlayer.h"
 #include "NowPlayingInfo.h"
 #include "PlatformMediaSessionManager.h"
+#include <wtf/SetForScope.h>
 
 namespace WebCore {
 
@@ -235,6 +236,8 @@
 
     ALWAYS_LOG(LOGIDENTIFIER, "state = ", m_state);
 
+    SetForScope<bool> preparingToPlay(m_preparingToPlay, true);
+
     if (!PlatformMediaSessionManager::sharedManager().sessionWillBeginPlayback(*this)) {
         if (state() == Interrupted)
             m_stateToRestore = Playing;

Modified: branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (290038 => 290039)


--- branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.h	2022-02-17 19:38:57 UTC (rev 290038)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/PlatformMediaSession.h	2022-02-17 19:51:09 UTC (rev 290039)
@@ -187,6 +187,8 @@
     bool hasPlayedSinceLastInterruption() const { return m_hasPlayedSinceLastInterruption; }
     void clearHasPlayedSinceLastInterruption() { m_hasPlayedSinceLastInterruption = false; }
 
+    bool preparingToPlay() const { return m_preparingToPlay; }
+
 #if !RELEASE_LOG_DISABLED
     const Logger& logger() const final { return m_logger.get(); }
     const void* logIdentifier() const override { return m_logIdentifier; }
@@ -225,6 +227,7 @@
     bool m_notifyingClient { false };
     bool m_isPlayingToWirelessPlaybackTarget { false };
     bool m_hasPlayedSinceLastInterruption { false };
+    bool m_preparingToPlay { false };
 
 #if !RELEASE_LOG_DISABLED
     Ref<const Logger> m_logger;

Modified: branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm (290038 => 290039)


--- branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2022-02-17 19:38:57 UTC (rev 290038)
+++ branches/safari-613.1.17.0-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.mm	2022-02-17 19:51:09 UTC (rev 290039)
@@ -125,7 +125,10 @@
         }
 
         if (!hasAudibleAudioOrVideoMediaType) {
-            bool isPotentiallyAudible = session.isPlayingToWirelessPlaybackTarget() || ((type == PlatformMediaSession::MediaType::VideoAudio || type == PlatformMediaSession::MediaType::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption());
+            bool isPotentiallyAudible = session.isPlayingToWirelessPlaybackTarget()
+                || ((type == PlatformMediaSession::MediaType::VideoAudio || type == PlatformMediaSession::MediaType::Audio)
+                    && session.canProduceAudio()
+                    && (session.hasPlayedSinceLastInterruption() || session.preparingToPlay()));
             if (isPotentiallyAudible) {
                 hasAudibleAudioOrVideoMediaType = true;
                 isPlayingAudio |= session.isPlaying();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to