Title: [257936] trunk/Source
Revision
257936
Author
jer.no...@apple.com
Date
2020-03-05 11:43:12 -0800 (Thu, 05 Mar 2020)

Log Message

[GPUP] Implement RemoteAudioSession
https://bugs.webkit.org/show_bug.cgi?id=208583

Reviewed by Alex Christensen.

Source/WebCore:

Add EnumTraits for all the enumerations inside AudioSession.

Make many AudioSession methods virtual, so they can be overridden in the case where the
GPU process is enabled.

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* platform/audio/AudioSession.cpp:
(WebCore::AudioSession::create):
(WebCore::AudioSession::sharedSession):
* platform/audio/AudioSession.h:

Source/WebKit:

Add a subclass of AudioSession which, instead of modifying the audio behavior of the current process, modifies the
audio behavior of the GPU Process. And, in the GPU Process, since it represents the audio behavior of potentially
multiple separate WebContent processes.

Override the default shared AudioSession at WebProcess initialization time.

* DerivedSources-input.xcfilelist:
* DerivedSources-output.xcfilelist:
* DerivedSources.make:
* GPUProcess/GPUConnectionToWebProcess.cpp:
(WebKit::GPUConnectionToWebProcess::didClose):
(WebKit::GPUConnectionToWebProcess::audioSessionProxy):
(WebKit::GPUConnectionToWebProcess::ensureAudioSession):
(WebKit::GPUConnectionToWebProcess::legacyCdmFactoryProxy):
(WebKit::GPUConnectionToWebProcess::dispatchMessage):
(WebKit::GPUConnectionToWebProcess::dispatchSyncMessage):
* GPUProcess/GPUConnectionToWebProcess.h:
* GPUProcess/GPUConnectionToWebProcess.messages.in:
* GPUProcess/GPUProcess.cpp:
(WebKit::GPUProcess::initializeGPUProcess):
(WebKit::GPUProcess::audioSessionManager const):
* GPUProcess/GPUProcess.h:
* GPUProcess/media/RemoteAudioSessionProxy.cpp: Added.
(WebKit::RemoteAudioSessionProxy::create):
(WebKit::RemoteAudioSessionProxy::RemoteAudioSessionProxy):
(WebKit::RemoteAudioSessionProxy::processIdentifier):
(WebKit::RemoteAudioSessionProxy::configuration):
(WebKit::RemoteAudioSessionProxy::setCategory):
(WebKit::RemoteAudioSessionProxy::setPreferredBufferSize):
(WebKit::RemoteAudioSessionProxy::tryToSetActive):
(WebKit::RemoteAudioSessionProxy::beginInterruption):
(WebKit::RemoteAudioSessionProxy::endInterruption):
(WebKit::RemoteAudioSessionProxy::audioSessionManager):
(WebKit::RemoteAudioSessionProxy::connection):
* GPUProcess/media/RemoteAudioSessionProxy.h: Added.
(WebKit::RemoteAudioSessionProxy::category const):
(WebKit::RemoteAudioSessionProxy::routeSharingPolicy const):
(WebKit::RemoteAudioSessionProxy::preferredBufferSize const):
(WebKit::RemoteAudioSessionProxy::isActive const):
* GPUProcess/media/RemoteAudioSessionProxy.messages.in:
* GPUProcess/media/RemoteAudioSessionProxyManager.cpp: Added.
(WebKit::RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager):
(WebKit::RemoteAudioSessionProxyManager::addProxy):
(WebKit::RemoteAudioSessionProxyManager::removeProxy):
(WebKit::RemoteAudioSessionProxyManager::getProxy):
(WebKit::RemoteAudioSessionProxyManager::setCategoryForProcess):
(WebKit::RemoteAudioSessionProxyManager::setPreferredBufferSizeForProcess):
(WebKit::RemoteAudioSessionProxyManager::tryToSetActiveForProcess):
* GPUProcess/media/RemoteAudioSessionProxyManager.h:
(WebKit::RemoteAudioSessionProxyManager::session const):
* GPUProcess/media/RemoteAudioSessionProxyManager.messages.in:
* Scripts/webkit/messages.py:
* Sources.txt:
* SourcesCocoa.txt:
* WebKit.xcodeproj/project.pbxproj:
* WebProcess/GPU/media/RemoteAudioSession.cpp: Added.
(WebKit::RemoteAudioSession::create):
(WebKit::RemoteAudioSession::RemoteAudioSession):
(WebKit::RemoteAudioSession::connection):
(WebKit::RemoteAudioSession::setCategory):
(WebKit::RemoteAudioSession::setPreferredBufferSize):
(WebKit::RemoteAudioSession::tryToSetActiveInternal):
(WebKit::RemoteAudioSession::configurationChanged):
(WebKit::RemoteAudioSession::beginInterruption):
(WebKit::RemoteAudioSession::endInterruption):
* WebProcess/GPU/media/RemoteAudioSession.h: Added.
* WebProcess/GPU/media/RemoteAudioSession.messages.in:
* WebProcess/GPU/media/RemoteAudioSessionConfiguration.h: Added.
(WebKit::RemoteAudioSessionConfiguration::encode const):
(WebKit::RemoteAudioSessionConfiguration::decode):
* WebProcess/GPU/media/RemoteAudioSessionIdentifier.h:

Source/WTF:

Add UniqueRef to the list of forward-declared template types.

* wtf/Forward.h:

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (257935 => 257936)


--- trunk/Source/WTF/ChangeLog	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WTF/ChangeLog	2020-03-05 19:43:12 UTC (rev 257936)
@@ -1,3 +1,14 @@
+2020-03-05  Jer Noble  <jer.no...@apple.com>
+
+        [GPUP] Implement RemoteAudioSession
+        https://bugs.webkit.org/show_bug.cgi?id=208583
+
+        Reviewed by Alex Christensen.
+
+        Add UniqueRef to the list of forward-declared template types.
+
+        * wtf/Forward.h:
+
 2020-03-04  Mark Lam  <mark....@apple.com>
 
         Handle an out of memory error while constructing the BytecodeGenerator.

Modified: trunk/Source/WTF/wtf/Forward.h (257935 => 257936)


--- trunk/Source/WTF/wtf/Forward.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WTF/wtf/Forward.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -68,6 +68,7 @@
 template<typename T, typename = DumbPtrTraits<T>> class RefPtr;
 template<typename> class StringBuffer;
 template<typename, typename = void> class StringTypeAdapter;
+template<typename T> class UniqueRef;
 template<typename T> class WeakPtr;
 
 template<typename> struct DefaultHash { using Hash = void; };
@@ -125,6 +126,7 @@
 using WTF::TextPosition;
 using WTF::TextStream;
 using WTF::URL;
+using WTF::UniqueRef;
 using WTF::Variant;
 using WTF::Vector;
 

Modified: trunk/Source/WebCore/ChangeLog (257935 => 257936)


--- trunk/Source/WebCore/ChangeLog	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebCore/ChangeLog	2020-03-05 19:43:12 UTC (rev 257936)
@@ -1,3 +1,22 @@
+2020-03-05  Jer Noble  <jer.no...@apple.com>
+
+        [GPUP] Implement RemoteAudioSession
+        https://bugs.webkit.org/show_bug.cgi?id=208583
+
+        Reviewed by Alex Christensen.
+
+        Add EnumTraits for all the enumerations inside AudioSession.
+
+        Make many AudioSession methods virtual, so they can be overridden in the case where the
+        GPU process is enabled.
+
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/audio/AudioSession.cpp:
+        (WebCore::AudioSession::create):
+        (WebCore::AudioSession::sharedSession):
+        * platform/audio/AudioSession.h:
+
 2020-03-05  Simon Fraser  <simon.fra...@apple.com>
 
         Make m_viewportConstrainedObjects into a WeakHashSet

Modified: trunk/Source/WebCore/platform/audio/AudioSession.cpp (257935 => 257936)


