Title: [190815] branches/safari-601.1.46-branch
Revision
190815
Author
[email protected]
Date
2015-10-09 12:58:42 -0700 (Fri, 09 Oct 2015)

Log Message

Roll out r190434. rdar://problem/22865007

Modified Paths

Diff

Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (190814 => 190815)


--- branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/LayoutTests/ChangeLog	2015-10-09 19:58:42 UTC (rev 190815)
@@ -1,5 +1,9 @@
 2015-10-09  Babak Shafiei  <[email protected]>
 
+        Roll out r190434.
+
+2015-10-09  Babak Shafiei  <[email protected]>
+
         Roll out r190438.
 
 2015-10-09  Babak Shafiei  <[email protected]>

Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt (190814 => 190815)


--- branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt	2015-10-09 19:58:42 UTC (rev 190815)
@@ -6,7 +6,7 @@
 
 EVENT(playing)
 EXPECTED (video.paused == 'false') OK
-RUN(internals.beginMediaSessionInterruption('System'))
+RUN(internals.beginMediaSessionInterruption())
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK
@@ -16,7 +16,7 @@
 EXPECTED (video.paused == 'false') OK
 
 EXPECTED (video.paused == 'false') OK
-RUN(internals.beginMediaSessionInterruption('System'))
+RUN(internals.beginMediaSessionInterruption())
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK

Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html (190814 => 190815)


--- branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html	2015-10-09 19:58:42 UTC (rev 190815)
@@ -12,7 +12,7 @@
                 case "playing":
                     testExpected("video.paused", false);
                     state = "interrupted";
-                    run("internals.beginMediaSessionInterruption('System')");;
+                    run("internals.beginMediaSessionInterruption()");;
                     setTimeout(checkState, 100);
                     consoleWrite("");
                     break;

Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt (190814 => 190815)


--- branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt	2015-10-09 19:58:42 UTC (rev 190815)
@@ -5,7 +5,7 @@
 RUN(video.play())
 
 EVENT(playing)
-RUN(internals.beginMediaSessionInterruption('System'))
+RUN(internals.beginMediaSessionInterruption())
 
 100ms timer fired...
 EXPECTED (video.paused == 'true') OK

Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html (190814 => 190815)


--- branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html	2015-10-09 19:58:42 UTC (rev 190815)
@@ -7,7 +7,7 @@
 
             function playing()
             {
-                run("internals.beginMediaSessionInterruption('System')");;
+                run("internals.beginMediaSessionInterruption()");;
                 setTimeout(checkState, 100);
             }
 

Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog	2015-10-09 19:58:42 UTC (rev 190815)
@@ -1,5 +1,9 @@
 2015-10-09  Babak Shafiei  <[email protected]>
 
+        Roll out r190434.
+
+2015-10-09  Babak Shafiei  <[email protected]>
+
         Roll out r190447.
 
 2015-10-09  Babak Shafiei  <[email protected]>

Modified: branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -322,7 +322,7 @@
     virtual void suspendPlayback() override;
     virtual bool canReceiveRemoteControlCommands() const override { return false; }
     virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { }
-    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
+    virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }
 
     // EventTarget
     virtual void refEventTarget() override { ref(); }

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp	2015-10-09 19:58:42 UTC (rev 190815)
@@ -6327,14 +6327,14 @@
 
 void HTMLMediaElement::suspendPlayback()
 {
-    LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused()));
+    LOG(Media, "HTMLMediaElement::pausePlayback(%p) - paused = %s", this, boolString(paused()));
     if (!paused())
         pause();
 }
 
 void HTMLMediaElement::mayResumePlayback(bool shouldResume)
 {
-    LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused()));
+    LOG(Media, "HTMLMediaElement::resumePlayback(%p) - paused = %s", this, boolString(paused()));
     if (paused() && shouldResume)
         play();
 }
@@ -6376,11 +6376,8 @@
     }
 }
 
-bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const
+bool HTMLMediaElement::overrideBackgroundPlaybackRestriction() const
 {
-    if (type != PlatformMediaSession::EnteringBackground)
-        return false;
-
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     if (m_player && m_player->isCurrentPlaybackTargetWireless())
         return true;

Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -725,7 +725,7 @@
     virtual double mediaSessionCurrentTime() const override { return currentTime(); }
     virtual bool canReceiveRemoteControlCommands() const override { return true; }
     virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
-    bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
+    virtual bool overrideBackgroundPlaybackRestriction() const override;
 
     virtual void pageMutedStateDidChange() override;
 

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp	2015-10-09 19:58:42 UTC (rev 190815)
@@ -39,31 +39,17 @@
 #if !LOG_DISABLED
 static const char* stateName(PlatformMediaSession::State state)
 {
-#define STATE_CASE(state) case PlatformMediaSession::state: return #state
+#define CASE(state) case PlatformMediaSession::state: return #state
     switch (state) {
-    STATE_CASE(Idle);
-    STATE_CASE(Playing);
-    STATE_CASE(Paused);
-    STATE_CASE(Interrupted);
+    CASE(Idle);
+    CASE(Playing);
+    CASE(Paused);
+    CASE(Interrupted);
     }
 
     ASSERT_NOT_REACHED();
     return "";
 }
-
-static const char* interruptionName(PlatformMediaSession::InterruptionType type)
-{
-#define INTERRUPTION_CASE(type) case PlatformMediaSession::type: return #type
-    switch (type) {
-    INTERRUPTION_CASE(SystemSleep);
-    INTERRUPTION_CASE(EnteringBackground);
-    INTERRUPTION_CASE(SystemInterruption);
-    INTERRUPTION_CASE(SuspendedUnderLock);
-    }
-    
-    ASSERT_NOT_REACHED();
-    return "";
-}
 #endif
 
 std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionClient& client)
@@ -93,21 +79,47 @@
     m_state = state;
 }
 
+void PlatformMediaSession::doInterruption()
+{
+    m_stateToRestore = state();
+    m_notifyingClient = true;
+    setState(Interrupted);
+    client().suspendPlayback();
+    m_notifyingClient = false;
+}
+
+bool PlatformMediaSession::shouldDoInterruption(InterruptionType type)
+{
+    return type != EnteringBackground || !client().overrideBackgroundPlaybackRestriction();
+}
+
 void PlatformMediaSession::beginInterruption(InterruptionType type)
 {
-    LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);
+    LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
 
-    if (++m_interruptionCount > 1)
+    if (++m_interruptionCount > 1 || !shouldDoInterruption(type))
         return;
 
-    if (client().shouldOverrideBackgroundPlaybackRestriction(type))
+    doInterruption();
+}
+
+void PlatformMediaSession::forceInterruption(InterruptionType type)
+{
+    LOG(Media, "PlatformMediaSession::forceInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
+
+    // beginInterruption() must have been called before calling this function.
+    if (!m_interruptionCount) {
+        ASSERT_NOT_REACHED();
         return;
+    }
 
-    m_stateToRestore = state();
-    m_notifyingClient = true;
-    setState(Interrupted);
-    client().suspendPlayback();
-    m_notifyingClient = false;
+    // The purpose of this function is to override the decision which was made by
+    // beginInterruption(). If it was decided to interrupt the media session there,
+    // then nothing should be done here.
+    if (shouldDoInterruption(type))
+        return;
+
+    doInterruption();
 }
 
 void PlatformMediaSession::endInterruption(EndInterruptionFlags flags)

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -74,14 +74,16 @@
         SystemSleep,
         EnteringBackground,
         SystemInterruption,
-        SuspendedUnderLock,
     };
     enum EndInterruptionFlags {
         NoFlags = 0,
         MayResumePlaying = 1 << 0,
     };
 
+    void doInterruption();
+    bool shouldDoInterruption(InterruptionType);
     void beginInterruption(InterruptionType);
+    void forceInterruption(InterruptionType);
     void endInterruption(EndInterruptionFlags);
 
     void applicationWillEnterForeground() const;
@@ -177,7 +179,7 @@
     virtual void setShouldBufferData(bool) { }
     virtual bool elementIsHidden() const { return false; }
 
-    virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0;
+    virtual bool overrideBackgroundPlaybackRestriction() const = 0;
 
     virtual void wirelessRoutesAvailableDidChange() { }
     virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) { }

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp	2015-10-09 19:58:42 UTC (rev 190815)
@@ -289,6 +289,20 @@
     }
 }
 
