[iOS] HTMLMediaElement sometimes doesn't send 'webkitplaybacktargetavailabilitychange...
authoreric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 23:29:56 +0000 (23:29 +0000)
committereric.carlson@apple.com <eric.carlson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 10 May 2019 23:29:56 +0000 (23:29 +0000)
https://bugs.webkit.org/show_bug.cgi?id=197793
<rdar://problem/46429187>

Reviewed by Jer Noble.

* html/MediaElementSession.cpp:
(WebCore::MediaElementSession::MediaElementSession): Initialize m_hasPlaybackTargets.

* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::externalOutputDeviceAvailableDidChange): Log
target availability.
(-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): Call the client
externalOutputDeviceAvailableDidChange method after the AVRouteDetector is available.

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

Source/WebCore/ChangeLog
Source/WebCore/html/MediaElementSession.cpp
Source/WebCore/platform/audio/PlatformMediaSessionManager.h
Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

index b8da9db..0bec278 100644 (file)
@@ -1,3 +1,20 @@
+2019-05-10  Eric Carlson  <eric.carlson@apple.com>
+
+        [iOS] HTMLMediaElement sometimes doesn't send 'webkitplaybacktargetavailabilitychanged' event
+        https://bugs.webkit.org/show_bug.cgi?id=197793
+        <rdar://problem/46429187>
+
+        Reviewed by Jer Noble.
+
+        * html/MediaElementSession.cpp:
+        (WebCore::MediaElementSession::MediaElementSession): Initialize m_hasPlaybackTargets.
+
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::externalOutputDeviceAvailableDidChange): Log
+        target availability.
+        (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): Call the client 
+        externalOutputDeviceAvailableDidChange method after the AVRouteDetector is available.
+
 2019-05-09  Geoffrey Garen  <ggaren@apple.com>
 
         Downgrade RELEASE_ASSERT TO RELEASE_LOG_FAULT for SQLite Class A files
index ec48a24..d987c64 100644 (file)
@@ -110,6 +110,7 @@ MediaElementSession::MediaElementSession(HTMLMediaElement& element)
     , m_restrictions(NoRestrictions)
 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
     , m_targetAvailabilityChangedTimer(*this, &MediaElementSession::targetAvailabilityChangedTimerFired)
+    , m_hasPlaybackTargets(PlatformMediaSessionManager::sharedManager().hasWirelessTargetsAvailable())
 #endif
     , m_mainContentCheckTimer(*this, &MediaElementSession::mainContentCheckTimerFired)
     , m_clientDataBufferingTimer(*this, &MediaElementSession::clientDataBufferingTimerFired)
index 51cd6a2..98f1f5e 100644 (file)
@@ -121,8 +121,8 @@ public:
 
 #if PLATFORM(IOS_FAMILY)
     virtual void configureWireLessTargetMonitoring() { }
-    virtual bool hasWirelessTargetsAvailable() { return false; }
 #endif
+    virtual bool hasWirelessTargetsAvailable() { return false; }
 
     void setCurrentSession(PlatformMediaSession&);
     PlatformMediaSession* currentSession() const;
index faf5b44..ab1cae0 100644 (file)
@@ -183,9 +183,14 @@ void MediaSessionManageriOS::providePresentingApplicationPIDIfNecessary()
 void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
 {
     BEGIN_BLOCK_OBJC_EXCEPTIONS
-    forEachSession([haveTargets = [m_objcObserver hasWirelessTargetsAvailable]] (PlatformMediaSession& session, size_t) {
+
+    auto haveTargets = [m_objcObserver hasWirelessTargetsAvailable];
+    ALWAYS_LOG(LOGIDENTIFIER, haveTargets);
+
+    forEachSession([haveTargets] (PlatformMediaSession& session, size_t) {
         session.externalOutputDeviceAvailableDidChange(haveTargets);
     });
+
     END_BLOCK_OBJC_EXCEPTIONS
 }
 
@@ -289,6 +294,8 @@ void MediaSessionManageriOS::externalOutputDeviceAvailableDidChange()
             protectedSelf->_routeDetector = adoptNS([PAL::allocAVRouteDetectorInstance() init]);
             protectedSelf->_routeDetector.get().routeDetectionEnabled = protectedSelf->_monitoringAirPlayRoutes;
             [[NSNotificationCenter defaultCenter] addObserver:protectedSelf selector:@selector(wirelessRoutesAvailableDidChange:) name:AVRouteDetectorMultipleRoutesDetectedDidChangeNotification object:protectedSelf->_routeDetector.get()];
+
+            protectedSelf->_callback->externalOutputDeviceAvailableDidChange();
             END_BLOCK_OBJC_EXCEPTIONS
         }