--- trunk/Source/WebCore/platform/audio/AudioSession.cpp	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebCore/platform/audio/AudioSession.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -33,12 +33,27 @@
 
 namespace WebCore {
 
+static UniqueRef<AudioSession>& sharedAudioSession()
+{
+    static NeverDestroyed<UniqueRef<AudioSession>> session = AudioSession::create();
+    return session.get();
+}
+
+UniqueRef<AudioSession> AudioSession::create()
+{
+    return makeUniqueRef<AudioSession>();
+}
+
 AudioSession& AudioSession::sharedSession()
 {
-    static NeverDestroyed<AudioSession> session;
-    return session;
+    return sharedAudioSession();
 }
 
+void AudioSession::setSharedSession(UniqueRef<AudioSession>&& session)
+{
+    sharedAudioSession() = WTFMove(session);
+}
+
 bool AudioSession::tryToSetActive(bool active)
 {
     if (!tryToSetActiveInternal(active))

Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (257935 => 257936)


--- trunk/Source/WebCore/platform/audio/AudioSession.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -31,6 +31,7 @@
 #include <wtf/HashSet.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/Noncopyable.h>
+#include <wtf/UniqueRef.h>
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -44,13 +45,18 @@
     LongFormVideo
 };
 
-class AudioSession final {
+class WEBCORE_EXPORT AudioSession {
     WTF_MAKE_FAST_ALLOCATED;
     WTF_MAKE_NONCOPYABLE(AudioSession);
+    friend class UniqueRef<AudioSession>;
+    friend UniqueRef<AudioSession> WTF::makeUniqueRefWithoutFastMallocCheck<AudioSession>();
 public:
-    WEBCORE_EXPORT static AudioSession& sharedSession();
+    static UniqueRef<AudioSession> create();
+    static void setSharedSession(UniqueRef<AudioSession>&&);
+    static AudioSession& sharedSession();
+    virtual ~AudioSession();
 
-    enum CategoryType {
+    enum CategoryType : uint8_t {
         None,
         AmbientSound,
         SoloAmbientSound,
@@ -59,23 +65,23 @@
         PlayAndRecord,
         AudioProcessing,
     };
-    WEBCORE_EXPORT void setCategory(CategoryType, RouteSharingPolicy);
-    WEBCORE_EXPORT CategoryType category() const;
+    virtual void setCategory(CategoryType, RouteSharingPolicy);
+    virtual CategoryType category() const;
 
     void setCategoryOverride(CategoryType);
     CategoryType categoryOverride() const;
 
-    RouteSharingPolicy routeSharingPolicy() const;
-    String routingContextUID() const;
+    virtual RouteSharingPolicy routeSharingPolicy() const;
+    virtual String routingContextUID() const;
 
-    WEBCORE_EXPORT float sampleRate() const;
-    size_t bufferSize() const;
-    size_t numberOfOutputChannels() const;
+    virtual float sampleRate() const;
+    virtual size_t bufferSize() const;
+    virtual size_t numberOfOutputChannels() const;
 
     bool tryToSetActive(bool);
 
-    WEBCORE_EXPORT size_t preferredBufferSize() const;
-    WEBCORE_EXPORT void setPreferredBufferSize(size_t);
+    virtual size_t preferredBufferSize() const;
+    virtual void setPreferredBufferSize(size_t);
 
     class MutedStateObserver {
     public:
@@ -87,17 +93,16 @@
     void addMutedStateObserver(MutedStateObserver*);
     void removeMutedStateObserver(MutedStateObserver*);
 
-    bool isMuted() const;
-    void handleMutedStateChange();
+    virtual bool isMuted() const;
+    virtual void handleMutedStateChange();
 
-    bool isActive() const { return m_active; }
+    virtual bool isActive() const { return m_active; }
 
-private:
+protected:
     friend class NeverDestroyed<AudioSession>;
     AudioSession();
-    ~AudioSession();
 
-    bool tryToSetActiveInternal(bool);
+    virtual bool tryToSetActiveInternal(bool);
 
     std::unique_ptr<AudioSessionPrivate> m_private;
     HashSet<MutedStateObserver*> m_observers;
@@ -120,6 +125,19 @@
     >;
 };
 
+template <> struct EnumTraits<WebCore::AudioSession::CategoryType> {
+    using values = EnumValues <
+    WebCore::AudioSession::CategoryType,
+    WebCore::AudioSession::CategoryType::None,
+    WebCore::AudioSession::CategoryType::AmbientSound,
+    WebCore::AudioSession::CategoryType::SoloAmbientSound,
+    WebCore::AudioSession::CategoryType::MediaPlayback,
+    WebCore::AudioSession::CategoryType::RecordAudio,
+    WebCore::AudioSession::CategoryType::PlayAndRecord,
+    WebCore::AudioSession::CategoryType::AudioProcessing
+    >;
+};
+
 template<typename Type>
 struct LogArgument;
 

Modified: trunk/Source/WebCore/platform/audio/PlatformMediaSession.h (257935 => 257936)


--- trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebCore/platform/audio/PlatformMediaSession.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -60,7 +60,7 @@
 
     virtual ~PlatformMediaSession();
 
-    enum class MediaType {
+    enum class MediaType : uint8_t {
         None = 0,
         Video,
         VideoAudio,
@@ -70,7 +70,7 @@
     MediaType mediaType() const;
     MediaType presentationType() const;
 
-    enum State {
+    enum State : uint8_t {
         Idle,
         Autoplaying,
         Playing,
@@ -80,7 +80,7 @@
     State state() const { return m_state; }
     void setState(State);
 
-    enum InterruptionType {
+    enum InterruptionType : uint8_t {
         NoInterruption,
         SystemSleep,
         EnteringBackground,
@@ -92,7 +92,7 @@
     };
     InterruptionType interruptionType() const { return m_interruptionType; }
 
-    enum EndInterruptionFlags {
+    enum EndInterruptionFlags : uint8_t {
         NoFlags = 0,
         MayResumePlaying = 1 << 0,
     };
@@ -118,7 +118,7 @@
         double asDouble;
     } RemoteCommandArgument;
 
-    enum RemoteControlCommandType {
+    enum RemoteControlCommandType : uint8_t {
         NoCommand,
         PlayCommand,
         PauseCommand,
@@ -134,7 +134,7 @@
     void didReceiveRemoteControlCommand(RemoteControlCommandType, const RemoteCommandArgument* argument = nullptr);
     bool supportsSeeking() const;
 
-    enum DisplayType {
+    enum DisplayType : uint8_t {
         Normal,
         Fullscreen,
         Optimized,
@@ -297,4 +297,64 @@
     }
 };
 
+template <> struct EnumTraits<WebCore::PlatformMediaSession::MediaType> {
+    using values = EnumValues <
+    WebCore::PlatformMediaSession::MediaType,
+    WebCore::PlatformMediaSession::MediaType::None,
+    WebCore::PlatformMediaSession::MediaType::Video,
+    WebCore::PlatformMediaSession::MediaType::VideoAudio,
+    WebCore::PlatformMediaSession::MediaType::Audio,
+    WebCore::PlatformMediaSession::MediaType::WebAudio
+    >;
+};
+
+template <> struct EnumTraits<WebCore::PlatformMediaSession::State> {
+    using values = EnumValues <
+    WebCore::PlatformMediaSession::State,
+    WebCore::PlatformMediaSession::State::Idle,
+    WebCore::PlatformMediaSession::State::Autoplaying,
+    WebCore::PlatformMediaSession::State::Playing,
+    WebCore::PlatformMediaSession::State::Paused,
+    WebCore::PlatformMediaSession::State::Interrupted
+    >;
+};
+
+template <> struct EnumTraits<WebCore::PlatformMediaSession::InterruptionType> {
+    using values = EnumValues <
+    WebCore::PlatformMediaSession::InterruptionType,
+    WebCore::PlatformMediaSession::InterruptionType::NoInterruption,
+    WebCore::PlatformMediaSession::InterruptionType::SystemSleep,
+    WebCore::PlatformMediaSession::InterruptionType::EnteringBackground,
+    WebCore::PlatformMediaSession::InterruptionType::SystemInterruption,
+    WebCore::PlatformMediaSession::InterruptionType::SuspendedUnderLock,
+    WebCore::PlatformMediaSession::InterruptionType::InvisibleAutoplay,
+    WebCore::PlatformMediaSession::InterruptionType::ProcessInactive,
+    WebCore::PlatformMediaSession::InterruptionType::PlaybackSuspended
+    >;
+};
+
+template <> struct EnumTraits<WebCore::PlatformMediaSession::EndInterruptionFlags> {
+    using values = EnumValues <
+    WebCore::PlatformMediaSession::EndInterruptionFlags,
+    WebCore::PlatformMediaSession::EndInterruptionFlags::NoFlags,
+    WebCore::PlatformMediaSession::EndInterruptionFlags::MayResumePlaying
+    >;
+};
+
+template <> struct EnumTraits<WebCore::PlatformMediaSession::RemoteControlCommandType> {
+    using values = EnumValues <
+    WebCore::PlatformMediaSession::RemoteControlCommandType,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::NoCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::PlayCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::PauseCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::StopCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::TogglePlayPauseCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::BeginSeekingBackwardCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::EndSeekingBackwardCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::BeginSeekingForwardCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::EndSeekingForwardCommand,
+    WebCore::PlatformMediaSession::RemoteControlCommandType::SeekToPlaybackPositionCommand
+    >;
+};
+
 } // namespace WTF

Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm (257935 => 257936)


--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm	2020-03-05 19:43:12 UTC (rev 257936)
@@ -243,6 +243,15 @@
     ASSERT(!error);
 }
 
+bool AudioSession::isMuted() const
+{
+    return false;
 }
 
+void AudioSession::handleMutedStateChange()
+{
+}
+
+}
+
 #endif // USE(AUDIO_SESSION) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/ChangeLog (257935 => 257936)


--- trunk/Source/WebKit/ChangeLog	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/ChangeLog	2020-03-05 19:43:12 UTC (rev 257936)
@@ -1,3 +1,82 @@
+2020-03-05  Jer Noble  <jer.no...@apple.com>
+
+        [GPUP] Implement RemoteAudioSession
+        https://bugs.webkit.org/show_bug.cgi?id=208583
+
+        Reviewed by Alex Christensen.
+
+        Add a subclass of AudioSession which, instead of modifying the audio behavior of the current process, modifies the
+        audio behavior of the GPU Process. And, in the GPU Process, since it represents the audio behavior of potentially
+        multiple separate WebContent processes.
+
+        Override the default shared AudioSession at WebProcess initialization time.
+
+        * DerivedSources-input.xcfilelist:
+        * DerivedSources-output.xcfilelist:
+        * DerivedSources.make:
+        * GPUProcess/GPUConnectionToWebProcess.cpp:
+        (WebKit::GPUConnectionToWebProcess::didClose):
+        (WebKit::GPUConnectionToWebProcess::audioSessionProxy):
+        (WebKit::GPUConnectionToWebProcess::ensureAudioSession):
+        (WebKit::GPUConnectionToWebProcess::legacyCdmFactoryProxy):
+        (WebKit::GPUConnectionToWebProcess::dispatchMessage):
+        (WebKit::GPUConnectionToWebProcess::dispatchSyncMessage):
+        * GPUProcess/GPUConnectionToWebProcess.h:
+        * GPUProcess/GPUConnectionToWebProcess.messages.in:
+        * GPUProcess/GPUProcess.cpp:
+        (WebKit::GPUProcess::initializeGPUProcess):
+        (WebKit::GPUProcess::audioSessionManager const):
+        * GPUProcess/GPUProcess.h:
+        * GPUProcess/media/RemoteAudioSessionProxy.cpp: Added.
+        (WebKit::RemoteAudioSessionProxy::create):
+        (WebKit::RemoteAudioSessionProxy::RemoteAudioSessionProxy):
+        (WebKit::RemoteAudioSessionProxy::processIdentifier):
+        (WebKit::RemoteAudioSessionProxy::configuration):
+        (WebKit::RemoteAudioSessionProxy::setCategory):
+        (WebKit::RemoteAudioSessionProxy::setPreferredBufferSize):
+        (WebKit::RemoteAudioSessionProxy::tryToSetActive):
+        (WebKit::RemoteAudioSessionProxy::beginInterruption):
+        (WebKit::RemoteAudioSessionProxy::endInterruption):
+        (WebKit::RemoteAudioSessionProxy::audioSessionManager):
+        (WebKit::RemoteAudioSessionProxy::connection):
+        * GPUProcess/media/RemoteAudioSessionProxy.h: Added.
+        (WebKit::RemoteAudioSessionProxy::category const):
+        (WebKit::RemoteAudioSessionProxy::routeSharingPolicy const):
+        (WebKit::RemoteAudioSessionProxy::preferredBufferSize const):
+        (WebKit::RemoteAudioSessionProxy::isActive const):
+        * GPUProcess/media/RemoteAudioSessionProxy.messages.in:
+        * GPUProcess/media/RemoteAudioSessionProxyManager.cpp: Added.
+        (WebKit::RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager):
+        (WebKit::RemoteAudioSessionProxyManager::addProxy):
+        (WebKit::RemoteAudioSessionProxyManager::removeProxy):
+        (WebKit::RemoteAudioSessionProxyManager::getProxy):
+        (WebKit::RemoteAudioSessionProxyManager::setCategoryForProcess):
+        (WebKit::RemoteAudioSessionProxyManager::setPreferredBufferSizeForProcess):
+        (WebKit::RemoteAudioSessionProxyManager::tryToSetActiveForProcess):
+        * GPUProcess/media/RemoteAudioSessionProxyManager.h:
+        (WebKit::RemoteAudioSessionProxyManager::session const):
+        * GPUProcess/media/RemoteAudioSessionProxyManager.messages.in:
+        * Scripts/webkit/messages.py:
+        * Sources.txt:
+        * SourcesCocoa.txt:
+        * WebKit.xcodeproj/project.pbxproj:
+        * WebProcess/GPU/media/RemoteAudioSession.cpp: Added.
+        (WebKit::RemoteAudioSession::create):
+        (WebKit::RemoteAudioSession::RemoteAudioSession):
+        (WebKit::RemoteAudioSession::connection):
+        (WebKit::RemoteAudioSession::setCategory):
+        (WebKit::RemoteAudioSession::setPreferredBufferSize):
+        (WebKit::RemoteAudioSession::tryToSetActiveInternal):
+        (WebKit::RemoteAudioSession::configurationChanged):
+        (WebKit::RemoteAudioSession::beginInterruption):
+        (WebKit::RemoteAudioSession::endInterruption):
+        * WebProcess/GPU/media/RemoteAudioSession.h: Added.
+        * WebProcess/GPU/media/RemoteAudioSession.messages.in:
+        * WebProcess/GPU/media/RemoteAudioSessionConfiguration.h: Added.
+        (WebKit::RemoteAudioSessionConfiguration::encode const):
+        (WebKit::RemoteAudioSessionConfiguration::decode):
+        * WebProcess/GPU/media/RemoteAudioSessionIdentifier.h:
+
 2020-03-05  Brent Fulgham  <bfulg...@apple.com>
 
         Sandbox: Allow sysctl read of "kern.ostype"

Modified: trunk/Source/WebKit/DerivedSources-input.xcfilelist (257935 => 257936)


--- trunk/Source/WebKit/DerivedSources-input.xcfilelist	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/DerivedSources-input.xcfilelist	2020-03-05 19:43:12 UTC (rev 257936)
@@ -18,6 +18,8 @@
 $(PROJECT_DIR)/GPUProcess/graphics/RemoteRenderingBackendProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/mac/com.apple.WebKit.GPUProcess.sb.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteAudioDestinationManager.messages.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteAudioSessionProxy.messages.in
+$(PROJECT_DIR)/GPUProcess/media/RemoteAudioSessionProxyManager.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteCDMFactoryProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteCDMInstanceProxy.messages.in
 $(PROJECT_DIR)/GPUProcess/media/RemoteCDMInstanceSessionProxy.messages.in
@@ -116,6 +118,7 @@
 $(PROJECT_DIR)/WebProcess/GPU/graphics/RemoteRenderingBackend.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/MediaPlayerPrivateRemote.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioDestinationProxy.messages.in
+$(PROJECT_DIR)/WebProcess/GPU/media/RemoteAudioSession.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteCDMInstanceSession.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/RemoteMediaPlayerManager.messages.in
 $(PROJECT_DIR)/WebProcess/GPU/media/TextTrackPrivateRemote.messages.in

Modified: trunk/Source/WebKit/DerivedSources-output.xcfilelist (257935 => 257936)


--- trunk/Source/WebKit/DerivedSources-output.xcfilelist	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/DerivedSources-output.xcfilelist	2020-03-05 19:43:12 UTC (rev 257936)
@@ -137,6 +137,15 @@
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioMediaStreamTrackRendererMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyManagerMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyManagerMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyManagerMessagesReplies.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyMessageReceiver.cpp
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyMessages.h
+$(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteAudioSessionProxyMessagesReplies.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessageReceiver.cpp
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessages.h
 $(BUILT_PRODUCTS_DIR)/DerivedSources/WebKit2/RemoteCDMFactoryProxyMessagesReplies.h

Modified: trunk/Source/WebKit/DerivedSources.make (257935 => 257936)


--- trunk/Source/WebKit/DerivedSources.make	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/DerivedSources.make	2020-03-05 19:43:12 UTC (rev 257936)
@@ -148,6 +148,8 @@
     PluginProxy \
     RemoteAudioDestinationManager \
     RemoteAudioDestinationProxy \
+    RemoteAudioSession \
+    RemoteAudioSessionProxy \
     RemoteAudioMediaStreamTrackRendererManager \
     RemoteAudioMediaStreamTrackRenderer \
     RemoteLayerTreeDrawingAreaProxy \

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (257935 => 257936)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -76,6 +76,11 @@
 #include "RemoteCDMProxyMessages.h"
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+#include "RemoteAudioSessionProxy.h"
+#include "RemoteAudioSessionProxyManager.h"
+#include "RemoteAudioSessionProxyMessages.h"
+#endif
 
 namespace WebKit {
 using namespace WebCore;
@@ -134,6 +139,10 @@
 
 void GPUConnectionToWebProcess::didClose(IPC::Connection&)
 {
+    if (m_audioSessionProxy) {
+        gpuProcess().audioSessionManager().removeProxy(webProcessIdentifier());
+        m_audioSessionProxy = nullptr;
+    }
 }
 
 Logger& GPUConnectionToWebProcess::logger()
@@ -232,6 +241,17 @@
 }
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+RemoteAudioSessionProxy& GPUConnectionToWebProcess::audioSessionProxy()
+{
+    if (!m_audioSessionProxy) {
+        m_audioSessionProxy = RemoteAudioSessionProxy::create(*this).moveToUniquePtr();
+        gpuProcess().audioSessionManager().addProxy(makeWeakPtr(m_audioSessionProxy.get()));
+    }
+    return *m_audioSessionProxy;
+}
+#endif
+
 void GPUConnectionToWebProcess::createRenderingBackend(RenderingBackendIdentifier renderingBackendIdentifier)
 {
     auto addResult = m_remoteRenderingBackendProxyMap.ensure(renderingBackendIdentifier, [&]() {
@@ -258,6 +278,13 @@
 }
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+void GPUConnectionToWebProcess::ensureAudioSession(EnsureAudioSessionCompletion&& completion)
+{
+    completion(audioSessionProxy().configuration());
+}
+#endif
+
 bool GPUConnectionToWebProcess::dispatchMessage(IPC::Connection& connection, IPC::Decoder& decoder)
 {
     if (decoder.messageReceiverName() == Messages::RemoteAudioDestinationManager::messageReceiverName()) {
@@ -335,6 +362,12 @@
         return true;
     }
 #endif
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    if (decoder.messageReceiverName() == Messages::RemoteAudioSessionProxy::messageReceiverName()) {
+        audioSessionProxy().didReceiveMessage(connection, decoder);
+        return true;
+    }
+#endif
 
     return messageReceiverMap().dispatchMessage(connection, decoder);
 }
@@ -382,6 +415,12 @@
         return true;
     }
 #endif
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    if (decoder.messageReceiverName() == Messages::RemoteAudioSessionProxy::messageReceiverName()) {
+        audioSessionProxy().didReceiveSyncMessage(connection, decoder, replyEncoder);
+        return true;
+    }
+#endif
 
     return messageReceiverMap().dispatchSyncMessage(connection, decoder, replyEncoder);
 }

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h (257935 => 257936)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -30,6 +30,7 @@
 #include "Connection.h"
 #include "GPUConnectionToWebProcessMessages.h"
 #include "MessageReceiverMap.h"
+#include "RemoteAudioSessionIdentifier.h"
 #include "RemoteRenderingBackendProxy.h"
 #include "RenderingBackendIdentifier.h"
 #include <WebCore/ProcessIdentifier.h>
@@ -48,6 +49,8 @@
 class LibWebRTCCodecsProxy;
 class RemoteAudioDestinationManager;
 class RemoteAudioMediaStreamTrackRendererManager;
+class RemoteAudioSessionProxy;
+class RemoteAudioSessionProxyManager;
 class RemoteCDMFactoryProxy;
 class RemoteMediaPlayerManagerProxy;
 class RemoteMediaRecorderManager;
@@ -54,6 +57,7 @@
 class RemoteMediaResourceManager;
 class RemoteSampleBufferDisplayLayerManager;
 class UserMediaCaptureManagerProxy;
+struct RemoteAudioSessionConfiguration;
 
 class GPUConnectionToWebProcess
     : public RefCounted<GPUConnectionToWebProcess>
@@ -88,11 +92,15 @@
     RemoteCDMFactoryProxy& cdmFactoryProxy();
 #endif
 
+    RemoteMediaPlayerManagerProxy& remoteMediaPlayerManagerProxy();
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    RemoteAudioSessionProxyManager& audioSessionManager();
+#endif
+
 private:
     GPUConnectionToWebProcess(GPUProcess&, WebCore::ProcessIdentifier, IPC::Connection::Identifier, PAL::SessionID);
 
     RemoteAudioDestinationManager& remoteAudioDestinationManager();
-    RemoteMediaPlayerManagerProxy& remoteMediaPlayerManagerProxy();
 #if PLATFORM(COCOA) && USE(LIBWEBRTC)
     LibWebRTCCodecsProxy& libWebRTCCodecsProxy();
 #endif
@@ -104,6 +112,11 @@
     RemoteSampleBufferDisplayLayerManager& sampleBufferDisplayLayerManager();
 #endif
 #endif
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    RemoteAudioSessionProxy& audioSessionProxy();
+#endif
+
     void createRenderingBackend(RenderingBackendIdentifier);
     void releaseRenderingBackend(RenderingBackendIdentifier);
 #if PLATFORM(COCOA)
@@ -111,6 +124,11 @@
     void setNowPlayingInfo(bool setAsNowPlayingApplication, const WebCore::NowPlayingInfo&);
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    using EnsureAudioSessionCompletion = CompletionHandler<void(const RemoteAudioSessionConfiguration&)>;
+    void ensureAudioSession(EnsureAudioSessionCompletion&&);
+#endif
+
     // IPC::Connection::Client
     void didClose(IPC::Connection&) final;
     void didReceiveInvalidMessage(IPC::Connection&, IPC::StringReference messageReceiverName, IPC::StringReference messageName) final;
@@ -149,6 +167,9 @@
 #if ENABLE(ENCRYPTED_MEDIA)
     std::unique_ptr<RemoteCDMFactoryProxy> m_cdmFactoryProxy;
 #endif
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    std::unique_ptr<RemoteAudioSessionProxy> m_audioSessionProxy;
+#endif
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in (257935 => 257936)


--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.messages.in	2020-03-05 19:43:12 UTC (rev 257936)
@@ -29,6 +29,7 @@
     void ClearNowPlayingInfo();
     void SetNowPlayingInfo(bool setAsNowPlayingApplication, struct WebCore::NowPlayingInfo nowPlayingInfo);
 #endif
+    EnsureAudioSession() -> (struct WebKit::RemoteAudioSessionConfiguration configuration) Synchronous
 }
 
 #endif // ENABLE(GPU_PROCESS)

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.cpp (257935 => 257936)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -51,6 +51,10 @@
 #include <wtf/UniqueRef.h>
 #include <wtf/text/AtomString.h>
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+#include "RemoteAudioSessionProxyManager.h"
+#endif
+
 namespace WebKit {
 using namespace WebCore;
 
@@ -212,6 +216,15 @@
 }
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+RemoteAudioSessionProxyManager& GPUProcess::audioSessionManager() const
+{
+    if (!m_audioSessionManager)
+        m_audioSessionManager = WTF::makeUnique<RemoteAudioSessionProxyManager>();
+    return *m_audioSessionManager;
+}
+#endif
+
 } // namespace WebKit
 
 #endif // ENABLE(GPU_PROCESS)

Modified: trunk/Source/WebKit/GPUProcess/GPUProcess.h (257935 => 257936)


--- trunk/Source/WebKit/GPUProcess/GPUProcess.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/GPUProcess/GPUProcess.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -40,6 +40,7 @@
 struct GPUProcessCreationParameters;
 struct GPUProcessSessionParameters;
 class LayerHostingContext;
+class RemoteAudioSessionProxyManager;
 
 class GPUProcess : public AuxiliaryProcess, public ThreadSafeRefCounted<GPUProcess>, public CanMakeWeakPtr<GPUProcess> {
     WTF_MAKE_NONCOPYABLE(GPUProcess);
@@ -63,6 +64,10 @@
     const String& mediaKeysStorageDirectory(PAL::SessionID) const;
 #endif
 
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    RemoteAudioSessionProxyManager& audioSessionManager() const;
+#endif
+
 private:
     void lowMemoryHandler(Critical);
 
@@ -103,6 +108,9 @@
     std::unique_ptr<LayerHostingContext> m_contextForVisibilityPropagation;
     bool m_canShowWhileLocked { false };
 #endif
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+    mutable std::unique_ptr<RemoteAudioSessionProxyManager> m_audioSessionManager;
+#endif
 };
 
 } // namespace WebKit

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include "config.h"
+#include "RemoteAudioSessionProxy.h"
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include "RemoteAudioSessionMessages.h"
+#include "RemoteAudioSessionProxyManager.h"
+#include "RemoteAudioSessionProxyMessages.h"
+#include <WebCore/AudioSession.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+UniqueRef<RemoteAudioSessionProxy> RemoteAudioSessionProxy::create(GPUConnectionToWebProcess& gpuConnection)
+{
+    return makeUniqueRef<RemoteAudioSessionProxy>(gpuConnection);
+}
+
+RemoteAudioSessionProxy::RemoteAudioSessionProxy(GPUConnectionToWebProcess& gpuConnection)
+    : m_gpuConnection(gpuConnection)
+{
+}
+
+RemoteAudioSessionProxy::~RemoteAudioSessionProxy() = default;
+
+WebCore::ProcessIdentifier RemoteAudioSessionProxy::processIdentifier()
+{
+    return m_gpuConnection.webProcessIdentifier();
+}
+
+RemoteAudioSessionConfiguration RemoteAudioSessionProxy::configuration()
+{
+    auto& session = audioSessionManager().session();
+    return {
+        session.category(),
+        session.routeSharingPolicy(),
+        session.routingContextUID(),
+        session.sampleRate(),
+        session.bufferSize(),
+        session.numberOfOutputChannels(),
+        session.preferredBufferSize(),
+        session.isMuted(),
+        m_active
+    };
+}
+
+void RemoteAudioSessionProxy::setCategory(WebCore::AudioSession::CategoryType category, WebCore::RouteSharingPolicy policy)
+{
+    m_category = category;
+    m_routeSharingPolicy = policy;
+    audioSessionManager().setCategoryForProcess(m_gpuConnection.webProcessIdentifier(), category, policy);
+}
+
+void RemoteAudioSessionProxy::setPreferredBufferSize(uint64_t size)
+{
+    m_preferredBufferSize = size;
+    audioSessionManager().setPreferredBufferSizeForProcess(m_gpuConnection.webProcessIdentifier(), size);
+}
+
+void RemoteAudioSessionProxy::tryToSetActive(bool active, SetActiveCompletion&& completion)
+{
+    m_active = audioSessionManager().tryToSetActiveForProcess(m_gpuConnection.webProcessIdentifier(), active);
+    completion(m_active);
+}
+
+void RemoteAudioSessionProxy::beginInterruption(WebCore::PlatformMediaSession::InterruptionType type)
+{
+    connection().send(Messages::RemoteAudioSession::BeginInterruption(type), { });
+}
+
+void RemoteAudioSessionProxy::endInterruption(WebCore::PlatformMediaSession::EndInterruptionFlags flags)
+{
+    connection().send(Messages::RemoteAudioSession::EndInterruption(flags), { });
+}
+
+RemoteAudioSessionProxyManager& RemoteAudioSessionProxy::audioSessionManager()
+{
+    return m_gpuConnection.gpuProcess().audioSessionManager();
+}
+
+IPC::Connection& RemoteAudioSessionProxy::connection()
+{
+    return m_gpuConnection.connection();
+}
+
+}
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include "MessageReceiver.h"
+#include "RemoteAudioSessionConfiguration.h"
+#include <WebCore/AudioSession.h>
+#include <WebCore/PlatformMediaSession.h>
+#include <WebCore/ProcessIdentifier.h>
+#include <wtf/WeakPtr.h>
+
+namespace IPC {
+class Connection;
+}
+
+namespace WebKit {
+
+class RemoteAudioSessionProxyManager;
+
+class RemoteAudioSessionProxy
+    : public IPC::MessageReceiver
+    , public CanMakeWeakPtr<RemoteAudioSessionProxy> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static UniqueRef<RemoteAudioSessionProxy> create(GPUConnectionToWebProcess&);
+    virtual ~RemoteAudioSessionProxy();
+
+    WebCore::ProcessIdentifier processIdentifier();
+    RemoteAudioSessionConfiguration configuration();
+
+    WebCore::AudioSession::CategoryType category() const { return m_category; };
+    WebCore::RouteSharingPolicy routeSharingPolicy() const { return m_routeSharingPolicy; }
+    size_t preferredBufferSize() const { return m_preferredBufferSize; }
+    bool isActive() const { return m_active; }
+
+    void beginInterruption(WebCore::PlatformMediaSession::InterruptionType);
+    void endInterruption(WebCore::PlatformMediaSession::EndInterruptionFlags);
+
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+    void didReceiveSyncMessage(IPC::Connection&, IPC::Decoder&, std::unique_ptr<IPC::Encoder>&) final;
+
+private:
+    friend UniqueRef<RemoteAudioSessionProxy> WTF::makeUniqueRefWithoutFastMallocCheck<RemoteAudioSessionProxy>(GPUConnectionToWebProcess&);
+    RemoteAudioSessionProxy(GPUConnectionToWebProcess&);
+
+    // Messages
+    void setCategory(WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
+    void setPreferredBufferSize(uint64_t);
+    using SetActiveCompletion = CompletionHandler<void(bool)>;
+    void tryToSetActive(bool, SetActiveCompletion&&);
+
+    RemoteAudioSessionProxyManager& audioSessionManager();
+    IPC::Connection& connection();
+
+    GPUConnectionToWebProcess& m_gpuConnection;
+    WebCore::AudioSession::CategoryType m_category;
+    WebCore::RouteSharingPolicy m_routeSharingPolicy;
+    size_t m_preferredBufferSize { 0 };
+    bool m_active { false };
+};
+
+}
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.messages.in (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.messages.in	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+messages -> RemoteAudioSessionProxy NotRefCounted {
+    SetCategory(enum:uint8_t WebCore::AudioSession::CategoryType type, enum:uint8_t WebCore::RouteSharingPolicy policy)
+    SetPreferredBufferSize(uint64_t preferredBufferSize)
+    TryToSetActive(bool active) -> (bool suceeded) Synchronous
+}
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include "config.h"
+#include "RemoteAudioSessionProxyManager.h"
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include "RemoteAudioSessionProxy.h"
+#include <WebCore/AudioSession.h>
+#include <wtf/HashCountedSet.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+static bool categoryCanMixWithOthers(AudioSession::CategoryType category)
+{
+    return category == AudioSession::AmbientSound;
+}
+
+RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager()
+    : m_session(AudioSession::create())
+{
+}
+
+RemoteAudioSessionProxyManager::~RemoteAudioSessionProxyManager() = default;
+
+void RemoteAudioSessionProxyManager::addProxy(WeakPtr<RemoteAudioSessionProxy>&& proxy)
+{
+    auto id = proxy->processIdentifier();
+    ASSERT(!m_proxies.contains(id));
+    m_proxies.set(id, WTFMove(proxy));
+}
+
+void RemoteAudioSessionProxyManager::removeProxy(const ProcessIdentifier& id)
+{
+    ASSERT(m_proxies.contains(id));
+    m_proxies.remove(id);
+}
+
+RemoteAudioSessionProxy* RemoteAudioSessionProxyManager::getProxy(const ProcessIdentifier& id)
+{
+    auto results = m_proxies.find(id);
+    if (results != m_proxies.end())
+        return results->value.get();
+    return nullptr;
+}
+
+void RemoteAudioSessionProxyManager::setCategoryForProcess(const ProcessIdentifier& id, AudioSession::CategoryType category, RouteSharingPolicy policy)
+{
+    ASSERT(m_proxies.contains(id));
+    auto proxy = getProxy(id);
+    if (!proxy)
+        return;
+
+    if (proxy->category() == category && proxy->routeSharingPolicy() == policy)
+        return;
+
+    HashCountedSet<AudioSession::CategoryType, WTF::IntHash<AudioSession::CategoryType>, WTF::StrongEnumHashTraits<AudioSession::CategoryType>> categoryCounts;
+    HashCountedSet<RouteSharingPolicy, WTF::IntHash<RouteSharingPolicy>, WTF::StrongEnumHashTraits<RouteSharingPolicy>> policyCounts;
+    for (auto& otherProxy : m_proxies.values()) {
+        categoryCounts.add(otherProxy->category());
+        policyCounts.add(otherProxy->routeSharingPolicy());
+    }
+
+    if (categoryCounts.contains(AudioSession::PlayAndRecord))
+        category = AudioSession::PlayAndRecord;
+    else if (categoryCounts.contains(AudioSession::RecordAudio))
+        category = AudioSession::RecordAudio;
+    else if (categoryCounts.contains(AudioSession::MediaPlayback))
+        category = AudioSession::MediaPlayback;
+    else if (categoryCounts.contains(AudioSession::SoloAmbientSound))
+        category = AudioSession::SoloAmbientSound;
+    else if (categoryCounts.contains(AudioSession::AmbientSound))
+        category = AudioSession::AmbientSound;
+    else if (categoryCounts.contains(AudioSession::AudioProcessing))
+        category = AudioSession::AudioProcessing;
+    else
+        category = AudioSession::None;
+
+    if (policyCounts.contains(RouteSharingPolicy::LongFormVideo))
+        policy = RouteSharingPolicy::LongFormVideo;
+    else if (policyCounts.contains(RouteSharingPolicy::LongFormAudio))
+        policy = RouteSharingPolicy::LongFormAudio;
+    else if (policyCounts.contains(RouteSharingPolicy::Independent))
+        policy = RouteSharingPolicy::Independent;
+    else
+        policy = RouteSharingPolicy::Default;
+
+    m_session->setCategory(category, policy);
+}
+
+void RemoteAudioSessionProxyManager::setPreferredBufferSizeForProcess(const ProcessIdentifier& id, size_t preferredBufferSize)
+{
+    for (auto& otherProxy : m_proxies.values()) {
+        if (!otherProxy)
+            continue;
+        if (otherProxy->preferredBufferSize() < preferredBufferSize)
+            preferredBufferSize = otherProxy->preferredBufferSize();
+    }
+
+    m_session->setPreferredBufferSize(preferredBufferSize);
+}
+
+bool RemoteAudioSessionProxyManager::tryToSetActiveForProcess(const ProcessIdentifier& id, bool active)
+{
+    ASSERT(m_proxies.contains(id));
+    auto proxy = getProxy(id);
+    if (!proxy)
+        return false;
+
+    size_t activeProxyCount { 0 };
+    for (auto& otherProxy : m_proxies.values()) {
+        if (!otherProxy)
+            continue;
+        if (otherProxy->isActive())
+            ++activeProxyCount;
+    }
+
+    if (!active && activeProxyCount > 1) {
+        // This proxy wants to de-activate, but other proxies are still
+        // active. No-op, and return deactivation was sucessful.
+        return true;
+    }
+
+    if (!active) {
+        // This proxy wants to de-activate, and is the last remaining active
+        // proxy. Deactivate the session, and return whether that deactivation
+        // was sucessful;
+        return m_session->tryToSetActive(false);
+    }
+
+    if (active && !activeProxyCount) {
+        // This proxy and only this proxy wants to become active. Activate
+        // the session, and return whether that activation was successful.
+        return m_session->tryToSetActive(active);
+    }
+
+    // If this proxy is Ambient, and the session is already active, this
+    // proxy will mix with the active proxies. No-op, and return activation
+    // was sucessful.
+    if (categoryCanMixWithOthers(proxy->category()))
+        return true;
+
+#if PLATFORM(IOS_FAMILY)
+    // Otherwise, this proxy wants to become active, but there are other
+    // proxies who are already active. Walk over the proxies, and interrupt
+    // those proxies whose cateogries indicate they cannot mix with others.
+    for (auto& otherProxy : m_proxies.values()) {
+        if (!otherProxy)
+            continue;
+        if (!otherProxy->isActive())
+            continue;
+
+        if (categoryCanMixWithOthers(otherProxy->category()))
+            continue;
+
+        otherProxy->beginInterruption(PlatformMediaSession::InterruptionType::SystemInterruption);
+    }
+#endif
+
+    return true;
+
+}
+
+}
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include <WebCore/AudioSession.h>
+#include <WebCore/ProcessIdentifier.h>
+
+namespace WebKit {
+
+class RemoteAudioSessionProxy;
+
+class RemoteAudioSessionProxyManager
+    : public CanMakeWeakPtr<RemoteAudioSessionProxyManager> {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    RemoteAudioSessionProxyManager();
+    ~RemoteAudioSessionProxyManager();
+
+    void addProxy(WeakPtr<RemoteAudioSessionProxy>&&);
+    void removeProxy(const WebCore::ProcessIdentifier&);
+    RemoteAudioSessionProxy* getProxy(const WebCore::ProcessIdentifier&);
+
+    void setCategoryForProcess(const WebCore::ProcessIdentifier&, WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
+    void setPreferredBufferSizeForProcess(const WebCore::ProcessIdentifier&, size_t);
+
+    bool tryToSetActiveForProcess(const WebCore::ProcessIdentifier&, bool);
+
+    const WebCore::AudioSession& session() const { return m_session; }
+
+private:
+    UniqueRef<WebCore::AudioSession> m_session;
+    HashMap<WebCore::ProcessIdentifier, WeakPtr<RemoteAudioSessionProxy>> m_proxies;
+};
+
+}
+
+#endif

Added: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.messages.in (0 => 257936)


--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.messages.in	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,25 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+

Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (257935 => 257936)


--- trunk/Source/WebKit/Scripts/webkit/messages.py	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py	2020-03-05 19:43:12 UTC (rev 257936)
@@ -234,6 +234,7 @@
         'WebKit::MediaPlayerPrivateRemoteIdentifier',
         'WebKit::MediaRecorderIdentifier',
         'WebKit::RemoteAudioDestinationIdentifier',
+        'WebKit::RemoteAudioSessionIdentifier',
         'WebKit::RemoteCDMIdentifier',
         'WebKit::RemoteCDMInstanceIdentifier',
         'WebKit::RemoteCDMInstanceSessionIdentifier',

Modified: trunk/Source/WebKit/Shared/WebProcessCreationParameters.h (257935 => 257936)


--- trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/Shared/WebProcessCreationParameters.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -124,6 +124,7 @@
     bool fullKeyboardAccessEnabled { false };
     bool memoryCacheDisabled { false };
     bool attrStyleEnabled { false };
+    bool useGPUProcessForMedia { false };
 
 #if ENABLE(SERVICE_CONTROLS)
     bool hasImageServices { false };

Modified: trunk/Source/WebKit/Sources.txt (257935 => 257936)


--- trunk/Source/WebKit/Sources.txt	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/Sources.txt	2020-03-05 19:43:12 UTC (rev 257936)
@@ -26,6 +26,8 @@
 GPUProcess/GPUProcessCreationParameters.cpp
 GPUProcess/graphics/RemoteImageBufferMessageHandlerProxy.cpp
 GPUProcess/graphics/RemoteRenderingBackendProxy.cpp
+GPUProcess/media/RemoteAudioSessionProxy.cpp
+GPUProcess/media/RemoteAudioSessionProxyManager.cpp
 GPUProcess/media/RemoteAudioTrackProxy.cpp
 GPUProcess/media/RemoteCDMFactoryProxy.cpp
 GPUProcess/media/RemoteCDMInstanceProxy.cpp
@@ -547,6 +549,7 @@
 WebProcess/GPU/media/AudioTrackPrivateRemote.cpp
 WebProcess/GPU/media/MediaPlayerPrivateRemote.cpp
 WebProcess/GPU/media/RemoteAudioDestinationProxy.cpp
+WebProcess/GPU/media/RemoteAudioSession.cpp
 WebProcess/GPU/media/RemoteCDM.cpp
 WebProcess/GPU/media/RemoteCDMFactory.cpp
 WebProcess/GPU/media/RemoteCDMInstance.cpp

Modified: trunk/Source/WebKit/SourcesCocoa.txt (257935 => 257936)


--- trunk/Source/WebKit/SourcesCocoa.txt	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2020-03-05 19:43:12 UTC (rev 257936)
@@ -656,6 +656,8 @@
 LibWebRTCCodecsMessageReceiver.cpp
 RemoteAudioDestinationManagerMessageReceiver.cpp
 RemoteAudioDestinationProxyMessageReceiver.cpp
+RemoteAudioSessionMessageReceiver.cpp
+RemoteAudioSessionProxyMessageReceiver.cpp
 RemoteAudioMediaStreamTrackRendererManagerMessageReceiver.cpp
 RemoteAudioMediaStreamTrackRendererMessageReceiver.cpp
 RemoteMediaRecorderMessageReceiver.cpp

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (257935 => 257936)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2020-03-05 19:43:12 UTC (rev 257936)
@@ -1745,6 +1745,7 @@
 		CDAC20F823FC726C0021DEE3 /* RemoteCDMInstanceProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAC20F523FC383B0021DEE3 /* RemoteCDMInstanceProxyMessageReceiver.cpp */; };
 		CDAC20F923FC726C0021DEE3 /* RemoteCDMInstanceSessionProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAC20EC23FC38380021DEE3 /* RemoteCDMInstanceSessionProxyMessageReceiver.cpp */; };
 		CDAC20FA23FC726C0021DEE3 /* RemoteCDMProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDAC20EF23FC38390021DEE3 /* RemoteCDMProxyMessageReceiver.cpp */; };
+		CDBB49FD240D9A720017C292 /* RemoteAudioSessionConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = CDBB49FC240D9A720017C292 /* RemoteAudioSessionConfiguration.h */; };
 		CDC2831D201BD79D00E6E745 /* WKFullscreenStackView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */; };
 		CDCA85C9132ABA4E00E961DF /* WKFullScreenWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */; };
 		CE11AD521CBC482F00681EE5 /* CodeSigning.h in Headers */ = {isa = PBXBuildFile; fileRef = CE11AD511CBC482F00681EE5 /* CodeSigning.h */; };
