Diff
Modified: branches/safari-601.1.46-branch/Source/WebCore/ChangeLog (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/ChangeLog 2015-10-02 08:07:40 UTC (rev 190470)
@@ -1,5 +1,43 @@
2015-10-02 Babak Shafiei <[email protected]>
+ Merge r189322.
+
+ 2015-09-03 Jer Noble <[email protected]>
+
+ [iOS] Playback does not pause when deselecting route and locking screen.
+ https://bugs.webkit.org/show_bug.cgi?id=148724
+
+ Reviewed by Eric Carlson.
+
+ When deselecting a route, the route change notification can be delayed for some amount
+ of time. If the screen is locked before the notification is fired, the PlatformMediaSessionManager
+ can refuse to pause the video when entering the background due to a wireless playback route
+ still being active.
+
+ When the media element transitions from having an active route to not having one (or vice versa),
+ re-run the interruption check. In order to correctly determine, when that occurs, whether
+ we are in an 'application background' state, cache that value to an ivar when handling
+ application{Will,Did}Enter{Background,Foreground}.
+
+ Because we only want to run this step during an actual transition between playing to a route ->
+ playing locally, cache the value of isPlayingToWirelessPlayback to another ivar, and only
+ inform the PlatformMediaSessionManager when that value actually changes.
+
+ * html/HTMLMediaElement.cpp:
+ (WebCore::HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged):
+ * platform/audio/PlatformMediaSession.cpp:
+ (WebCore::PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged): Set or clear m_isPlayingToWirelessPlaybackTarget.
+ * platform/audio/PlatformMediaSession.h:
+ (WebCore::PlatformMediaSession::isPlayingToWirelessPlaybackTarget): Simple getter.
+ * platform/audio/PlatformMediaSessionManager.cpp:
+ (WebCore::PlatformMediaSessionManager::applicationWillEnterBackground): Set m_isApplicationInBackground.
+ (WebCore::PlatformMediaSessionManager::applicationDidEnterBackground): Ditto.
+ (WebCore::PlatformMediaSessionManager::applicationWillEnterForeground): Clear m_isApplicationInBackground.
+ (WebCore::PlatformMediaSessionManager::sessionIsPlayingToWirelessPlaybackTargetChanged): Run interruption
+ if application is in background.
+
+2015-10-02 Babak Shafiei <[email protected]>
+
Merge r188768.
2015-08-21 Joseph Pecoraro <[email protected]>
Modified: branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/html/HTMLMediaElement.cpp 2015-10-02 08:07:40 UTC (rev 190470)
@@ -5036,9 +5036,10 @@
void HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged(MediaPlayer*)
{
LOG(Media, "HTMLMediaElement::mediaPlayerCurrentPlaybackTargetIsWirelessChanged(%p) - webkitCurrentPlaybackTargetIsWireless = %s", this, boolString(webkitCurrentPlaybackTargetIsWireless()));
-
+ ASSERT(m_player);
configureMediaControls();
scheduleEvent(eventNames().webkitcurrentplaybacktargetiswirelesschangedEvent);
+ m_mediaSession->isPlayingToWirelessPlaybackTargetChanged(m_player->isCurrentPlaybackTargetWireless());
updateMediaState(UpdateMediaState::Asynchronously);
}
Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.cpp 2015-10-02 08:07:40 UTC (rev 190470)
@@ -255,6 +255,15 @@
return m_client.elementIsHidden();
}
+void PlatformMediaSession::isPlayingToWirelessPlaybackTargetChanged(bool isWireless)
+{
+ if (isWireless == m_isPlayingToWirelessPlaybackTarget)
+ return;
+
+ m_isPlayingToWirelessPlaybackTarget = isWireless;
+ PlatformMediaSessionManager::sharedManager().sessionIsPlayingToWirelessPlaybackTargetChanged(*this);
+}
+
PlatformMediaSession::DisplayType PlatformMediaSession::displayType() const
{
return m_client.displayType();
Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSession.h 2015-10-02 08:07:40 UTC (rev 190470)
@@ -125,7 +125,8 @@
bool isHidden() const;
virtual bool canPlayToWirelessPlaybackTarget() const { return false; }
- virtual bool isPlayingToWirelessPlaybackTarget() const { return false; }
+ virtual bool isPlayingToWirelessPlaybackTarget() const { return m_isPlayingToWirelessPlaybackTarget; }
+ void isPlayingToWirelessPlaybackTargetChanged(bool);
#if ENABLE(WIRELESS_PLAYBACK_TARGET)
// MediaPlaybackTargetClient
@@ -151,6 +152,7 @@
State m_stateToRestore;
int m_interruptionCount { 0 };
bool m_notifyingClient;
+ bool m_isPlayingToWirelessPlaybackTarget { false };
friend class PlatformMediaSessionManager;
};
Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.cpp 2015-10-02 08:07:40 UTC (rev 190470)
@@ -276,6 +276,12 @@
void PlatformMediaSessionManager::applicationWillEnterBackground() const
{
LOG(Media, "PlatformMediaSessionManager::applicationWillEnterBackground");
+
+ if (m_isApplicationInBackground)
+ return;
+
+ m_isApplicationInBackground = true;
+
Vector<PlatformMediaSession*> sessions = m_sessions;
for (auto* session : sessions) {
if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)
@@ -300,6 +306,12 @@
void PlatformMediaSessionManager::applicationWillEnterForeground() const
{
LOG(Media, "PlatformMediaSessionManager::applicationWillEnterForeground");
+
+ if (!m_isApplicationInBackground)
+ return;
+
+ m_isApplicationInBackground = false;
+
Vector<PlatformMediaSession*> sessions = m_sessions;
for (auto* session : sessions) {
if (m_restrictions[session->mediaType()] & BackgroundProcessPlaybackRestricted)
@@ -307,6 +319,15 @@
}
}
+void PlatformMediaSessionManager::sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession& session)
+{
+ if (!m_isApplicationInBackground || !(m_restrictions[session.mediaType()] & BackgroundProcessPlaybackRestricted))
+ return;
+
+ if (session.state() != PlatformMediaSession::Interrupted && session.shouldDoInterruption(PlatformMediaSession::EnteringBackground))
+ session.doInterruption();
+}
+
#if !PLATFORM(COCOA)
void PlatformMediaSessionManager::updateSessionState()
{
Modified: branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h (190469 => 190470)
--- branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2015-10-02 08:06:44 UTC (rev 190469)
+++ branches/safari-601.1.46-branch/Source/WebCore/platform/audio/PlatformMediaSessionManager.h 2015-10-02 08:07:40 UTC (rev 190470)
@@ -93,6 +93,8 @@
void setCurrentSession(PlatformMediaSession&);
PlatformMediaSession* currentSession();
+ void sessionIsPlayingToWirelessPlaybackTargetChanged(PlatformMediaSession&);
+
protected:
friend class PlatformMediaSession;
explicit PlatformMediaSessionManager();
@@ -131,6 +133,7 @@
#endif
bool m_interrupted { false };
+ mutable bool m_isApplicationInBackground { false };
};
}