[iOS] Enable media layout tests to run simultaneously by ignoring system-level interr...
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 19:14:36 +0000 (19:14 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 19:14:36 +0000 (19:14 +0000)
https://bugs.webkit.org/show_bug.cgi?id=148807

Reviewed by Eric Carlson.

Add an internal property that, when set, will cause system-level interruption notifications
(e.g., due to simultaneous media playback in separate processes) to be ignored by the
PlatformMediaSessionManager, and cause the media playback sessions to continue normally, if
inaudibly.

* platform/audio/PlatformMediaSessionManager.h:
(WebCore::PlatformMediaSessionManager::willIgnoreSystemInterruptions):
(WebCore::PlatformMediaSessionManager::setWillIgnoreSystemInterruptions):
* platform/audio/ios/MediaSessionManagerIOS.mm:
(-[WebMediaSessionHelper interruption:]):
(-[WebMediaSessionHelper applicationWillEnterForeground:]):
(-[WebMediaSessionHelper applicationDidBecomeActive:]):
(-[WebMediaSessionHelper applicationWillResignActive:]):
(-[WebMediaSessionHelper applicationDidEnterBackground:]):
* testing/Internals.cpp:
(WebCore::Internals::resetToConsistentState):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm
Source/WebCore/testing/Internals.cpp

index 87b0f8e8cb4af0b502212c1da99bc08b7a30514a..43d6405c6822841fed2b2b434711581b168292d2 100644 (file)
@@ -1,3 +1,27 @@
+2015-09-04  Jer Noble  <jer.noble@apple.com>
+
+        [iOS] Enable media layout tests to run simultaneously by ignoring system-level interruptions
+        https://bugs.webkit.org/show_bug.cgi?id=148807
+
+        Reviewed by Eric Carlson.
+
+        Add an internal property that, when set, will cause system-level interruption notifications
+        (e.g., due to simultaneous media playback in separate processes) to be ignored by the
+        PlatformMediaSessionManager, and cause the media playback sessions to continue normally, if
+        inaudibly.
+
+        * platform/audio/PlatformMediaSessionManager.h:
+        (WebCore::PlatformMediaSessionManager::willIgnoreSystemInterruptions):
+        (WebCore::PlatformMediaSessionManager::setWillIgnoreSystemInterruptions):
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (-[WebMediaSessionHelper interruption:]):
+        (-[WebMediaSessionHelper applicationWillEnterForeground:]):
+        (-[WebMediaSessionHelper applicationDidBecomeActive:]):
+        (-[WebMediaSessionHelper applicationWillResignActive:]):
+        (-[WebMediaSessionHelper applicationDidEnterBackground:]):
+        * testing/Internals.cpp:
+        (WebCore::Internals::resetToConsistentState):
+
 2015-09-04  Beth Dakin  <bdakin@apple.com>
 
         Need to be able to test default behaviors on force click
 2015-09-04  Beth Dakin  <bdakin@apple.com>
 
         Need to be able to test default behaviors on force click
index 1f7603abdc0a2f252cfab0cfae5136dd124d3dd4..bdbc87b8fb200f76ec72ca4d7fe71ea4e23043e9 100644 (file)
@@ -52,6 +52,9 @@ public:
     int count(PlatformMediaSession::MediaType) const;
     bool activeAudioSessionRequired() const;
 
     int count(PlatformMediaSession::MediaType) const;
     bool activeAudioSessionRequired() const;
 
+    bool willIgnoreSystemInterruptions() const { return m_willIgnoreSystemInterruptions; }
+    void setWillIgnoreSystemInterruptions(bool ignore) { m_willIgnoreSystemInterruptions = ignore; }
+
     WEBCORE_EXPORT void beginInterruption(PlatformMediaSession::InterruptionType);
     WEBCORE_EXPORT void endInterruption(PlatformMediaSession::EndInterruptionFlags);
 
     WEBCORE_EXPORT void beginInterruption(PlatformMediaSession::InterruptionType);
     WEBCORE_EXPORT void endInterruption(PlatformMediaSession::EndInterruptionFlags);
 
@@ -129,6 +132,7 @@ private:
 
     bool m_interrupted { false };
     mutable bool m_isApplicationInBackground { false };
 
     bool m_interrupted { false };
     mutable bool m_isApplicationInBackground { false };
+    bool m_willIgnoreSystemInterruptions { false };
 };
 
 }
 };
 
 }
index f26942e3be0d9c6792aef4d266b7d567165ed3c8..b12f7863a9dc7584338d6d569b11af17b5d319c2 100644 (file)
@@ -385,7 +385,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 
 - (void)interruption:(NSNotification *)notification
 {
 
 - (void)interruption:(NSNotification *)notification
 {
-    if (!_callback)
+    if (!_callback || _callback->willIgnoreSystemInterruptions())
         return;
 
     NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
         return;
 
     NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
@@ -412,7 +412,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     UNUSED_PARAM(notification);
 
 {
     UNUSED_PARAM(notification);
 
-    if (!_callback)
+    if (!_callback || _callback->willIgnoreSystemInterruptions())
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationWillEnterForeground]");
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationWillEnterForeground]");
@@ -429,7 +429,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     UNUSED_PARAM(notification);
 
 {
     UNUSED_PARAM(notification);
 
-    if (!_callback)
+    if (!_callback || _callback->willIgnoreSystemInterruptions())
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationDidBecomeActive]");
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationDidBecomeActive]");
@@ -446,7 +446,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     UNUSED_PARAM(notification);
 
 {
     UNUSED_PARAM(notification);
 
-    if (!_callback)
+    if (!_callback || _callback->willIgnoreSystemInterruptions())
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationWillResignActive]");
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationWillResignActive]");
@@ -478,7 +478,7 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 
 - (void)applicationDidEnterBackground:(NSNotification *)notification
 {
 
 - (void)applicationDidEnterBackground:(NSNotification *)notification
 {
-    if (!_callback)
+    if (!_callback || _callback->willIgnoreSystemInterruptions())
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationDidEnterBackground]");
         return;
 
     LOG(Media, "-[WebMediaSessionHelper applicationDidEnterBackground]");
index 31bf51743a881cfcb825a578b46ab2cc2ccf5557..2fdfec5fb5d9e995a1914fe6166dccb4eb6c134b 100644 (file)
@@ -333,6 +333,7 @@ void Internals::resetToConsistentState(Page* page)
     ApplicationCacheStorage::singleton().setDefaultOriginQuota(ApplicationCacheStorage::noQuota());
 #if ENABLE(VIDEO)
     PlatformMediaSessionManager::sharedManager().resetRestrictions();
     ApplicationCacheStorage::singleton().setDefaultOriginQuota(ApplicationCacheStorage::noQuota());
 #if ENABLE(VIDEO)
     PlatformMediaSessionManager::sharedManager().resetRestrictions();
+    PlatformMediaSessionManager::sharedManager().setWillIgnoreSystemInterruptions(true);
 #endif
 #if HAVE(ACCESSIBILITY)
     AXObjectCache::setEnhancedUserInterfaceAccessibility(false);
 #endif
 #if HAVE(ACCESSIBILITY)
     AXObjectCache::setEnhancedUserInterfaceAccessibility(false);