@@ -5103,6 +5104,15 @@
 		CDAC20F423FC383A0021DEE3 /* RemoteCDMProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCDMProxyMessages.h; sourceTree = "<group>"; };
 		CDAC20F523FC383B0021DEE3 /* RemoteCDMInstanceProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteCDMInstanceProxyMessageReceiver.cpp; sourceTree = "<group>"; };
 		CDAC20F623FC383B0021DEE3 /* RemoteCDMInstanceProxyMessagesReplies.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RemoteCDMInstanceProxyMessagesReplies.h; sourceTree = "<group>"; };
+		CDBB49F4240D8AC60017C292 /* RemoteAudioSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSession.h; sourceTree = "<group>"; };
+		CDBB49F5240D8AC60017C292 /* RemoteAudioSession.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSession.cpp; sourceTree = "<group>"; };
+		CDBB49F6240D8C950017C292 /* RemoteAudioSessionProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxy.h; sourceTree = "<group>"; };
+		CDBB49F7240D8C950017C292 /* RemoteAudioSessionProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSessionProxy.cpp; sourceTree = "<group>"; };
+		CDBB49F8240D8D530017C292 /* RemoteAudioSessionProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioSessionProxy.messages.in; sourceTree = "<group>"; };
+		CDBB49F9240D963C0017C292 /* RemoteAudioSessionProxyManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxyManager.h; sourceTree = "<group>"; };
+		CDBB49FA240D963D0017C292 /* RemoteAudioSessionProxyManager.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSessionProxyManager.cpp; sourceTree = "<group>"; };
+		CDBB49FB240D974A0017C292 /* RemoteAudioSessionIdentifier.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionIdentifier.h; sourceTree = "<group>"; };
+		CDBB49FC240D9A720017C292 /* RemoteAudioSessionConfiguration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionConfiguration.h; sourceTree = "<group>"; };
 		CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFullscreenStackView.h; path = ios/fullscreen/WKFullscreenStackView.h; sourceTree = "<group>"; };
 		CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFullscreenStackView.mm; path = ios/fullscreen/WKFullscreenStackView.mm; sourceTree = "<group>"; };
 		CDC382F717211506008A2FC3 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = /System/Library/Frameworks/CFNetwork.framework; sourceTree = "<absolute>"; };
@@ -5110,6 +5120,17 @@
 		CDCA85C6132ABA4E00E961DF /* WKFullScreenWindowController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKFullScreenWindowController.mm; sourceTree = "<group>"; };
 		CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKFullScreenWindowController.h; sourceTree = "<group>"; };
 		CDCA85D4132AC2B300E961DF /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = "<absolute>"; };
+		CDD5356F240DD34300F7B8C4 /* RemoteAudioSession.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioSession.messages.in; sourceTree = "<group>"; };
+		CDD53570240DD4EF00F7B8C4 /* RemoteAudioSessionProxyManager.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteAudioSessionProxyManager.messages.in; sourceTree = "<group>"; };
+		CDD53571240DDE0600F7B8C4 /* RemoteAudioSessionProxyMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSessionProxyMessageReceiver.cpp; sourceTree = "<group>"; };
+		CDD53572240DDE0600F7B8C4 /* RemoteAudioSessionProxyMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxyMessages.h; sourceTree = "<group>"; };
+		CDD53573240DDE0600F7B8C4 /* RemoteAudioSessionProxyManagerMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSessionProxyManagerMessageReceiver.cpp; sourceTree = "<group>"; };
+		CDD53574240DDE0700F7B8C4 /* RemoteAudioSessionMessagesReplies.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionMessagesReplies.h; sourceTree = "<group>"; };
+		CDD53575240DDE0700F7B8C4 /* RemoteAudioSessionMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionMessages.h; sourceTree = "<group>"; };
+		CDD53576240DDE0700F7B8C4 /* RemoteAudioSessionMessageReceiver.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteAudioSessionMessageReceiver.cpp; sourceTree = "<group>"; };
+		CDD53577240DDE0700F7B8C4 /* RemoteAudioSessionProxyMessagesReplies.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxyMessagesReplies.h; sourceTree = "<group>"; };
+		CDD53578240DDE0800F7B8C4 /* RemoteAudioSessionProxyManagerMessages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxyManagerMessages.h; sourceTree = "<group>"; };
+		CDD53579240DDE0800F7B8C4 /* RemoteAudioSessionProxyManagerMessagesReplies.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteAudioSessionProxyManagerMessagesReplies.h; sourceTree = "<group>"; };
 		CE11AD4F1CBC47F800681EE5 /* CodeSigning.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CodeSigning.mm; sourceTree = "<group>"; };
 		CE11AD511CBC482F00681EE5 /* CodeSigning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CodeSigning.h; sourceTree = "<group>"; };
 		CE1A0BCC1A48E6C60054EF74 /* AssertionServicesSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AssertionServicesSPI.h; sourceTree = "<group>"; };
@@ -5389,6 +5410,11 @@
 				9B5BEC29240101580070C6EF /* RemoteAudioDestinationProxy.cpp */,
 				9B5BEC28240101580070C6EF /* RemoteAudioDestinationProxy.h */,
 				9B5BEC2E2401018C0070C6EF /* RemoteAudioDestinationProxy.messages.in */,
