<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[190815] branches/safari-601.1.46-branch</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/190815">190815</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-10-09 12:58:42 -0700 (Fri, 09 Oct 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Roll out <a href="http://trac.webkit.org/projects/webkit/changeset/190434">r190434</a>. rdar://problem/22865007</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari601146branchLayoutTestsChangeLog">branches/safari-601.1.46-branch/LayoutTests/ChangeLog</a></li>
<li><a href="#branchessafari601146branchLayoutTestsmediavideointerruptionwithresumeallowingplayexpectedtxt">branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt</a></li>
<li><a href="#branchessafari601146branchLayoutTestsmediavideointerruptionwithresumeallowingplayhtml">branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html</a></li>
<li><a href="#branchessafari601146branchLayoutTestsmediavideointerruptionwithresumenotallowingplayexpectedtxt">branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt</a></li>
<li><a href="#branchessafari601146branchLayoutTestsmediavideointerruptionwithresumenotallowingplayhtml">branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreChangeLog">branches/safari-601.1.46-branch/Source/WebCore/ChangeLog</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreModuleswebaudioAudioContexth">branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCorehtmlHTMLMediaElementcpp">branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCorehtmlHTMLMediaElementh">branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessioncpp">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionh">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSh">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm">branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm</a></li>
<li><a href="#branchessafari601146branchSourceWebCoretestingInternalscpp">branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp</a></li>
<li><a href="#branchessafari601146branchSourceWebCoretestingInternalsh">branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h</a></li>
<li><a href="#branchessafari601146branchSourceWebCoretestingInternalsidl">branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari601146branchLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/ChangeLog (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,9 @@
</span><span class="cx"> 2015-10-09 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Roll out r190434.
+
+2015-10-09 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Roll out r190438.
</span><span class="cx">
</span><span class="cx"> 2015-10-09 Babak Shafiei <bshafiei@apple.com>
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsmediavideointerruptionwithresumeallowingplayexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play-expected.txt (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -6,7 +6,7 @@
</span><span class="cx">
</span><span class="cx"> EVENT(playing)
</span><span class="cx"> EXPECTED (video.paused == 'false') OK
</span><del>-RUN(internals.beginMediaSessionInterruption('System'))
</del><ins>+RUN(internals.beginMediaSessionInterruption())
</ins><span class="cx">
</span><span class="cx"> 100ms timer fired...
</span><span class="cx"> EXPECTED (video.paused == 'true') OK
</span><span class="lines">@@ -16,7 +16,7 @@
</span><span class="cx"> EXPECTED (video.paused == 'false') OK
</span><span class="cx">
</span><span class="cx"> EXPECTED (video.paused == 'false') OK
</span><del>-RUN(internals.beginMediaSessionInterruption('System'))
</del><ins>+RUN(internals.beginMediaSessionInterruption())
</ins><span class="cx">
</span><span class="cx"> 100ms timer fired...
</span><span class="cx"> EXPECTED (video.paused == 'true') OK
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsmediavideointerruptionwithresumeallowingplayhtml"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-allowing-play.html (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -12,7 +12,7 @@
</span><span class="cx"> case "playing":
</span><span class="cx"> testExpected("video.paused", false);
</span><span class="cx"> state = "interrupted";
</span><del>- run("internals.beginMediaSessionInterruption('System')");;
</del><ins>+ run("internals.beginMediaSessionInterruption()");;
</ins><span class="cx"> setTimeout(checkState, 100);
</span><span class="cx"> consoleWrite("");
</span><span class="cx"> break;
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsmediavideointerruptionwithresumenotallowingplayexpectedtxt"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play-expected.txt (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -5,7 +5,7 @@
</span><span class="cx"> RUN(video.play())
</span><span class="cx">
</span><span class="cx"> EVENT(playing)
</span><del>-RUN(internals.beginMediaSessionInterruption('System'))
</del><ins>+RUN(internals.beginMediaSessionInterruption())
</ins><span class="cx">
</span><span class="cx"> 100ms timer fired...
</span><span class="cx"> EXPECTED (video.paused == 'true') OK
</span></span></pre></div>
<a id="branchessafari601146branchLayoutTestsmediavideointerruptionwithresumenotallowingplayhtml"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/LayoutTests/media/video-interruption-with-resume-not-allowing-play.html (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx">
</span><span class="cx"> function playing()
</span><span class="cx"> {
</span><del>- run("internals.beginMediaSessionInterruption('System')");;
</del><ins>+ run("internals.beginMediaSessionInterruption()");;
</ins><span class="cx"> setTimeout(checkState, 100);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -1,5 +1,9 @@
</span><span class="cx"> 2015-10-09 Babak Shafiei <bshafiei@apple.com>
</span><span class="cx">
</span><ins>+ Roll out r190434.
+
+2015-10-09 Babak Shafiei <bshafiei@apple.com>
+
</ins><span class="cx"> Roll out r190447.
</span><span class="cx">
</span><span class="cx"> 2015-10-09 Babak Shafiei <bshafiei@apple.com>
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreModuleswebaudioAudioContexth"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/Modules/webaudio/AudioContext.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -322,7 +322,7 @@
</span><span class="cx"> virtual void suspendPlayback() override;
</span><span class="cx"> virtual bool canReceiveRemoteControlCommands() const override { return false; }
</span><span class="cx"> virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override { }
</span><del>- bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override { return false; }
</del><ins>+ virtual bool overrideBackgroundPlaybackRestriction() const override { return false; }
</ins><span class="cx">
</span><span class="cx"> // EventTarget
</span><span class="cx"> virtual void refEventTarget() override { ref(); }
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorehtmlHTMLMediaElementcpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -6327,14 +6327,14 @@
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::suspendPlayback()
</span><span class="cx"> {
</span><del>- LOG(Media, "HTMLMediaElement::suspendPlayback(%p) - paused = %s", this, boolString(paused()));
</del><ins>+ LOG(Media, "HTMLMediaElement::pausePlayback(%p) - paused = %s", this, boolString(paused()));
</ins><span class="cx"> if (!paused())
</span><span class="cx"> pause();
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void HTMLMediaElement::mayResumePlayback(bool shouldResume)
</span><span class="cx"> {
</span><del>- LOG(Media, "HTMLMediaElement::mayResumePlayback(%p) - paused = %s", this, boolString(paused()));
</del><ins>+ LOG(Media, "HTMLMediaElement::resumePlayback(%p) - paused = %s", this, boolString(paused()));
</ins><span class="cx"> if (paused() && shouldResume)
</span><span class="cx"> play();
</span><span class="cx"> }
</span><span class="lines">@@ -6376,11 +6376,8 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><del>-bool HTMLMediaElement::shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType type) const
</del><ins>+bool HTMLMediaElement::overrideBackgroundPlaybackRestriction() const
</ins><span class="cx"> {
</span><del>- if (type != PlatformMediaSession::EnteringBackground)
- return false;
-
</del><span class="cx"> #if ENABLE(WIRELESS_PLAYBACK_TARGET)
</span><span class="cx"> if (m_player && m_player->isCurrentPlaybackTargetWireless())
</span><span class="cx"> return true;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCorehtmlHTMLMediaElementh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -725,7 +725,7 @@
</span><span class="cx"> virtual double mediaSessionCurrentTime() const override { return currentTime(); }
</span><span class="cx"> virtual bool canReceiveRemoteControlCommands() const override { return true; }
</span><span class="cx"> virtual void didReceiveRemoteControlCommand(PlatformMediaSession::RemoteControlCommandType) override;
</span><del>- bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const override;
</del><ins>+ virtual bool overrideBackgroundPlaybackRestriction() const override;
</ins><span class="cx">
</span><span class="cx"> virtual void pageMutedStateDidChange() override;
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessioncpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -39,31 +39,17 @@
</span><span class="cx"> #if !LOG_DISABLED
</span><span class="cx"> static const char* stateName(PlatformMediaSession::State state)
</span><span class="cx"> {
</span><del>-#define STATE_CASE(state) case PlatformMediaSession::state: return #state
</del><ins>+#define CASE(state) case PlatformMediaSession::state: return #state
</ins><span class="cx"> switch (state) {
</span><del>- STATE_CASE(Idle);
- STATE_CASE(Playing);
- STATE_CASE(Paused);
- STATE_CASE(Interrupted);
</del><ins>+ CASE(Idle);
+ CASE(Playing);
+ CASE(Paused);
+ CASE(Interrupted);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> ASSERT_NOT_REACHED();
</span><span class="cx"> return "";
</span><span class="cx"> }
</span><del>-
-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 "";
-}
</del><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> std::unique_ptr<PlatformMediaSession> PlatformMediaSession::create(PlatformMediaSessionClient& client)
</span><span class="lines">@@ -93,21 +79,47 @@
</span><span class="cx"> m_state = state;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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();
+}
+
</ins><span class="cx"> void PlatformMediaSession::beginInterruption(InterruptionType type)
</span><span class="cx"> {
</span><del>- LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption type = %s, interruption count = %i", this, stateName(m_state), interruptionName(type), m_interruptionCount);
</del><ins>+ LOG(Media, "PlatformMediaSession::beginInterruption(%p), state = %s, interruption count = %i", this, stateName(m_state), m_interruptionCount);
</ins><span class="cx">
</span><del>- if (++m_interruptionCount > 1)
</del><ins>+ if (++m_interruptionCount > 1 || !shouldDoInterruption(type))
</ins><span class="cx"> return;
</span><span class="cx">
</span><del>- if (client().shouldOverrideBackgroundPlaybackRestriction(type))
</del><ins>+ 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();
</ins><span class="cx"> return;
</span><ins>+ }
</ins><span class="cx">
</span><del>- m_stateToRestore = state();
- m_notifyingClient = true;
- setState(Interrupted);
- client().suspendPlayback();
- m_notifyingClient = false;
</del><ins>+ // 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();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void PlatformMediaSession::endInterruption(EndInterruptionFlags flags)
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -74,14 +74,16 @@
</span><span class="cx"> SystemSleep,
</span><span class="cx"> EnteringBackground,
</span><span class="cx"> SystemInterruption,
</span><del>- SuspendedUnderLock,
</del><span class="cx"> };
</span><span class="cx"> enum EndInterruptionFlags {
</span><span class="cx"> NoFlags = 0,
</span><span class="cx"> MayResumePlaying = 1 << 0,
</span><span class="cx"> };
</span><span class="cx">
</span><ins>+ void doInterruption();
+ bool shouldDoInterruption(InterruptionType);
</ins><span class="cx"> void beginInterruption(InterruptionType);
</span><ins>+ void forceInterruption(InterruptionType);
</ins><span class="cx"> void endInterruption(EndInterruptionFlags);
</span><span class="cx">
</span><span class="cx"> void applicationWillEnterForeground() const;
</span><span class="lines">@@ -177,7 +179,7 @@
</span><span class="cx"> virtual void setShouldBufferData(bool) { }
</span><span class="cx"> virtual bool elementIsHidden() const { return false; }
</span><span class="cx">
</span><del>- virtual bool shouldOverrideBackgroundPlaybackRestriction(PlatformMediaSession::InterruptionType) const = 0;
</del><ins>+ virtual bool overrideBackgroundPlaybackRestriction() const = 0;
</ins><span class="cx">
</span><span class="cx"> virtual void wirelessRoutesAvailableDidChange() { }
</span><span class="cx"> virtual void setWirelessPlaybackTarget(Ref<MediaPlaybackTarget>&&) { }
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionManagercpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -289,6 +289,20 @@
</span><span class="cx"> }
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+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);
+ }
+}
+
</ins><span class="cx"> void PlatformMediaSessionManager::applicationWillEnterForeground() const
</span><span class="cx"> {
</span><span class="cx"> LOG(Media, "PlatformMediaSessionManager::applicationWillEnterForeground");
</span><span class="lines">@@ -310,8 +324,8 @@
</span><span class="cx"> if (!m_isApplicationInBackground || !(m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted))
</span><span class="cx"> return;
</span><span class="cx">
</span><del>- if (session.state() != PlatformMediaSession::Interrupted)
- session.beginInterruption(PlatformMediaSession::EnteringBackground);
</del><ins>+ if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))
+ session.doInterruption();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> #if !PLATFORM(COCOA)
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioPlatformMediaSessionManagerh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -56,6 +56,7 @@
</span><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT void applicationWillEnterForeground() const;
</span><span class="cx"> WEBCORE_EXPORT void applicationWillEnterBackground() const;
</span><ins>+ WEBCORE_EXPORT void applicationDidEnterBackground(bool isSuspendedUnderLock) const;
</ins><span class="cx">
</span><span class="cx"> void stopAllMediaPlaybackForDocument(const Document*);
</span><span class="cx"> WEBCORE_EXPORT void stopAllMediaPlaybackForProcess();
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -48,7 +48,6 @@
</span><span class="cx">
</span><span class="cx"> void externalOutputDeviceAvailableDidChange();
</span><span class="cx"> virtual bool hasWirelessTargetsAvailable() override;
</span><del>- void applicationDidEnterBackground(bool isSuspendedUnderLock);
</del><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> friend class PlatformMediaSessionManager;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoreplatformaudioiosMediaSessionManagerIOSmm"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -248,21 +248,6 @@
</span><span class="cx"> session->externalOutputDeviceAvailableDidChange(haveTargets);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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);
- }
-}
-
-
</del><span class="cx"> } // namespace WebCore
</span><span class="cx">
</span><span class="cx"> @implementation WebMediaSessionHelper
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoretestingInternalscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.cpp (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -2614,21 +2614,8 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span><del>-void Internals::beginMediaSessionInterruption(const String& interruptionString, ExceptionCode& ec)
</del><ins>+void Internals::beginMediaSessionInterruption()
</ins><span class="cx"> {
</span><del>- 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;
- }
-
</del><span class="cx"> PlatformMediaSessionManager::sharedManager().beginInterruption(PlatformMediaSession::SystemInterruption);
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoretestingInternalsh"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.h (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -382,7 +382,7 @@
</span><span class="cx"> #endif
</span><span class="cx">
</span><span class="cx"> #if ENABLE(VIDEO)
</span><del>- void beginMediaSessionInterruption(const String&, ExceptionCode&);
</del><ins>+ void beginMediaSessionInterruption();
</ins><span class="cx"> void endMediaSessionInterruption(const String&);
</span><span class="cx"> void applicationWillEnterForeground() const;
</span><span class="cx"> void applicationWillEnterBackground() const;
</span></span></pre></div>
<a id="branchessafari601146branchSourceWebCoretestingInternalsidl"></a>
<div class="modfile"><h4>Modified: branches/safari-601.1.46-branch/Source/WebCore/testing/Internals.idl (190814 => 190815)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -349,7 +349,7 @@
</span><span class="cx"> [Conditional=MEDIA_SOURCE] void initializeMockMediaSource();
</span><span class="cx"> [Conditional=MEDIA_SOURCE] DOMString[] bufferedSamplesForTrackID(SourceBuffer buffer, DOMString trackID);
</span><span class="cx">
</span><del>- [Conditional=VIDEO, RaisesException] void beginMediaSessionInterruption(DOMString interruptionType);
</del><ins>+ [Conditional=VIDEO] void beginMediaSessionInterruption();
</ins><span class="cx"> [Conditional=VIDEO] void endMediaSessionInterruption(DOMString flags);
</span><span class="cx"> [Conditional=VIDEO] void applicationWillEnterForeground();
</span><span class="cx"> [Conditional=VIDEO] void applicationWillEnterBackground();
</span></span></pre>
</div>
</div>
</body>
</html>