REGRESSION: Cannot listen to audio on Google Translate with side switch set to ...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 23:30:57 +0000 (23:30 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jun 2018 23:30:57 +0000 (23:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=186415
<rdar://problem/40584651>

Reviewed by Eric Carlson.

Source/WebCore:

Test: platform/mac/media/audio-session-category-audio-autoplay.html

Make sure that the PlatformMediaSession's state has already been set when calling updateSessionStates().

* platform/audio/PlatformMediaSession.cpp:
(WebCore::PlatformMediaSession::setState):
* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback):
(WebCore::PlatformMediaSessionManager::sessionStateChanged):

LayoutTests:

* platform/mac/media/audio-session-category-audio-autoplay-expected.txt: Added.
* platform/mac/media/audio-session-category-audio-autoplay.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/media/audio-session-category-audio-autoplay-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/media/audio-session-category-audio-autoplay.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/PlatformMediaSession.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h

index fc310f0..e4839f2 100644 (file)
@@ -1,3 +1,14 @@
+2018-06-07  Jer Noble  <jer.noble@apple.com>
+
+        REGRESSION:  Cannot listen to audio on Google Translate with side switch set to "vibrate"
+        https://bugs.webkit.org/show_bug.cgi?id=186415
+        <rdar://problem/40584651>
+
+        Reviewed by Eric Carlson.
+
+        * platform/mac/media/audio-session-category-audio-autoplay-expected.txt: Added.
+        * platform/mac/media/audio-session-category-audio-autoplay.html: Added.
+
 2018-06-08  Brendan McLoughlin  <brendan@bocoup.com>
 
         Sync web-platform-tests repo to 197cdad
diff --git a/LayoutTests/platform/mac/media/audio-session-category-audio-autoplay-expected.txt b/LayoutTests/platform/mac/media/audio-session-category-audio-autoplay-expected.txt
new file mode 100644 (file)
index 0000000..a11c27c
--- /dev/null
@@ -0,0 +1,8 @@
+
+RUN(internals.settings.setShouldManageAudioSessionCategory(true))
+RUN(audio.autoplay = true)
+RUN(audio.src = findMediaFile("audio", "../../../media/content/test"))
+EVENT(playing)
+EXPECTED (internals.audioSessionCategory() == 'MediaPlayback') OK
+END OF TEST
+
diff --git a/LayoutTests/platform/mac/media/audio-session-category-audio-autoplay.html b/LayoutTests/platform/mac/media/audio-session-category-audio-autoplay.html
new file mode 100644 (file)
index 0000000..5d8f4bf
--- /dev/null
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <title>audio-session-category-track-change</title>
+    <script src="../../../media/video-test.js"></script>
+    <script src="../../../media/media-file.js"></script>
+    <script>
+    function go() {
+        audio = video = mediaElement = document.querySelector('audio');
+        run('internals.settings.setShouldManageAudioSessionCategory(true)');
+        run('audio.autoplay = true');
+        run('audio.src = findMediaFile("audio", "../../../media/content/test")');
+        waitForEvent('playing', playing);
+    }
+
+    function playing() {
+        testExpected('internals.audioSessionCategory()', 'MediaPlayback');
+        endTest();
+    }
+    </script>
+</head>
+<body onload="go()">
+    <audio controls></video>
+</body>
+</html>
index 3213937..23b06e5 100644 (file)
@@ -1,3 +1,21 @@
+2018-06-07  Jer Noble  <jer.noble@apple.com>
+
+        REGRESSION:  Cannot listen to audio on Google Translate with side switch set to "vibrate"
+        https://bugs.webkit.org/show_bug.cgi?id=186415
+        <rdar://problem/40584651>
+
+        Reviewed by Eric Carlson.
+
+        Test: platform/mac/media/audio-session-category-audio-autoplay.html
+
+        Make sure that the PlatformMediaSession's state has already been set when calling updateSessionStates().
+
+        * platform/audio/PlatformMediaSession.cpp:
+        (WebCore::PlatformMediaSession::setState):
+        * platform/audio/PlatformMediaSessionManager.cpp:
+        (WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback):
+        (WebCore::PlatformMediaSessionManager::sessionStateChanged):
+
 2018-06-08  Dean Jackson  <dino@apple.com>
 
         'setRenderPipelineState:' is unavailable: not available on iOS
index d56e7bd..7339944 100644 (file)
@@ -112,8 +112,12 @@ PlatformMediaSession::~PlatformMediaSession()
 
 void PlatformMediaSession::setState(State state)
 {
+    if (state == m_state)
+        return;
+
     INFO_LOG(LOGIDENTIFIER, state);
     m_state = state;
+    PlatformMediaSessionManager::sharedManager().sessionStateChanged(*this);
 }
 
 void PlatformMediaSession::beginInterruption(InterruptionType type)
index 3277b1a..f06aa91 100644 (file)
@@ -213,7 +213,6 @@ bool PlatformMediaSessionManager::sessionWillBeginPlayback(PlatformMediaSession&
             oneSession.pauseSession();
     });
 
-    updateSessionState();
     return true;
 }
     
@@ -249,6 +248,11 @@ void PlatformMediaSessionManager::sessionWillEndPlayback(PlatformMediaSession& s
     LOG(Media, "PlatformMediaSessionManager::sessionWillEndPlayback - session moved from index %zu to %zu", pausingSessionIndex, lastPlayingSessionIndex);
 }
 
+void PlatformMediaSessionManager::sessionStateChanged(PlatformMediaSession&)
+{
+    updateSessionState();
+}
+
 void PlatformMediaSessionManager::setCurrentSession(PlatformMediaSession& session)
 {
     LOG(Media, "PlatformMediaSessionManager::setCurrentSession - %p", &session);
index 9897e6a..b8b7cea 100644 (file)
@@ -94,6 +94,7 @@ public:
 
     virtual bool sessionWillBeginPlayback(PlatformMediaSession&);
     virtual void sessionWillEndPlayback(PlatformMediaSession&);
+    virtual void sessionStateChanged(PlatformMediaSession&);
     virtual void sessionDidEndRemoteScrubbing(const PlatformMediaSession&) { };
     virtual void clientCharacteristicsChanged(PlatformMediaSession&) { }