+				CDBB49F5240D8AC60017C292 /* RemoteAudioSession.cpp */,
+				CDBB49F4240D8AC60017C292 /* RemoteAudioSession.h */,
+				CDD5356F240DD34300F7B8C4 /* RemoteAudioSession.messages.in */,
+				CDBB49FC240D9A720017C292 /* RemoteAudioSessionConfiguration.h */,
+				CDBB49FB240D974A0017C292 /* RemoteAudioSessionIdentifier.h */,
 				CDAC20BF23FC2F750021DEE3 /* RemoteCDM.cpp */,
 				CDAC20BA23FC2F740021DEE3 /* RemoteCDM.h */,
 				CDAC20B823FC2F730021DEE3 /* RemoteCDMConfiguration.h */,
@@ -5431,6 +5457,12 @@
 				9B1229CC23FF25F2008CA751 /* RemoteAudioDestinationManager.cpp */,
 				9B1229CB23FF25F2008CA751 /* RemoteAudioDestinationManager.h */,
 				9B1229CF23FF2814008CA751 /* RemoteAudioDestinationManager.messages.in */,
+				CDBB49F7240D8C950017C292 /* RemoteAudioSessionProxy.cpp */,
+				CDBB49F6240D8C950017C292 /* RemoteAudioSessionProxy.h */,
+				CDBB49F8240D8D530017C292 /* RemoteAudioSessionProxy.messages.in */,
+				CDBB49FA240D963D0017C292 /* RemoteAudioSessionProxyManager.cpp */,
+				CDBB49F9240D963C0017C292 /* RemoteAudioSessionProxyManager.h */,
+				CDD53570240DD4EF00F7B8C4 /* RemoteAudioSessionProxyManager.messages.in */,
 				071BC57E23CA5DB100680D7C /* RemoteAudioTrackProxy.cpp */,
 				071BC57F23CA5DB100680D7C /* RemoteAudioTrackProxy.h */,
 				CDAC207923FB1E210021DEE3 /* RemoteCDMFactoryProxy.cpp */,