+void PlatformMediaSessionManager::applicationDidEnterBackground(bool isSuspendedUnderLock) const
+{
+    LOG(Media, "PlatformMediaSessionManager::applicationDidEnterBackground");
+
+    if (!isSuspendedUnderLock)
+        return;
+
+    Vector<PlatformMediaSession*> sessions = m_sessions;
+    for (auto* session : sessions) {
+        if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)
+            session->forceInterruption(PlatformMediaSession::EnteringBackground);
+    }
+}
+
 void PlatformMediaSessionManager::applicationWillEnterForeground() const
 {
     LOG(Media, "PlatformMediaSessionManager::applicationWillEnterForeground");
@@ -310,8 +324,8 @@
     if (!m_isApplicationInBackground || !(m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted))
         return;
 
-    if (session.state() != PlatformMediaSession::Interrupted)
-        session.beginInterruption(PlatformMediaSession::EnteringBackground);
+    if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))
+        session.doInterruption();
 }
 
 #if !PLATFORM(COCOA)

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -56,6 +56,7 @@
 
     WEBCORE_EXPORT void applicationWillEnterForeground() const;
     WEBCORE_EXPORT void applicationWillEnterBackground() const;
+    WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
 
     void stopAllMediaPlaybackForDocument(const Document*);
     WEBCORE_EXPORT void stopAllMediaPlaybackForProcess();

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -48,7 +48,6 @@
 
     void externalOutputDeviceAvailableDidChange();
     virtual bool hasWirelessTargetsAvailable() override;
-    void applicationDidEnterBackground(bool isSuspendedUnderLock);
 
 private:
     friend class PlatformMediaSessionManager;

Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2015-10-09 19:58:42 UTC (rev 190815)
@@ -248,21 +248,6 @@
         session->externalOutputDeviceAvailableDidChange(haveTargets);
 }
 
-void MediaSessionManageriOS::applicationDidEnterBackground(bool isSuspendedUnderLock)
-{
-    LOG(Media, "MediaSessionManageriOS::applicationDidEnterBackground");
-
-    if (!isSuspendedUnderLock)
-        return;
-
-    Vector<PlatformMediaSession*> sessions = this->sessions();
-    for (auto* session : sessions) {
-        if (restrictions(session->mediaType()) & BackgroundProcessPlaybackRestricted)
-            session->beginInterruption(PlatformMediaSession::SuspendedUnderLock);
-    }
-}
-
-
 } // namespace WebCore
 
 @implementation WebMediaSessionHelper

Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp	2015-10-09 19:58:42 UTC (rev 190815)
@@ -2614,21 +2614,8 @@
 #endif
 
 #if ENABLE(VIDEO)
-void Internals::beginMediaSessionInterruption(const String& interruptionString, ExceptionCode& ec)
+void Internals::beginMediaSessionInterruption()
 {
-    PlatformMediaSession::InterruptionType interruption = PlatformMediaSession::SystemInterruption;
-
-    if (equalIgnoringCase(interruptionString, "System"))
-        interruption = PlatformMediaSession::SystemInterruption;
-    else if (equalIgnoringCase(interruptionString, "SystemSleep"))
-        interruption = PlatformMediaSession::SystemSleep;
-    else if (equalIgnoringCase(interruptionString, "EnteringBackground"))
-        interruption = PlatformMediaSession::EnteringBackground;
-    else {
-        ec = INVALID_ACCESS_ERR;
-        return;
-    }
-
     PlatformMediaSessionManager::sharedManager().beginInterruption(PlatformMediaSession::SystemInterruption);
 }
 

Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h	2015-10-09 19:58:42 UTC (rev 190815)
@@ -382,7 +382,7 @@
 #endif
 
 #if ENABLE(VIDEO)
-    void beginMediaSessionInterruption(const String&, ExceptionCode&);
+    void beginMediaSessionInterruption();
     void endMediaSessionInterruption(const String&);
     void applicationWillEnterForeground() const;
     void applicationWillEnterBackground() const;

Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl (190814 => 190815)


--- branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl	2015-10-09 19:56:59 UTC (rev 190814)
+++ branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl	2015-10-09 19:58:42 UTC (rev 190815)
@@ -349,7 +349,7 @@
     [Conditional=MEDIA_SOURCE] void initializeMockMediaSource();
     [Conditional=MEDIA_SOURCE] DOMString[] bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
 
-    [Conditional=VIDEO, RaisesException] void beginMediaSessionInterruption(DOMString interruptionType);
+    [Conditional=VIDEO] void beginMediaSessionInterruption();
     [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
     [Conditional=VIDEO] void applicationWillEnterForeground();
     [Conditional=VIDEO] void applicationWillEnterBackground();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to