Diff
Modified: branches/safari-606-branch/LayoutTests/ChangeLog (234571 => 234572)
--- branches/safari-606-branch/LayoutTests/ChangeLog 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/LayoutTests/ChangeLog 2018-08-04 02:01:04 UTC (rev 234572)
@@ -1,5 +1,78 @@
2018-08-03 Babak Shafiei <[email protected]>
+ Cherry-pick r234534. rdar://problem/42902608
+
+ Control center controls disappear when pausing, locking device.
+ https://bugs.webkit.org/show_bug.cgi?id=188282
+ <rdar://problem/42497809>
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Test: platform/mac/media/audio-session-category-video-paused.html
+
+ MediaRemote will set any app whose audio session category changes from MediaPlayback to
+ Ambient as not eligable for being the "now playing" app. Previously, due to the ordering of
+ events, we never moved from MediaPlayback to Ambient when pausing <video>, even though that
+ was the intention. Now that that bug is fixed, it exposed this new issue with MediaRemote.
+
+ To solve the new issue, make our audio session category policy more explicit: once we are in
+ MediaPlayback category, we will remain so as long as the media element in queston stays
+ loaded, has played, and is never interrupted by the system.
+
+ Make MediaSessionManagerCocoa a proper subclass of PlatformMediaSessionManager, and make
+ MediaSessionManageriOS and -Mac subclasses of the -Cocoa class. Add a new
+ m_hasPlayedSinceLastInterruption ivar to PlatformMediaSession, set when the state() changes
+ to Playing, and cleared during an interruption. Check this flag when deciding what audio
+ sessino category to set in MediaSessionManagerCocoa.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::setState):
+ * platform/audio/PlatformMediaSession.h:
+ (WebCore::PlatformMediaSession::hasPlayedSinceLastInterruption const):
+ (WebCore::PlatformMediaSession::clearHasPlayedSinceLastInterruption):
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::audioHardwareListener):
+ (WebCore::PlatformMediaSessionManager::updateSessionState):
+ * platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
+ (MediaSessionManagerCocoa::updateSessionState):
+ (MediaSessionManagerCocoa::beginInterruption):
+ (PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h: Added.
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::MediaSessionManageriOS):
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::MediaSessionManagerMac):
+
+ LayoutTests:
+
+ * platform/mac/media/audio-session-category-video-paused-expected.txt: Added.
+ * platform/mac/media/audio-session-category-video-paused.html: Added.
+ * platform/ios/TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-08-02 Jer Noble <[email protected]>
+
+ Control center controls disappear when pausing, locking device.
+ https://bugs.webkit.org/show_bug.cgi?id=188282
+ <rdar://problem/42497809>
+
+ Reviewed by Eric Carlson.
+
+ * platform/mac/media/audio-session-category-video-paused-expected.txt: Added.
+ * platform/mac/media/audio-session-category-video-paused.html: Added.
+ * platform/ios/TestExpectations:
+
+2018-08-03 Babak Shafiei <[email protected]>
+
Revert r234534. rdar://problem/42902608
2018-08-03 Kocsen Chung <[email protected]>
Modified: branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations (234571 => 234572)
--- branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/LayoutTests/platform/ios/TestExpectations 2018-08-04 02:01:04 UTC (rev 234572)
@@ -3340,3 +3340,6 @@
# We are only accepting GLSL3 for macOS.
webkit.org/b/187982 webgl/2.0.0/conformance2/glsl3 [ Skip ]
+
+# Audio session does not have a "none" category on iOS [ Skip ]
+webkit.org/b/188285 platform/mac/media/audio-session-category-video-paused.html [ Skip ]
Added: branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused-expected.txt (0 => 234572)
--- branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused-expected.txt (rev 0)
+++ branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused-expected.txt 2018-08-04 02:01:04 UTC (rev 234572)
@@ -0,0 +1,19 @@
+
+RUN(internals.settings.setShouldManageAudioSessionCategory(true))
+RUN(video.src = "" "../../../media/content/test"))
+RUN(video.play())
+EVENT(playing)
+EXPECTED (internals.audioSessionCategory() == 'MediaPlayback') OK
+RUN(video.pause())
+EVENT(pause)
+EXPECTED (internals.audioSessionCategory() == 'MediaPlayback') OK
+RUN(internals.beginMediaSessionInterruption("system"))
+EXPECTED (internals.audioSessionCategory() == 'None') OK
+RUN(video.play())
+EVENT(playing)
+EXPECTED (internals.audioSessionCategory() == 'MediaPlayback') OK
+RUN(video.src = ""
+RUN(video.load())
+EXPECTED (internals.audioSessionCategory() == 'None') OK
+END OF TEST
+
Added: branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused.html (0 => 234572)
--- branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused.html (rev 0)
+++ branches/safari-606-branch/LayoutTests/platform/mac/media/audio-session-category-video-paused.html 2018-08-04 02:01:04 UTC (rev 234572)
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title>audio-session-category-track-change</title>
+ <script src=""
+ <script src=""
+ <script>
+ window.addEventListener('load', async event => {
+ findMediaElement();
+ run('internals.settings.setShouldManageAudioSessionCategory(true)');
+ run('video.src = "" "../../../media/content/test")');
+ run('video.play()');
+ await waitFor(video, 'playing');
+ await testExpectedEventually('internals.audioSessionCategory()', 'MediaPlayback');
+
+ run('video.pause()');
+ await waitFor(video, 'pause');
+ await testExpectedEventually('internals.audioSessionCategory()', 'MediaPlayback');
+
+ run('internals.beginMediaSessionInterruption("system")');
+ await testExpectedEventually('internals.audioSessionCategory()', 'None');
+
+ run('video.play()');
+ await waitFor(video, 'playing');
+ await testExpectedEventually('internals.audioSessionCategory()', 'MediaPlayback');
+
+ run('video.src = ""
+ run('video.load()');
+ await testExpectedEventually('internals.audioSessionCategory()', 'None');
+
+ endTest();
+ });
+ </script>
+</head>
+<body>
+ <video controls></video>
+</body>
+</html>
Modified: branches/safari-606-branch/Source/WebCore/ChangeLog (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/ChangeLog 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/ChangeLog 2018-08-04 02:01:04 UTC (rev 234572)
@@ -1,5 +1,114 @@
2018-08-03 Babak Shafiei <[email protected]>
+ Cherry-pick r234534. rdar://problem/42902608
+
+ Control center controls disappear when pausing, locking device.
+ https://bugs.webkit.org/show_bug.cgi?id=188282
+ <rdar://problem/42497809>
+
+ Reviewed by Eric Carlson.
+
+ Source/WebCore:
+
+ Test: platform/mac/media/audio-session-category-video-paused.html
+
+ MediaRemote will set any app whose audio session category changes from MediaPlayback to
+ Ambient as not eligable for being the "now playing" app. Previously, due to the ordering of
+ events, we never moved from MediaPlayback to Ambient when pausing <video>, even though that
+ was the intention. Now that that bug is fixed, it exposed this new issue with MediaRemote.
+
+ To solve the new issue, make our audio session category policy more explicit: once we are in
+ MediaPlayback category, we will remain so as long as the media element in queston stays
+ loaded, has played, and is never interrupted by the system.
+
+ Make MediaSessionManagerCocoa a proper subclass of PlatformMediaSessionManager, and make
+ MediaSessionManageriOS and -Mac subclasses of the -Cocoa class. Add a new
+ m_hasPlayedSinceLastInterruption ivar to PlatformMediaSession, set when the state() changes
+ to Playing, and cleared during an interruption. Check this flag when deciding what audio
+ sessino category to set in MediaSessionManagerCocoa.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::setState):
+ * platform/audio/PlatformMediaSession.h:
+ (WebCore::PlatformMediaSession::hasPlayedSinceLastInterruption const):
+ (WebCore::PlatformMediaSession::clearHasPlayedSinceLastInterruption):
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::audioHardwareListener):
+ (WebCore::PlatformMediaSessionManager::updateSessionState):
+ * platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
+ (MediaSessionManagerCocoa::updateSessionState):
+ (MediaSessionManagerCocoa::beginInterruption):
+ (PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h: Added.
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::MediaSessionManageriOS):
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::MediaSessionManagerMac):
+
+ LayoutTests:
+
+ * platform/mac/media/audio-session-category-video-paused-expected.txt: Added.
+ * platform/mac/media/audio-session-category-video-paused.html: Added.
+ * platform/ios/TestExpectations:
+
+
+ git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234534 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+ 2018-08-02 Jer Noble <[email protected]>
+
+ Control center controls disappear when pausing, locking device.
+ https://bugs.webkit.org/show_bug.cgi?id=188282
+ <rdar://problem/42497809>
+
+ Reviewed by Eric Carlson.
+
+ Test: platform/mac/media/audio-session-category-video-paused.html
+
+ MediaRemote will set any app whose audio session category changes from MediaPlayback to
+ Ambient as not eligable for being the "now playing" app. Previously, due to the ordering of
+ events, we never moved from MediaPlayback to Ambient when pausing <video>, even though that
+ was the intention. Now that that bug is fixed, it exposed this new issue with MediaRemote.
+
+ To solve the new issue, make our audio session category policy more explicit: once we are in
+ MediaPlayback category, we will remain so as long as the media element in queston stays
+ loaded, has played, and is never interrupted by the system.
+
+ Make MediaSessionManagerCocoa a proper subclass of PlatformMediaSessionManager, and make
+ MediaSessionManageriOS and -Mac subclasses of the -Cocoa class. Add a new
+ m_hasPlayedSinceLastInterruption ivar to PlatformMediaSession, set when the state() changes
+ to Playing, and cleared during an interruption. Check this flag when deciding what audio
+ sessino category to set in MediaSessionManagerCocoa.
+
+ * WebCore.xcodeproj/project.pbxproj:
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::setState):
+ * platform/audio/PlatformMediaSession.h:
+ (WebCore::PlatformMediaSession::hasPlayedSinceLastInterruption const):
+ (WebCore::PlatformMediaSession::clearHasPlayedSinceLastInterruption):
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/PlatformMediaSessionManager.h:
+ (WebCore::PlatformMediaSessionManager::audioHardwareListener):
+ (WebCore::PlatformMediaSessionManager::updateSessionState):
+ * platform/audio/cocoa/MediaSessionManagerCocoa.cpp:
+ (MediaSessionManagerCocoa::updateSessionState):
+ (MediaSessionManagerCocoa::beginInterruption):
+ (PlatformMediaSessionManager::updateSessionState): Deleted.
+ * platform/audio/cocoa/MediaSessionManagerCocoa.h: Added.
+ * platform/audio/ios/MediaSessionManagerIOS.h:
+ * platform/audio/ios/MediaSessionManagerIOS.mm:
+ (WebCore::MediaSessionManageriOS::MediaSessionManageriOS):
+ * platform/audio/mac/MediaSessionManagerMac.h:
+ * platform/audio/mac/MediaSessionManagerMac.mm:
+ (WebCore::MediaSessionManagerMac::MediaSessionManagerMac):
+
+2018-08-03 Babak Shafiei <[email protected]>
+
Revert r234534. rdar://problem/42902608
2018-08-03 Kocsen Chung <[email protected]>
Modified: branches/safari-606-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-04 02:01:04 UTC (rev 234572)
@@ -3949,6 +3949,7 @@
CD1E7347167BC78E009A885D /* TextTrackRepresentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */; };
CD225C0B1C46FBF400140761 /* WebCoreNSURLSession.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */; };
CD225C0C1C46FBF400140761 /* WebCoreNSURLSession.h in Headers */ = {isa = PBXBuildFile; fileRef = CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ CD227E3A2113C86200D285AF /* MediaSessionManagerCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = CD227E362113AEFA00D285AF /* MediaSessionManagerCocoa.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD2F4A2418D89F700063746D /* AudioHardwareListener.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2218D89F700063746D /* AudioHardwareListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
CD2F4A2818D8A3490063746D /* AudioHardwareListenerMac.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2F4A2618D8A3490063746D /* AudioHardwareListenerMac.h */; };
CD318622199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD318620199F1E2A0030A0F7 /* CDMPrivateMediaSourceAVFObjC.mm */; };
@@ -13174,6 +13175,7 @@
CD1E7346167BC78E009A885D /* TextTrackRepresentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextTrackRepresentation.cpp; sourceTree = "<group>"; };
CD225C091C46FBF400140761 /* WebCoreNSURLSession.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSURLSession.mm; sourceTree = "<group>"; };
CD225C0A1C46FBF400140761 /* WebCoreNSURLSession.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebCoreNSURLSession.h; sourceTree = "<group>"; };
+ CD227E362113AEFA00D285AF /* MediaSessionManagerCocoa.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = MediaSessionManagerCocoa.h; path = cocoa/MediaSessionManagerCocoa.h; sourceTree = "<group>"; };
CD27F6E014575C1B0078207D /* MediaController.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MediaController.idl; sourceTree = "<group>"; };
CD27F6E2145767580078207D /* JSMediaController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMediaController.cpp; sourceTree = "<group>"; };
CD27F6E3145767580078207D /* JSMediaController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMediaController.h; sourceTree = "<group>"; };
@@ -24625,6 +24627,7 @@
isa = PBXGroup;
children = (
CD669D661D232DFF004D1866 /* MediaSessionManagerCocoa.cpp */,
+ CD227E362113AEFA00D285AF /* MediaSessionManagerCocoa.h */,
CDE667A21E4BBF1500E8154A /* WebAudioBufferList.cpp */,
CDE667A31E4BBF1500E8154A /* WebAudioBufferList.h */,
);
@@ -27824,6 +27827,7 @@
8371AC3B1F509BE400FBF284 /* ErrorCallback.h in Headers */,
2ECF7AE210162B5800427DE7 /* ErrorEvent.h in Headers */,
85031B420A44EFC700F992E0 /* Event.h in Headers */,
+ CD227E3A2113C86200D285AF /* MediaSessionManagerCocoa.h in Headers */,
4138D3351244054800323D33 /* EventContext.h in Headers */,
418A06D0133C04D500CD379C /* EventDispatcher.h in Headers */,
93C09A530B064DB3005ABD4D /* EventHandler.h in Headers */,
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2018-08-04 02:01:04 UTC (rev 234572)
@@ -117,6 +117,8 @@
INFO_LOG(LOGIDENTIFIER, state);
m_state = state;
+ if (m_state == State::Playing)
+ m_hasPlayedSinceLastInterruption = true;
PlatformMediaSessionManager::sharedManager().sessionStateChanged(*this);
}
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2018-08-04 02:01:04 UTC (rev 234572)
@@ -176,6 +176,9 @@
virtual bool allowsNowPlayingControlsVisibility() const { return false; }
+ bool hasPlayedSinceLastInterruption() const { return m_hasPlayedSinceLastInterruption; }
+ void clearHasPlayedSinceLastInterruption() { m_hasPlayedSinceLastInterruption = false; }
+
protected:
PlatformMediaSessionClient& client() const { return m_client; }
@@ -194,6 +197,7 @@
int m_interruptionCount { 0 };
bool m_notifyingClient;
bool m_isPlayingToWirelessPlaybackTarget { false };
+ bool m_hasPlayedSinceLastInterruption { false };
#if !RELEASE_LOG_DISABLED
Ref<const Logger> m_logger;
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2018-08-04 02:01:04 UTC (rev 234572)
@@ -357,12 +357,6 @@
updateSessionState();
}
-#if !PLATFORM(COCOA)
-void PlatformMediaSessionManager::updateSessionState()
-{
-}
-#endif
-
void PlatformMediaSessionManager::didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType command, const PlatformMediaSession::RemoteCommandArgument* argument)
{
PlatformMediaSession* activeSession = currentSession();
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2018-08-04 02:01:04 UTC (rev 234572)
@@ -66,7 +66,7 @@
bool willIgnoreSystemInterruptions() const { return m_willIgnoreSystemInterruptions; }
void setWillIgnoreSystemInterruptions(bool ignore) { m_willIgnoreSystemInterruptions = ignore; }
- WEBCORE_EXPORT void beginInterruption(PlatformMediaSession::InterruptionType);
+ WEBCORE_EXPORT virtual void beginInterruption(PlatformMediaSession::InterruptionType);
WEBCORE_EXPORT void endInterruption(PlatformMediaSession::EndInterruptionFlags);
WEBCORE_EXPORT void applicationWillBecomeInactive() const;
@@ -123,10 +123,12 @@
PlatformMediaSession* findSession(const Function<bool(PlatformMediaSession&, size_t)>&) const;
bool anyOfSessions(const Function<bool(PlatformMediaSession&, size_t)>& predicate) const { return findSession(predicate); }
+ AudioHardwareListener* audioHardwareListener() { return m_audioHardwareListener.get(); }
+
private:
friend class Internals;
- void updateSessionState();
+ virtual void updateSessionState() { }
// RemoteCommandListenerClient
WEBCORE_EXPORT void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType, const PlatformMediaSession::RemoteCommandArgument*) override;
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.cpp 2018-08-04 02:01:04 UTC (rev 234572)
@@ -24,7 +24,7 @@
*/
#include "config.h"
-#include "PlatformMediaSessionManager.h"
+#include "MediaSessionManagerCocoa.h"
#if USE(AUDIO_SESSION)
@@ -38,7 +38,7 @@
static const size_t kWebAudioBufferSize = 128;
static const size_t kLowPowerVideoBufferSize = 4096;
-void PlatformMediaSessionManager::updateSessionState()
+void MediaSessionManagerCocoa::updateSessionState()
{
LOG(Media, "PlatformMediaSessionManager::scheduleUpdateSessionState() - types: Video(%d), Audio(%d), WebAudio(%d)", count(PlatformMediaSession::Video), count(PlatformMediaSession::Audio), count(PlatformMediaSession::WebAudio));
@@ -53,7 +53,7 @@
// causes media LayoutTests to fail on 10.8.
size_t bufferSize;
- if (m_audioHardwareListener && m_audioHardwareListener->outputDeviceSupportsLowPowerMode())
+ if (audioHardwareListener() && audioHardwareListener()->outputDeviceSupportsLowPowerMode())
bufferSize = kLowPowerVideoBufferSize;
else
bufferSize = kWebAudioBufferSize;
@@ -70,7 +70,7 @@
auto type = session.mediaType();
if (type == PlatformMediaSession::WebAudio)
hasWebAudioType = true;
- if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.state() == PlatformMediaSession::Playing)
+ if ((type == PlatformMediaSession::VideoAudio || type == PlatformMediaSession::Audio) && session.canProduceAudio() && session.hasPlayedSinceLastInterruption())
hasAudibleAudioOrVideoMediaType = true;
if (session.isPlayingToWirelessPlaybackTarget())
hasAudibleAudioOrVideoMediaType = true;
@@ -87,4 +87,15 @@
AudioSession::sharedSession().setCategory(AudioSession::None);
}
+void MediaSessionManagerCocoa::beginInterruption(PlatformMediaSession::InterruptionType type)
+{
+ if (type == PlatformMediaSession::InterruptionType::SystemInterruption) {
+ forEachSession([] (PlatformMediaSession& session, size_t) {
+ session.clearHasPlayedSinceLastInterruption();
+ });
+ }
+
+ PlatformMediaSessionManager::beginInterruption(type);
+}
+
#endif // USE(AUDIO_SESSION)
Added: branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (0 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h (rev 0)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/cocoa/MediaSessionManagerCocoa.h 2018-08-04 02:01:04 UTC (rev 234572)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if PLATFORM(COCOA)
+
+#include "PlatformMediaSessionManager.h"
+
+namespace WebCore {
+
+class MediaSessionManagerCocoa : public PlatformMediaSessionManager {
+public:
+ void updateSessionState() override;
+ void beginInterruption(PlatformMediaSession::InterruptionType) override;
+};
+
+}
+
+#endif // PLATFORM(COCOA)
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2018-08-04 02:01:04 UTC (rev 234572)
@@ -27,7 +27,7 @@
#if PLATFORM(IOS)
-#include "PlatformMediaSessionManager.h"
+#include "MediaSessionManagerCocoa.h"
#include <wtf/RetainPtr.h>
OBJC_CLASS WebMediaSessionHelper;
@@ -41,7 +41,7 @@
namespace WebCore {
-class MediaSessionManageriOS : public PlatformMediaSessionManager {
+class MediaSessionManageriOS : public MediaSessionManagerCocoa {
public:
virtual ~MediaSessionManageriOS();
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2018-08-04 02:01:04 UTC (rev 234572)
@@ -144,7 +144,7 @@
}
MediaSessionManageriOS::MediaSessionManageriOS()
- : PlatformMediaSessionManager()
+ : MediaSessionManagerCocoa()
{
BEGIN_BLOCK_OBJC_EXCEPTIONS
m_objcObserver = adoptNS([[WebMediaSessionHelper alloc] initWithCallback:this]);
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.h 2018-08-04 02:01:04 UTC (rev 234572)
@@ -28,11 +28,11 @@
#if PLATFORM(MAC)
#include "GenericTaskQueue.h"
-#include "PlatformMediaSessionManager.h"
+#include "MediaSessionManagerCocoa.h"
namespace WebCore {
-class MediaSessionManagerMac : public PlatformMediaSessionManager {
+class MediaSessionManagerMac : public MediaSessionManagerCocoa {
public:
virtual ~MediaSessionManagerMac();
Modified: branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm (234571 => 234572)
--- branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2018-08-04 01:33:10 UTC (rev 234571)
+++ branches/safari-606-branch/Source/WebCore/platform/audio/mac/MediaSessionManagerMac.mm 2018-08-04 02:01:04 UTC (rev 234572)
@@ -55,7 +55,7 @@
}
MediaSessionManagerMac::MediaSessionManagerMac()
- : PlatformMediaSessionManager()
+ : MediaSessionManagerCocoa()
{
resetRestrictions();
}