@@ -9850,6 +9882,15 @@
 				1A043B5C124D5E9D00FFBFB5 /* PluginProcessProxyMessages.h */,
 				1A8EFA6E1252B84100F7067F /* PluginProxyMessageReceiver.cpp */,
 				1A8EFA6F1252B84100F7067F /* PluginProxyMessages.h */,
+				CDD53576240DDE0700F7B8C4 /* RemoteAudioSessionMessageReceiver.cpp */,
+				CDD53575240DDE0700F7B8C4 /* RemoteAudioSessionMessages.h */,
+				CDD53574240DDE0700F7B8C4 /* RemoteAudioSessionMessagesReplies.h */,
+				CDD53573240DDE0600F7B8C4 /* RemoteAudioSessionProxyManagerMessageReceiver.cpp */,
+				CDD53578240DDE0800F7B8C4 /* RemoteAudioSessionProxyManagerMessages.h */,
+				CDD53579240DDE0800F7B8C4 /* RemoteAudioSessionProxyManagerMessagesReplies.h */,
+				CDD53571240DDE0600F7B8C4 /* RemoteAudioSessionProxyMessageReceiver.cpp */,
+				CDD53572240DDE0600F7B8C4 /* RemoteAudioSessionProxyMessages.h */,
+				CDD53577240DDE0700F7B8C4 /* RemoteAudioSessionProxyMessagesReplies.h */,
 				CDAC20F223FC383A0021DEE3 /* RemoteCDMFactoryProxyMessageReceiver.cpp */,
 				CDAC20F323FC383A0021DEE3 /* RemoteCDMFactoryProxyMessages.h */,
 				CDAC20EE23FC38390021DEE3 /* RemoteCDMFactoryProxyMessagesReplies.h */,
