Title: [186238] trunk/Source/WebCore
Revision
186238
Author
eric.carl...@apple.com
Date
2015-07-02 15:31:21 -0700 (Thu, 02 Jul 2015)

Log Message

[Mac] Clear current AirPlay source before setting another
https://bugs.webkit.org/show_bug.cgi?id=145959

Reviewed by Brent Fulgham.

* Modules/mediasession/WebMediaSessionManager.cpp:
(WebCore::WebMediaSessionManager::clientStateDidChange): Don't make a client begin playing
  to the target just because it has paused.
(WebCore::WebMediaSessionManager::configurePlaybackTargetClients): Always select a client that
  requrested the picker, and never consider paused clients when choosing a client to begin
  playing to the targer. Call setShouldPlayToPlaybackTarget(true) after all of the other
  clients have been told to stop playing to the target.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (186237 => 186238)


--- trunk/Source/WebCore/ChangeLog	2015-07-02 22:17:42 UTC (rev 186237)
+++ trunk/Source/WebCore/ChangeLog	2015-07-02 22:31:21 UTC (rev 186238)
@@ -1,3 +1,18 @@
+2015-07-02  Eric Carlson  <eric.carl...@apple.com>
+
+        [Mac] Clear current AirPlay source before setting another
+        https://bugs.webkit.org/show_bug.cgi?id=145959
+
+        Reviewed by Brent Fulgham.
+
+        * Modules/mediasession/WebMediaSessionManager.cpp:
+        (WebCore::WebMediaSessionManager::clientStateDidChange): Don't make a client begin playing 
+          to the target just because it has paused.
+        (WebCore::WebMediaSessionManager::configurePlaybackTargetClients): Always select a client that
+          requrested the picker, and never consider paused clients when choosing a client to begin
+          playing to the targer. Call setShouldPlayToPlaybackTarget(true) after all of the other 
+          clients have been told to stop playing to the target.
+
 2015-07-02  Beth Dakin  <bda...@apple.com>
 
         Allow the UIDelegate to customize an image preview

Modified: trunk/Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp (186237 => 186238)


--- trunk/Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp	2015-07-02 22:17:42 UTC (rev 186237)
+++ trunk/Source/WebCore/Modules/mediasession/WebMediaSessionManager.cpp	2015-07-02 22:31:21 UTC (rev 186238)
@@ -171,15 +171,18 @@
     if (!flagsAreSet(oldFlags, MediaProducer::RequiresPlaybackTargetMonitoring) && flagsAreSet(newFlags, MediaProducer::RequiresPlaybackTargetMonitoring))
         scheduleDelayedTask(TargetMonitoringConfigurationTask);
 
-    if (!flagsAreSet(newFlags, MediaProducer::ExternalDeviceAutoPlayCandidate))
+    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
         return;
 
-    if (!m_playbackTarget || !m_playbackTarget->hasActiveRoute())
+    if (!flagsAreSet(newFlags, MediaProducer::ExternalDeviceAutoPlayCandidate) || !flagsAreSet(newFlags, MediaProducer::IsPlayingVideo))
         return;
 
     // Do not interrupt another element already playing to a device.
     bool anotherClientHasActiveTarget = false;
     for (auto& state : m_clientState) {
+        if (state == changedClientState)
+            continue;
+
         if (flagsAreSet(state->flags, MediaProducer::IsPlayingToExternalDevice)) {
             if (flagsAreSet(state->flags, MediaProducer::IsPlayingVideo))
                 return;
@@ -243,14 +246,11 @@
     for (size_t i = 0; i < m_clientState.size(); ++i) {
         auto& state = m_clientState[i];
 
-        if (indexOfClientThatRequestedPicker == notFound && state->requestedPicker)
+        if (state->requestedPicker)
             indexOfClientThatRequestedPicker = i;
 
         if (indexOfClientWillPlayToTarget == notFound && flagsAreSet(state->flags, MediaProducer::IsPlayingToExternalDevice))
             indexOfClientWillPlayToTarget = i;
-
-        if (indexOfAutoPlayCandidate == notFound && flagsAreSet(state->flags, MediaProducer::ExternalDeviceAutoPlayCandidate) && !flagsAreSet(state->flags, MediaProducer::IsPlayingVideo))
-            indexOfAutoPlayCandidate = i;
     }
 
     if (indexOfClientThatRequestedPicker != notFound)
@@ -264,14 +264,18 @@
         if (m_playbackTarget)
             state->client.setPlaybackTarget(state->contextId, *m_playbackTarget.copyRef());
 
-        if (i != indexOfClientWillPlayToTarget)
+        if (i != indexOfClientWillPlayToTarget || !haveActiveRoute)
             state->client.setShouldPlayToPlaybackTarget(state->contextId, false);
-        else if (!flagsAreSet(state->flags, MediaProducer::IsPlayingToExternalDevice))
-            state->client.setShouldPlayToPlaybackTarget(state->contextId, haveActiveRoute);
 
         state->configurationRequired = false;
         state->requestedPicker = false;
     }
+
+    if (haveActiveRoute && indexOfClientWillPlayToTarget != notFound) {
+        auto& state = m_clientState[indexOfClientWillPlayToTarget];
+        if (!flagsAreSet(state->flags, MediaProducer::IsPlayingToExternalDevice))
+            state->client.setShouldPlayToPlaybackTarget(state->contextId, true);
+    }
 }
 
 void WebMediaSessionManager::configurePlaybackTargetMonitoring()
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to