[Cocoa] Deactivate the audio session before the WebProcess suspends.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Apr 2019 01:08:50 +0000 (01:08 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Apr 2019 01:08:50 +0000 (01:08 +0000)
commitf359bf2cde9a4e32c8aceef87cf7d7c6584b7922
treec669a453592c012a4149668bf68551b7c87ba2b7
parent8a642276d6c895852072d7d97539c202a541ae4c
[Cocoa] Deactivate the audio session before the WebProcess suspends.
https://bugs.webkit.org/show_bug.cgi?id=196658

Reviewed by Eric Carlson.

Source/WebCore:

Test: platform/mac/media/audio-session-deactivated-when-suspended.html

Deactivate the audio session when we are notified that the session will suspend.

Drive-by fix: don't try to begin playback when the process is suspended.

* platform/audio/PlatformMediaSessionManager.cpp:
(WebCore::PlatformMediaSessionManager::sessionWillBeginPlayback):
(WebCore::PlatformMediaSessionManager::processWillSuspend):
(WebCore::PlatformMediaSessionManager::processDidResume):
* platform/audio/PlatformMediaSessionManager.h:
(WebCore::PlatformMediaSessionManager::processIsSuspended const):
* testing/InternalSettings.cpp:
(WebCore::InternalSettings::Backup::Backup):
(WebCore::InternalSettings::Backup::restoreTo):
(WebCore::InternalSettings::setShouldDeactivateAudioSession):
* testing/InternalSettings.h:
* testing/InternalSettings.idl:
* testing/Internals.cpp:
(WebCore::Internals::processWillSuspend):
(WebCore::Internals::processDidResume):
* testing/Internals.h:
* testing/Internals.idl:

Source/WebKit:

Notify the PlatformMediaSessionManager when the process suspends or resumes.

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::actualPrepareToSuspend):
(WebKit::WebProcess::cancelPrepareToSuspend):
(WebKit::WebProcess::processDidResume):

LayoutTests:

* platform/mac/media/audio-session-deactivated-when-suspended-expected.txt: Added.
* platform/mac/media/audio-session-deactivated-when-suspended.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243958 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/mac/media/audio-session-deactivated-when-suspended-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/media/audio-session-deactivated-when-suspended.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/testing/InternalSettings.cpp
Source/WebCore/testing/InternalSettings.h
Source/WebCore/testing/InternalSettings.idl
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl
Source/WebKit/ChangeLog
Source/WebKit/WebProcess/WebProcess.cpp