@@ -10773,6 +10814,7 @@
 				9B1229D223FF2BCC008CA751 /* RemoteAudioDestinationIdentifier.h in Headers */,
 				9B1229CD23FF25F2008CA751 /* RemoteAudioDestinationManager.h in Headers */,
 				9B5BEC2A240101580070C6EF /* RemoteAudioDestinationProxy.h in Headers */,
+				CDBB49FD240D9A720017C292 /* RemoteAudioSessionConfiguration.h in Headers */,
 				CDAC20C723FC2F750021DEE3 /* RemoteCDM.h in Headers */,
 				CDAC20C523FC2F750021DEE3 /* RemoteCDMConfiguration.h in Headers */,
 				CDAC20CD23FC2F750021DEE3 /* RemoteCDMFactory.h in Headers */,

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp (0 => 257936)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,99 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#include "config.h"
+#include "RemoteAudioSession.h"
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include "GPUConnectionToWebProcessMessages.h"
+#include "GPUProcessProxy.h"
+#include "RemoteAudioSessionProxyMessages.h"
+#include <WebCore/PlatformMediaSessionManager.h>
+
+namespace WebKit {
+
+using namespace WebCore;
+
+UniqueRef<RemoteAudioSession> RemoteAudioSession::create(WebProcess& process)
+{
+    RemoteAudioSessionConfiguration configuration;
+    process.ensureGPUProcessConnection().connection().sendSync(Messages::GPUConnectionToWebProcess::EnsureAudioSession(), Messages::GPUConnectionToWebProcess::EnsureAudioSession::Reply(configuration), { });
+    return makeUniqueRef<RemoteAudioSession>(process, WTFMove(configuration));
+}
+
+RemoteAudioSession::RemoteAudioSession(WebProcess& process, RemoteAudioSessionConfiguration&& configuration)
+    : m_process(process)
+    , m_configuration(WTFMove(configuration))
+{
+}
+
+RemoteAudioSession::~RemoteAudioSession() = default;
+
+IPC::Connection& RemoteAudioSession::connection()
+{
+    return m_process.ensureGPUProcessConnection().connection();
+}
+
+void RemoteAudioSession::setCategory(CategoryType type, RouteSharingPolicy policy)
+{
+    connection().send(Messages::RemoteAudioSessionProxy::SetCategory(type, policy), { });
+}
+
+void RemoteAudioSession::setPreferredBufferSize(size_t size)
+{
+    connection().send(Messages::RemoteAudioSessionProxy::SetPreferredBufferSize(size), { });
+}
+
+bool RemoteAudioSession::tryToSetActiveInternal(bool active)
+{
+    bool succeeded;
+    connection().sendSync(Messages::RemoteAudioSessionProxy::TryToSetActive(active), Messages::RemoteAudioSessionProxy::TryToSetActive::Reply(succeeded), { });
+    return succeeded;
+}
+
+void RemoteAudioSession::configurationChanged(RemoteAudioSessionConfiguration&& configuration)
+{
+    bool mutedStateChanged = configuration.isMuted != m_configuration.isMuted;
+
+    m_configuration = configuration;
+
+    if (mutedStateChanged)
+        handleMutedStateChange();
+}
+
+void RemoteAudioSession::beginInterruption(PlatformMediaSession::InterruptionType type)
+{
+    PlatformMediaSessionManager::sharedManager().beginInterruption(type);
+}
+
+void RemoteAudioSession::endInterruption(PlatformMediaSession::EndInterruptionFlags flags)
+{
+    PlatformMediaSessionManager::sharedManager().endInterruption(flags);
+}
+
+}
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.h (0 => 257936)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include "MessageReceiver.h"
+#include "RemoteAudioSessionConfiguration.h"
+#include <WebCore/AudioSession.h>
+#include <WebCore/PlatformMediaSession.h>
+
+namespace IPC {
+class Connection;
+}
+
+namespace WebKit {
+
+class GPUProcessConnection;
+class WebProcess;
+
+class RemoteAudioSession final
+    : public WebCore::AudioSession
+    , IPC::MessageReceiver {
+    WTF_MAKE_FAST_ALLOCATED;
+public:
+    static UniqueRef<RemoteAudioSession> create(WebProcess&);
+    virtual ~RemoteAudioSession();
+
+private:
+    friend UniqueRef<RemoteAudioSession> WTF::makeUniqueRefWithoutFastMallocCheck<RemoteAudioSession>(WebProcess&, RemoteAudioSessionConfiguration&&);
+    RemoteAudioSession(WebProcess&, RemoteAudioSessionConfiguration&&);
+    IPC::Connection& connection();
+
+    // IPC::MessageReceiver
+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
+
+    // Messages
+    void configurationChanged(RemoteAudioSessionConfiguration&&);
+    void beginInterruption(WebCore::PlatformMediaSession::InterruptionType);
+    void endInterruption(WebCore::PlatformMediaSession::EndInterruptionFlags);
+
+    // AudioSession
+    void setCategory(CategoryType, WebCore::RouteSharingPolicy) final;
+    void setPreferredBufferSize(size_t) final;
+    bool tryToSetActiveInternal(bool) final;
+
+    CategoryType category() const final { return m_configuration.category; }
+    WebCore::RouteSharingPolicy routeSharingPolicy() const final { return m_configuration.routeSharingPolicy; }
+    String routingContextUID() const final { return m_configuration.routingContextUID; }
+    float sampleRate() const final { return m_configuration.sampleRate; }
+    size_t bufferSize() const final { return m_configuration.bufferSize; }
+    size_t numberOfOutputChannels() const final { return m_configuration.numberOfOutputChannels; }
+    size_t preferredBufferSize() const final { return m_configuration.preferredBufferSize; }
+    bool isMuted() const final { return m_configuration.isMuted; }
+    bool isActive() const final { return m_configuration.isActive; }
+
+    WebProcess& m_process;
+    RemoteAudioSessionConfiguration m_configuration;
+};
+
+}
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.messages.in (0 => 257936)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.messages.in	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSession.messages.in	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2020 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.
+ */
+
+#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+messages -> RemoteAudioSession NotRefCounted {
+    ConfigurationChanged(struct WebKit::RemoteAudioSessionConfiguration configuration)
+    BeginInterruption(enum:uint8_t WebCore::PlatformMediaSession::InterruptionType type)
+    EndInterruption(enum:uint8_t WebCore::PlatformMediaSession::EndInterruptionFlags flags)
+}
+
+#endif

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionConfiguration.h (0 => 257936)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionConfiguration.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionConfiguration.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include <WebCore/AudioSession.h>
+
+namespace WebKit {
+
+struct RemoteAudioSessionConfiguration {
+
+    WebCore::AudioSession::CategoryType category { WebCore::AudioSession::CategoryType::None };
+    WebCore::RouteSharingPolicy routeSharingPolicy { WebCore::RouteSharingPolicy::Default };
+    String routingContextUID;
+    float sampleRate { 0 };
+    uint64_t bufferSize { 0 };
+    uint64_t numberOfOutputChannels { 0 };
+    uint64_t preferredBufferSize { 0 };
+    bool isMuted { false };
+    bool isActive { false };
+
+    template<class Encoder>
+    void encode(Encoder& encoder) const
+    {
+        encoder << category;
+        encoder << routeSharingPolicy;
+        encoder << routingContextUID;
+        encoder << sampleRate;
+        encoder << bufferSize;
+        encoder << numberOfOutputChannels;
+        encoder << preferredBufferSize;
+        encoder << isMuted;
+        encoder << isActive;
+    }
+
+    template <class Decoder>
+    static Optional<RemoteAudioSessionConfiguration> decode(Decoder& decoder)
+    {
+        Optional<WebCore::AudioSession::CategoryType> category;
+        decoder >> category;
+        if (!category)
+            return WTF::nullopt;
+
+        Optional<WebCore::RouteSharingPolicy> routeSharingPolicy;
+        decoder >> routeSharingPolicy;
+        if (!routeSharingPolicy)
+            return WTF::nullopt;
+
+        Optional<String> routingContextUID;
+        decoder >> routingContextUID;
+        if (!routingContextUID)
+            return WTF::nullopt;
+
+        Optional<float> sampleRate;
+        decoder >> sampleRate;
+        if (!sampleRate)
+            return WTF::nullopt;
+
+        Optional<uint64_t> bufferSize;
+        decoder >> bufferSize;
+        if (!bufferSize)
+            return WTF::nullopt;
+
+        Optional<uint64_t> numberOfOutputChannels;
+        decoder >> numberOfOutputChannels;
+        if (!numberOfOutputChannels)
+            return WTF::nullopt;
+
+        Optional<uint64_t> preferredBufferSize;
+        decoder >> preferredBufferSize;
+        if (!preferredBufferSize)
+            return WTF::nullopt;
+
+        Optional<bool> isMuted;
+        decoder >> isMuted;
+        if (!isMuted)
+            return WTF::nullopt;
+
+        Optional<bool> isActive;
+        decoder >> isActive;
+        if (!isActive)
+            return WTF::nullopt;
+
+        return {{
+            WTFMove(*category),
+            WTFMove(*routeSharingPolicy),
+            WTFMove(*routingContextUID),
+            *sampleRate,
+            *bufferSize,
+            *numberOfOutputChannels,
+            *preferredBufferSize,
+            *isMuted,
+            *isActive,
+        }};
+    }
+};
+
+} // namespace WebKit
+
+#endif
+

