Diff
Modified: trunk/Source/WebCore/ChangeLog (258265 => 258266)
--- trunk/Source/WebCore/ChangeLog 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/ChangeLog 2020-03-11 16:50:10 UTC (rev 258266)
@@ -1,3 +1,17 @@
+2020-03-11 Commit Queue <[email protected]>
+
+ Unreviewed, reverting r258263.
+ https://bugs.webkit.org/show_bug.cgi?id=208922
+
+ it is breaking internal builds (Requested by youenn on
+ #webkit).
+
+ Reverted changeset:
+
+ "Move AudioSession interruption listener code to AudioSession"
+ https://bugs.webkit.org/show_bug.cgi?id=208714
+ https://trac.webkit.org/changeset/258263
+
2020-03-11 youenn fablet <[email protected]>
Move AudioSession interruption listener code to AudioSession
Modified: trunk/Source/WebCore/platform/audio/AudioSession.cpp (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/AudioSession.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/AudioSession.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -63,24 +63,6 @@
return true;
}
-#if !PLATFORM(IOS)
-void AudioSession::addInterruptionObserver(InterruptionObserver&)
-{
-}
-
-void AudioSession::removeInterruptionObserver(InterruptionObserver&)
-{
-}
-
-void AudioSession::beginInterruption(PlatformMediaSession::InterruptionType)
-{
-}
-
-void AudioSession::endInterruption(PlatformMediaSession::EndInterruptionFlags)
-{
-}
-#endif
-
#if !PLATFORM(COCOA)
class AudioSessionPrivate {
WTF_MAKE_FAST_ALLOCATED;
Modified: trunk/Source/WebCore/platform/audio/AudioSession.h (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/AudioSession.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/AudioSession.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -27,12 +27,11 @@
#if USE(AUDIO_SESSION)
-#include "PlatformMediaSession.h"
#include <memory>
+#include <wtf/HashSet.h>
#include <wtf/NeverDestroyed.h>
#include <wtf/Noncopyable.h>
#include <wtf/UniqueRef.h>
-#include <wtf/WeakHashSet.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -94,19 +93,6 @@
void addMutedStateObserver(MutedStateObserver*);
void removeMutedStateObserver(MutedStateObserver*);
- class InterruptionObserver : public CanMakeWeakPtr<InterruptionObserver> {
- public:
- virtual ~InterruptionObserver() = default;
-
- // FIXME: Remove use of InterruptionType and EndInterruptionFlags in this interface.
- virtual void beginAudioSessionInterruption(PlatformMediaSession::InterruptionType) = 0;
- virtual void endAudioSessionInterruption(PlatformMediaSession::EndInterruptionFlags) = 0;
- };
- void addInterruptionObserver(InterruptionObserver&);
- void removeInterruptionObserver(InterruptionObserver&);
- void beginInterruption(PlatformMediaSession::InterruptionType);
- void endInterruption(PlatformMediaSession::EndInterruptionFlags);
-
virtual bool isMuted() const;
virtual void handleMutedStateChange();
@@ -120,9 +106,6 @@
std::unique_ptr<AudioSessionPrivate> m_private;
HashSet<MutedStateObserver*> m_observers;
-#if PLATFORM(IOS)
- WeakHashSet<InterruptionObserver> m_interruptionObservers;
-#endif
bool m_active { false }; // Used only for testing.
};
Modified: trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/ios/AudioSessionIOS.mm 2020-03-11 16:50:10 UTC (rev 258266)
@@ -32,71 +32,11 @@
#import <AVFoundation/AVAudioSession.h>
#import <objc/runtime.h>
#import <pal/spi/cocoa/AVFoundationSPI.h>
-#import <wtf/BlockObjCExceptions.h>
#import <wtf/OSObjectPtr.h>
#import <wtf/RetainPtr.h>
#import <pal/cocoa/AVFoundationSoftLink.h>
-@interface WebInterruptionObserverHelper : NSObject {
- WebCore::AudioSession* _callback;
-}
-
-- (id)initWithCallback:(WebCore::AudioSession*)callback;
-- (void)clearCallback;
-- (void)interruption:(NSNotification *)notification;
-@end
-
-@implementation WebInterruptionObserverHelper
-
-- (id)initWithCallback:(WebCore::AudioSession*)callback
-{
- if (!(self = [super init]))
- return nil;
-
- _callback = callback;
-
- NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
- [center addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:[PAL::getAVAudioSessionClass() sharedInstance]];
-
- return self;
-}
-
-- (void)dealloc
-{
- [[NSNotificationCenter defaultCenter] removeObserver:self];
- [super dealloc];
-}
-
-- (void)clearCallback
-{
- _callback = nil;
-}
-
-- (void)interruption:(NSNotification *)notification
-{
- if (!_callback)
- return;
-
- NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
- WebCore::PlatformMediaSession::EndInterruptionFlags flags = WebCore::PlatformMediaSession::NoFlags;
-
- if (type == AVAudioSessionInterruptionTypeEnded && [[[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey] unsignedIntegerValue] == AVAudioSessionInterruptionOptionShouldResume)
- flags = WebCore::PlatformMediaSession::MayResumePlaying;
-
- callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), type, flags]() mutable {
- auto* callback = protectedSelf->_callback;
- if (!callback)
- return;
-
- if (type == AVAudioSessionInterruptionTypeBegan)
- callback->beginInterruption(WebCore::PlatformMediaSession::SystemInterruption);
- else
- callback->endInterruption(flags);
- });
-}
-@end
-
namespace WebCore {
#if !LOG_DISABLED
@@ -121,27 +61,16 @@
class AudioSessionPrivate {
WTF_MAKE_FAST_ALLOCATED;
public:
- explicit AudioSessionPrivate(AudioSession*);
- ~AudioSessionPrivate();
-
+ AudioSessionPrivate(AudioSession*);
AudioSession::CategoryType m_categoryOverride;
OSObjectPtr<dispatch_queue_t> m_dispatchQueue;
- RetainPtr<WebInterruptionObserverHelper> m_interruptionObserverHelper;
};
-AudioSessionPrivate::AudioSessionPrivate(AudioSession* session)
+AudioSessionPrivate::AudioSessionPrivate(AudioSession*)
: m_categoryOverride(AudioSession::None)
{
- BEGIN_BLOCK_OBJC_EXCEPTIONS
- m_interruptionObserverHelper = adoptNS([[WebInterruptionObserverHelper alloc] initWithCallback:session]);
- END_BLOCK_OBJC_EXCEPTIONS
}
-AudioSessionPrivate::~AudioSessionPrivate()
-{
- [m_interruptionObserverHelper clearCallback];
-}
-
AudioSession::AudioSession()
: m_private(makeUnique<AudioSessionPrivate>(this))
{
@@ -323,28 +252,6 @@
{
}
-void AudioSession::addInterruptionObserver(InterruptionObserver& observer)
-{
- m_interruptionObservers.add(observer);
}
-void AudioSession::removeInterruptionObserver(InterruptionObserver& observer)
-{
- m_interruptionObservers.remove(observer);
-}
-
-void AudioSession::beginInterruption(PlatformMediaSession::InterruptionType type)
-{
- for (auto& observer : m_interruptionObservers)
- observer.beginAudioSessionInterruption(type);
-}
-
-void AudioSession::endInterruption(PlatformMediaSession::EndInterruptionFlags flags)
-{
- for (auto& observer : m_interruptionObservers)
- observer.endAudioSessionInterruption(flags);
-}
-
-}
-
#endif // USE(AUDIO_SESSION) && PLATFORM(IOS_FAMILY)
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -37,6 +37,10 @@
public:
virtual ~MediaSessionHelperClient() = default;
+ enum class InterruptionType : bool { Begin, End };
+ enum class ShouldResume : bool { No, Yes };
+ virtual void receivedInterruption(InterruptionType, ShouldResume) = 0;
+
enum class SuspendedUnderLock : bool { No, Yes };
virtual void applicationWillEnterForeground(SuspendedUnderLock) = 0;
virtual void applicationDidEnterBackground(SuspendedUnderLock) = 0;
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionHelperIOS.mm 2020-03-11 16:50:10 UTC (rev 258266)
@@ -79,6 +79,7 @@
- (id)initWithCallback:(MediaSessionHelperiOS*)callback;
- (void)clearCallback;
+- (void)interruption:(NSNotification *)notification;
- (void)applicationWillEnterForeground:(NSNotification *)notification;
- (void)applicationWillResignActive:(NSNotification *)notification;
- (void)applicationDidEnterBackground:(NSNotification *)notification;
@@ -97,6 +98,7 @@
~MediaSessionHelperiOS();
void externalOutputDeviceAvailableDidChange();
+ void receivedInterruption(MediaSessionHelperClient::InterruptionType, MediaSessionHelperClient::ShouldResume);
void applicationWillEnterForeground(MediaSessionHelperClient::SuspendedUnderLock);
void applicationDidEnterBackground(MediaSessionHelperClient::SuspendedUnderLock);
void applicationWillBecomeInactive();
@@ -110,8 +112,10 @@
private:
using HasAvailableTargets = MediaSessionHelperClient::HasAvailableTargets;
+ using InterruptionType = MediaSessionHelperClient::InterruptionType;
using PlayingToAutomotiveHeadUnit = MediaSessionHelperClient::PlayingToAutomotiveHeadUnit;
using ShouldPause = MediaSessionHelperClient::ShouldPause;
+ using ShouldResume = MediaSessionHelperClient::ShouldResume;
using SupportsAirPlayVideo = MediaSessionHelperClient::SupportsAirPlayVideo;
using SuspendedUnderLock = MediaSessionHelperClient::SuspendedUnderLock;
@@ -274,6 +278,12 @@
}
#endif
+void MediaSessionHelperiOS::receivedInterruption(MediaSessionHelperClient::InterruptionType type, MediaSessionHelperClient::ShouldResume shouldResume)
+{
+ for (auto& client : m_clients)
+ client.receivedInterruption(type, shouldResume);
+}
+
void MediaSessionHelperiOS::applicationDidBecomeActive()
{
for (auto& client : m_clients)
@@ -320,6 +330,8 @@
_callback = callback;
NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
+ [center addObserver:self selector:@selector(interruption:) name:AVAudioSessionInterruptionNotification object:[PAL::getAVAudioSessionClass() sharedInstance]];
+
[center addObserver:self selector:@selector(applicationWillEnterForeground:) name:PAL::get_UIKit_UIApplicationWillEnterForegroundNotification() object:nil];
[center addObserver:self selector:@selector(applicationWillEnterForeground:) name:WebUIApplicationWillEnterForegroundNotification object:nil];
[center addObserver:self selector:@selector(applicationDidBecomeActive:) name:PAL::get_UIKit_UIApplicationDidBecomeActiveNotification() object:nil];
@@ -433,6 +445,26 @@
}
#endif // !PLATFORM(WATCHOS)
+- (void)interruption:(NSNotification *)notification
+{
+ using InterruptionType = MediaSessionHelperClient::InterruptionType;
+ using ShouldResume = MediaSessionHelperClient::ShouldResume;
+
+ NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
+ InterruptionType interruptionType = (type == AVAudioSessionInterruptionTypeEnded ? InterruptionType::End : InterruptionType::Begin);
+ ShouldResume shouldResume = ShouldResume::No;
+
+ LOG(Media, "-[WebMediaSessionHelper interruption] - type = %i", (int)type);
+
+ if (interruptionType == InterruptionType::End && [[[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey] unsignedIntegerValue] == AVAudioSessionInterruptionOptionShouldResume)
+ shouldResume = ShouldResume::Yes;
+
+ callOnWebThreadOrDispatchAsyncOnMainThread([protectedSelf = retainPtr(self), interruptionType, shouldResume]() mutable {
+ if (auto* callback = protectedSelf->_callback)
+ callback->receivedInterruption(interruptionType, shouldResume);
+ });
+}
+
- (void)applicationWillEnterForeground:(NSNotification *)notification
{
using SuspendedUnderLock = MediaSessionHelperClient::SuspendedUnderLock;
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -27,7 +27,6 @@
#if PLATFORM(IOS_FAMILY)
-#include "AudioSession.h"
#include "MediaSessionHelperIOS.h"
#include "MediaSessionManagerCocoa.h"
#include <wtf/RetainPtr.h>
@@ -45,8 +44,7 @@
class MediaSessionManageriOS
: public MediaSessionManagerCocoa
- , public MediaSessionHelperClient
- , public AudioSession::InterruptionObserver {
+ , public MediaSessionHelperClient {
public:
virtual ~MediaSessionManageriOS();
@@ -53,9 +51,6 @@
bool hasWirelessTargetsAvailable() override;
static WEBCORE_EXPORT void providePresentingApplicationPID();
- using WeakValueType = MediaSessionHelperClient::WeakValueType;
- using MediaSessionHelperClient::weakPtrFactory;
-
private:
friend class PlatformMediaSessionManager;
@@ -67,11 +62,8 @@
void providePresentingApplicationPIDIfNecessary() final;
void sessionWillEndPlayback(PlatformMediaSession&, DelayCallingUpdateNowPlaying) final;
- // AudioSession::InterruptionObserver
- void beginAudioSessionInterruption(PlatformMediaSession::InterruptionType type) final { beginInterruption(type); }
- void endAudioSessionInterruption(PlatformMediaSession::EndInterruptionFlags flags) final { endInterruption(flags); }
-
// MediaSessionHelperClient
+ void receivedInterruption(InterruptionType, ShouldResume) final;
void applicationWillEnterForeground(SuspendedUnderLock) final;
void applicationDidEnterBackground(SuspendedUnderLock) final;
void applicationWillBecomeInactive() final;
Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (258265 => 258266)
--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm 2020-03-11 16:50:10 UTC (rev 258266)
@@ -51,7 +51,6 @@
MediaSessionManageriOS::MediaSessionManageriOS()
: MediaSessionManagerCocoa()
{
- AudioSession::sharedSession().addInterruptionObserver(*this);
}
MediaSessionManageriOS::~MediaSessionManageriOS()
@@ -59,7 +58,6 @@
if (m_isMonitoringWirelessRoutes)
MediaSessionHelper::sharedHelper().stopMonitoringWirelessRoutes();
MediaSessionHelper::sharedHelper().removeClient(*this);
- AudioSession::sharedSession().removeInterruptionObserver(*this);
}
void MediaSessionManageriOS::resetRestrictions()
@@ -168,6 +166,19 @@
nowPlayingSession->setPlaybackTarget(WTFMove(playbackTarget));
}
+void MediaSessionManageriOS::receivedInterruption(InterruptionType type, ShouldResume shouldResume)
+{
+ if (willIgnoreSystemInterruptions())
+ return;
+
+ auto flags = shouldResume == ShouldResume::Yes ? PlatformMediaSession::MayResumePlaying : PlatformMediaSession::NoFlags;
+
+ if (type == InterruptionType::Begin)
+ beginInterruption(PlatformMediaSession::SystemInterruption);
+ else
+ endInterruption(flags);
+}
+
void MediaSessionManageriOS::applicationWillEnterForeground(SuspendedUnderLock isSuspendedUnderLock)
{
if (willIgnoreSystemInterruptions())
Modified: trunk/Source/WebKit/ChangeLog (258265 => 258266)
--- trunk/Source/WebKit/ChangeLog 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/ChangeLog 2020-03-11 16:50:10 UTC (rev 258266)
@@ -1,3 +1,17 @@
+2020-03-11 Commit Queue <[email protected]>
+
+ Unreviewed, reverting r258263.
+ https://bugs.webkit.org/show_bug.cgi?id=208922
+
+ it is breaking internal builds (Requested by youenn on
+ #webkit).
+
+ Reverted changeset:
+
+ "Move AudioSession interruption listener code to AudioSession"
+ https://bugs.webkit.org/show_bug.cgi?id=208714
+ https://trac.webkit.org/changeset/258263
+
2020-03-11 youenn fablet <[email protected]>
Move AudioSession interruption listener code to AudioSession
Modified: trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/GPUConnectionToWebProcess.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -156,7 +156,7 @@
{
#if USE(AUDIO_SESSION)
if (m_audioSessionProxy) {
- gpuProcess().audioSessionManager().removeProxy(*m_audioSessionProxy);
+ gpuProcess().audioSessionManager().removeProxy(webProcessIdentifier());
m_audioSessionProxy = nullptr;
}
#endif
@@ -263,7 +263,7 @@
{
if (!m_audioSessionProxy) {
m_audioSessionProxy = RemoteAudioSessionProxy::create(*this).moveToUniquePtr();
- gpuProcess().audioSessionManager().addProxy(*m_audioSessionProxy);
+ gpuProcess().audioSessionManager().addProxy(makeWeakPtr(m_audioSessionProxy.get()));
}
return *m_audioSessionProxy;
}
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxy.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -75,18 +75,18 @@
{
m_category = category;
m_routeSharingPolicy = policy;
- audioSessionManager().setCategoryForProcess(*this, category, policy);
+ audioSessionManager().setCategoryForProcess(m_gpuConnection.webProcessIdentifier(), category, policy);
}
void RemoteAudioSessionProxy::setPreferredBufferSize(uint64_t size)
{
m_preferredBufferSize = size;
- audioSessionManager().setPreferredBufferSizeForProcess(*this, size);
+ audioSessionManager().setPreferredBufferSizeForProcess(m_gpuConnection.webProcessIdentifier(), size);
}
void RemoteAudioSessionProxy::tryToSetActive(bool active, SetActiveCompletion&& completion)
{
- m_active = audioSessionManager().tryToSetActiveForProcess(*this, active);
+ m_active = audioSessionManager().tryToSetActiveForProcess(m_gpuConnection.webProcessIdentifier(), active);
completion(m_active);
}
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -28,8 +28,6 @@
#if ENABLE(GPU_PROCESS) && USE(AUDIO_SESSION)
-#include "GPUProcess.h"
-#include "GPUProcessConnectionMessages.h"
#include "RemoteAudioSessionProxy.h"
#include <WebCore/AudioSession.h>
#include <wtf/HashCountedSet.h>
@@ -46,36 +44,46 @@
RemoteAudioSessionProxyManager::RemoteAudioSessionProxyManager()
: m_session(AudioSession::create())
{
- m_session->addInterruptionObserver(*this);
}
-RemoteAudioSessionProxyManager::~RemoteAudioSessionProxyManager()
+RemoteAudioSessionProxyManager::~RemoteAudioSessionProxyManager() = default;
+
+void RemoteAudioSessionProxyManager::addProxy(WeakPtr<RemoteAudioSessionProxy>&& proxy)
{
- m_session->removeInterruptionObserver(*this);
+ auto id = proxy->processIdentifier();
+ ASSERT(!m_proxies.contains(id));
+ m_proxies.set(id, WTFMove(proxy));
}
-void RemoteAudioSessionProxyManager::addProxy(RemoteAudioSessionProxy& proxy)
+void RemoteAudioSessionProxyManager::removeProxy(const ProcessIdentifier& id)
{
- ASSERT(!m_proxies.contains(proxy));
- m_proxies.add(proxy);
+ ASSERT(m_proxies.contains(id));
+ m_proxies.remove(id);
}
-void RemoteAudioSessionProxyManager::removeProxy(RemoteAudioSessionProxy& proxy)
+RemoteAudioSessionProxy* RemoteAudioSessionProxyManager::getProxy(const ProcessIdentifier& id)
{
- ASSERT(m_proxies.contains(proxy));
- m_proxies.remove(proxy);
+ auto results = m_proxies.find(id);
+ if (results != m_proxies.end())
+ return results->value.get();
+ return nullptr;
}
-void RemoteAudioSessionProxyManager::setCategoryForProcess(RemoteAudioSessionProxy& proxy, AudioSession::CategoryType category, RouteSharingPolicy policy)
+void RemoteAudioSessionProxyManager::setCategoryForProcess(const ProcessIdentifier& id, AudioSession::CategoryType category, RouteSharingPolicy policy)
{
- if (proxy.category() == category && proxy.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) {
- categoryCounts.add(otherProxy.category());
- policyCounts.add(otherProxy.routeSharingPolicy());
+ for (auto& otherProxy : m_proxies.values()) {
+ categoryCounts.add(otherProxy->category());
+ policyCounts.add(otherProxy->routeSharingPolicy());
}
if (categoryCounts.contains(AudioSession::PlayAndRecord))
@@ -105,23 +113,30 @@
m_session->setCategory(category, policy);
}
-void RemoteAudioSessionProxyManager::setPreferredBufferSizeForProcess(RemoteAudioSessionProxy& proxy, size_t preferredBufferSize)
+void RemoteAudioSessionProxyManager::setPreferredBufferSizeForProcess(const ProcessIdentifier& id, size_t preferredBufferSize)
{
- for (auto& otherProxy : m_proxies) {
- if (otherProxy.preferredBufferSize() < preferredBufferSize)
- preferredBufferSize = otherProxy.preferredBufferSize();
+ for (auto& otherProxy : m_proxies.values()) {
+ if (!otherProxy)
+ continue;
+ if (otherProxy->preferredBufferSize() < preferredBufferSize)
+ preferredBufferSize = otherProxy->preferredBufferSize();
}
m_session->setPreferredBufferSize(preferredBufferSize);
}
-bool RemoteAudioSessionProxyManager::tryToSetActiveForProcess(RemoteAudioSessionProxy& proxy, bool active)
+bool RemoteAudioSessionProxyManager::tryToSetActiveForProcess(const ProcessIdentifier& id, bool active)
{
- ASSERT(m_proxies.contains(proxy));
+ ASSERT(m_proxies.contains(id));
+ auto proxy = getProxy(id);
+ if (!proxy)
+ return false;
size_t activeProxyCount { 0 };
- for (auto& otherProxy : m_proxies) {
- if (otherProxy.isActive())
+ for (auto& otherProxy : m_proxies.values()) {
+ if (!otherProxy)
+ continue;
+ if (otherProxy->isActive())
++activeProxyCount;
}
@@ -147,21 +162,23 @@
// 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()))
+ 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 categories indicate they cannot mix with others.
- for (auto& otherProxy : m_proxies) {
- if (!otherProxy.isActive())
+ // 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()))
+ if (categoryCanMixWithOthers(otherProxy->category()))
continue;
- otherProxy.beginInterruption(PlatformMediaSession::InterruptionType::SystemInterruption);
+ otherProxy->beginInterruption(PlatformMediaSession::InterruptionType::SystemInterruption);
}
#endif
@@ -169,22 +186,6 @@
}
-void RemoteAudioSessionProxyManager::beginAudioSessionInterruption(PlatformMediaSession::InterruptionType type)
-{
- for (auto& proxy : m_proxies) {
- if (proxy.isActive())
- proxy.beginInterruption(type);
- }
}
-void RemoteAudioSessionProxyManager::endAudioSessionInterruption(PlatformMediaSession::EndInterruptionFlags flags)
-{
- for (auto& proxy : m_proxies) {
- if (proxy.isActive())
- proxy.endInterruption(flags);
- }
-}
-
-}
-
#endif
Modified: trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/media/RemoteAudioSessionProxyManager.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -29,36 +29,32 @@
#include <WebCore/AudioSession.h>
#include <WebCore/ProcessIdentifier.h>
-#include <wtf/WeakHashSet.h>
namespace WebKit {
-class GPUProcess;
class RemoteAudioSessionProxy;
class RemoteAudioSessionProxyManager
- : public WebCore::AudioSession::InterruptionObserver {
+ : public CanMakeWeakPtr<RemoteAudioSessionProxyManager> {
WTF_MAKE_FAST_ALLOCATED;
public:
RemoteAudioSessionProxyManager();
~RemoteAudioSessionProxyManager();
- void addProxy(RemoteAudioSessionProxy&);
- void removeProxy(RemoteAudioSessionProxy&);
+ void addProxy(WeakPtr<RemoteAudioSessionProxy>&&);
+ void removeProxy(const WebCore::ProcessIdentifier&);
+ RemoteAudioSessionProxy* getProxy(const WebCore::ProcessIdentifier&);
- void setCategoryForProcess(RemoteAudioSessionProxy&, WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
- void setPreferredBufferSizeForProcess(RemoteAudioSessionProxy&, size_t);
+ void setCategoryForProcess(const WebCore::ProcessIdentifier&, WebCore::AudioSession::CategoryType, WebCore::RouteSharingPolicy);
+ void setPreferredBufferSizeForProcess(const WebCore::ProcessIdentifier&, size_t);
- bool tryToSetActiveForProcess(RemoteAudioSessionProxy&, bool);
+ bool tryToSetActiveForProcess(const WebCore::ProcessIdentifier&, bool);
const WebCore::AudioSession& session() const { return m_session; }
private:
- void beginAudioSessionInterruption(WebCore::PlatformMediaSession::InterruptionType) final;
- void endAudioSessionInterruption(WebCore::PlatformMediaSession::EndInterruptionFlags) final;
-
UniqueRef<WebCore::AudioSession> m_session;
- WeakHashSet<RemoteAudioSessionProxy> m_proxies;
+ HashMap<WebCore::ProcessIdentifier, WeakPtr<RemoteAudioSessionProxy>> m_proxies;
};
}
Modified: trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -74,6 +74,11 @@
MediaSessionHelper::sharedHelper().providePresentingApplicationPID(pid);
}
+void RemoteMediaSessionHelperProxy::receivedInterruption(InterruptionType type, ShouldResume shouldResume)
+{
+ m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ReceivedInterruption(type, shouldResume), { });
+}
+
void RemoteMediaSessionHelperProxy::applicationWillEnterForeground(SuspendedUnderLock suspendedUnderLock)
{
m_gpuConnection.connection().send(Messages::RemoteMediaSessionHelper::ApplicationWillEnterForeground(suspendedUnderLock), { });
Modified: trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h (258265 => 258266)
--- trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/GPUProcess/media/ios/RemoteMediaSessionHelperProxy.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -52,6 +52,7 @@
void providePresentingApplicationPID(int);
// MediaSessionHelperClient
+ void receivedInterruption(InterruptionType, ShouldResume) final;
void applicationWillEnterForeground(SuspendedUnderLock) final;
void applicationDidEnterBackground(SuspendedUnderLock) final;
void applicationWillBecomeInactive() final;
Modified: trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp (258265 => 258266)
--- trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.cpp 2020-03-11 16:50:10 UTC (rev 258266)
@@ -76,6 +76,12 @@
connection().send(Messages::RemoteMediaSessionHelperProxy::ProvidePresentingApplicationPID(pid), { });
}
+void RemoteMediaSessionHelper::receivedInterruption(InterruptionType type, ShouldResume shouldResume)
+{
+ for (auto& client : m_clients)
+ client.receivedInterruption(type, shouldResume);
+}
+
void RemoteMediaSessionHelper::applicationWillEnterForeground(SuspendedUnderLock suspendedUnderLock)
{
for (auto& client : m_clients)
Modified: trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.h (258265 => 258266)
--- trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.h 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.h 2020-03-11 16:50:10 UTC (rev 258266)
@@ -44,8 +44,10 @@
IPC::Connection& connection();
using HasAvailableTargets = WebCore::MediaSessionHelperClient::HasAvailableTargets;
+ using InterruptionType = WebCore::MediaSessionHelperClient::InterruptionType;
using PlayingToAutomotiveHeadUnit = WebCore::MediaSessionHelperClient::PlayingToAutomotiveHeadUnit;
using ShouldPause = WebCore::MediaSessionHelperClient::ShouldPause;
+ using ShouldResume = WebCore::MediaSessionHelperClient::ShouldResume;
using SupportsAirPlayVideo = WebCore::MediaSessionHelperClient::SupportsAirPlayVideo;
using SuspendedUnderLock = WebCore::MediaSessionHelperClient::SuspendedUnderLock;
@@ -59,6 +61,7 @@
void providePresentingApplicationPID(int) final;
// Messages
+ void receivedInterruption(InterruptionType, ShouldResume);
void applicationWillEnterForeground(SuspendedUnderLock);
void applicationDidEnterBackground(SuspendedUnderLock);
void applicationWillBecomeInactive();
Modified: trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.messages.in (258265 => 258266)
--- trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.messages.in 2020-03-11 16:41:03 UTC (rev 258265)
+++ trunk/Source/WebKit/WebProcess/GPU/media/ios/RemoteMediaSessionHelper.messages.in 2020-03-11 16:50:10 UTC (rev 258266)
@@ -24,6 +24,7 @@
#if ENABLE(GPU_PROCESS) && PLATFORM(IOS_FAMILY)
messages -> RemoteMediaSessionHelper NotRefCounted {
+ ReceivedInterruption(enum:bool WebKit::RemoteMediaSessionHelper::InterruptionType type, enum:bool WebKit::RemoteMediaSessionHelper::ShouldResume shouldResume)
ApplicationWillEnterForeground(enum:bool WebKit::RemoteMediaSessionHelper::SuspendedUnderLock suspendedUnderLock)
ApplicationDidEnterBackground(enum:bool WebKit::RemoteMediaSessionHelper::SuspendedUnderLock suspendedUnderLock)
ApplicationWillBecomeInactive()