Added: trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionIdentifier.h (0 => 257936)


--- trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionIdentifier.h	                        (rev 0)
+++ trunk/Source/WebKit/WebProcess/GPU/media/RemoteAudioSessionIdentifier.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 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 ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
+
+#include <wtf/ObjectIdentifier.h>
+
+namespace WebKit {
+
+enum RemoteAudioSessionIdentifierType { };
+using RemoteAudioSessionIdentifier = ObjectIdentifier<RemoteAudioSessionIdentifierType>;
+
+} // namespace WebKit
+
+#endif

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (257935 => 257936)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2020-03-05 19:43:12 UTC (rev 257936)
@@ -42,6 +42,7 @@
 #include "NetworkSession.h"
 #include "NetworkSessionCreationParameters.h"
 #include "PluginProcessConnectionManager.h"
+#include "RemoteAudioSession.h"
 #include "StatisticsData.h"
 #include "StorageAreaMap.h"
 #include "UserData.h"
@@ -471,6 +472,8 @@
     WebResourceLoadObserver::setShouldLogUserInteraction(parameters.shouldLogUserInteraction);
 #endif
 
+    setUseGPUProcessForMedia(parameters.useGPUProcessForMedia);
+
     RELEASE_LOG_IF_ALLOWED(Process, "initializeWebProcess: Presenting process = %d", WebCore::presentingApplicationPID());
 }
 
@@ -1997,6 +2000,21 @@
 }
 #endif
 
+void WebProcess::setUseGPUProcessForMedia(bool useGPUProcessForMedia)
+{
+    if (useGPUProcessForMedia == m_useGPUProcessForMedia)
+        return;
+
+    m_useGPUProcessForMedia = useGPUProcessForMedia;
+
+#if USE(AUDIO_SESSION)
+    if (useGPUProcessForMedia)
+        AudioSession::setSharedSession(RemoteAudioSession::create(*this));
+    else
+        AudioSession::setSharedSession(AudioSession::create());
+#endif
+}
+
 } // namespace WebKit
 
 #undef RELEASE_LOG_SESSION_ID

Modified: trunk/Source/WebKit/WebProcess/WebProcess.h (257935 => 257936)


--- trunk/Source/WebKit/WebProcess/WebProcess.h	2020-03-05 19:12:16 UTC (rev 257935)
+++ trunk/Source/WebKit/WebProcess/WebProcess.h	2020-03-05 19:43:12 UTC (rev 257936)
@@ -517,6 +517,8 @@
 
     bool isAlwaysOnLoggingAllowed() { return m_sessionID ? m_sessionID->isAlwaysOnLoggingAllowed() : true; }
 
+    void setUseGPUProcessForMedia(bool);
+
     RefPtr<WebConnectionToUIProcess> m_webConnection;
 
     HashMap<WebCore::PageIdentifier, RefPtr<WebPage>> m_pageMap;
@@ -653,6 +655,8 @@
     RefPtr<SandboxExtension> m_assetServiceExtension;
     RefPtr<SandboxExtension> m_assetServiceV2Extension;
 #endif
+
+    bool m_useGPUProcessForMedia { false };
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to