Title: [175976] trunk/Source/WebCore
Revision
175976
Author
[email protected]
Date
2014-11-11 14:03:15 -0800 (Tue, 11 Nov 2014)

Log Message

[iOS] cleanup wireless route monitoring
https://bugs.webkit.org/show_bug.cgi?id=138614

Reviewed by Jer Noble.

* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::clearMediaPlayer): Add logging.
(WebCore::HTMLMediaElement::removeEventListener): Ditto.
(WebCore::HTMLMediaElement::createMediaPlayer): Ditto.

* platform/audio/ios/MediaSessionManagerIOS.mm:
(WebCore::MediaSessionManageriOS::resetRestrictions): Add logging.
(WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Ditto.
(WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Ditto.
(-[WebMediaSessionHelper initWithCallback:]): Ditto.
(-[WebMediaSessionHelper dealloc]): Always deallocate volume view and routing controller
    on the main thread.
(-[WebMediaSessionHelper clearCallback]): Add logging.
(-[WebMediaSessionHelper hasWirelessTargetsAvailable]): Ditto.
(-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): Always call routing controller on
    the main thread.
(-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): Ditto.
(-[WebMediaSessionHelper interruption:]): Add logging.
(-[WebMediaSessionHelper applicationWillEnterForeground:]): Ditto.
(-[WebMediaSessionHelper applicationDidBecomeActive:]): Ditto.
(-[WebMediaSessionHelper applicationWillResignActive:]): Ditto.
(-[WebMediaSessionHelper wirelessRoutesAvailableDidChange:]): Ditto.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175975 => 175976)


--- trunk/Source/WebCore/ChangeLog	2014-11-11 22:02:16 UTC (rev 175975)
+++ trunk/Source/WebCore/ChangeLog	2014-11-11 22:03:15 UTC (rev 175976)
@@ -1,3 +1,33 @@
+2014-11-11  Eric Carlson  <[email protected]>
+
+        [iOS] cleanup wireless route monitoring
+        https://bugs.webkit.org/show_bug.cgi?id=138614
+
+        Reviewed by Jer Noble.
+
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::clearMediaPlayer): Add logging.
+        (WebCore::HTMLMediaElement::removeEventListener): Ditto.
+        (WebCore::HTMLMediaElement::createMediaPlayer): Ditto.
+
+        * platform/audio/ios/MediaSessionManagerIOS.mm:
+        (WebCore::MediaSessionManageriOS::resetRestrictions): Add logging.
+        (WebCore::MediaSessionManageriOS::configureWireLessTargetMonitoring): Ditto.
+        (WebCore::MediaSessionManageriOS::updateNowPlayingInfo): Ditto.
+        (-[WebMediaSessionHelper initWithCallback:]): Ditto.
+        (-[WebMediaSessionHelper dealloc]): Always deallocate volume view and routing controller
+            on the main thread.
+        (-[WebMediaSessionHelper clearCallback]): Add logging.
+        (-[WebMediaSessionHelper hasWirelessTargetsAvailable]): Ditto.
+        (-[WebMediaSessionHelper startMonitoringAirPlayRoutes]): Always call routing controller on
+            the main thread.
+        (-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]): Ditto.
+        (-[WebMediaSessionHelper interruption:]): Add logging.
+        (-[WebMediaSessionHelper applicationWillEnterForeground:]): Ditto.
+        (-[WebMediaSessionHelper applicationDidBecomeActive:]): Ditto.
+        (-[WebMediaSessionHelper applicationWillResignActive:]): Ditto.
+        (-[WebMediaSessionHelper wirelessRoutesAvailableDidChange:]): Ditto.
+
 2014-11-11  Myles C. Maxfield  <[email protected]>
 
         Unreviewd iOS build fix

Modified: trunk/Source/WebCore/html/HTMLMediaElement.cpp (175975 => 175976)


--- trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-11-11 22:02:16 UTC (rev 175975)
+++ trunk/Source/WebCore/html/HTMLMediaElement.cpp	2014-11-11 22:03:15 UTC (rev 175976)
@@ -4651,6 +4651,8 @@
 
 void HTMLMediaElement::clearMediaPlayer(int flags)
 {
+    LOG(Media, "HTMLMediaElement::clearMediaPlayer(%p) - flags = %x", this, (unsigned)flags);
+
 #if USE(PLATFORM_TEXT_TRACK_MENU)
     if (platformTextTrackMenu()) {
         m_platformMenu->setClient(0);
@@ -4855,6 +4857,7 @@
         return false;
 
     bool didRemoveLastAvailabilityChangedListener = !hasEventListeners(eventNames().webkitplaybacktargetavailabilitychangedEvent);
+    LOG(Media, "HTMLMediaElement::removeEventListener(%p) - removed last listener = %s", this, boolString(didRemoveLastAvailabilityChangedListener));
     if (didRemoveLastAvailabilityChangedListener)
         m_mediaSession->setHasPlaybackTargetAvailabilityListeners(*this, false);
 
@@ -5357,6 +5360,8 @@
 
 void HTMLMediaElement::createMediaPlayer()
 {
+    LOG(Media, "HTMLMediaElement::createMediaPlayer(%p)", this);
+
 #if ENABLE(WEB_AUDIO)
     if (m_audioSourceNode)
         m_audioSourceNode->lock();

Modified: trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm (175975 => 175976)


--- trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2014-11-11 22:02:16 UTC (rev 175975)
+++ trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm	2014-11-11 22:03:15 UTC (rev 175976)
@@ -126,6 +126,8 @@
 
 void MediaSessionManageriOS::resetRestrictions()
 {
+    LOG(Media, "MediaSessionManageriOS::resetRestrictions");
+
     MediaSessionManager::resetRestrictions();
 
     static wkDeviceClass deviceClass = iosDeviceClass();
@@ -166,6 +168,8 @@
         }
     }
 
+    LOG(Media, "MediaSessionManageriOS::configureWireLessTargetMonitoring - requiresMonitoring = %s", requiresMonitoring ? "true" : "false");
+
     if (requiresMonitoring)
         [m_objcObserver startMonitoringAirPlayRoutes];
     else
@@ -187,6 +191,8 @@
     
 void MediaSessionManageriOS::updateNowPlayingInfo()
 {
+    LOG(Media, "MediaSessionManageriOS::updateNowPlayingInfo");
+
     MPNowPlayingInfoCenter *nowPlaying = (MPNowPlayingInfoCenter *)[getMPNowPlayingInfoCenterClass() defaultCenter];
     const MediaSession* currentSession = this->currentSession();
     
@@ -224,6 +230,8 @@
 
 - (id)initWithCallback:(MediaSessionManageriOS*)callback
 {
+    LOG(Media, "-[WebMediaSessionHelper initWithCallback]");
+
     if (!(self = [super init]))
         return nil;
     
@@ -249,17 +257,38 @@
 
 - (void)dealloc
 {
+    LOG(Media, "-[WebMediaSessionHelper dealloc]");
+
+    if (!isMainThread()) {
+        auto volumeView = WTF::move(_volumeView);
+        auto routingController = WTF::move(_airPlayPresenceRoutingController);
+
+        callOnMainThread([volumeView, routingController] () mutable {
+            LOG(Media, "-[WebMediaSessionHelper dealloc] - dipatched to MainThread");
+
+            volumeView.clear();
+
+            if (!routingController)
+                return;
+
+            [routingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
+            routingController.clear();
+        });
+    }
+
     [[NSNotificationCenter defaultCenter] removeObserver:self];
     [super dealloc];
 }
 
 - (void)clearCallback
 {
+    LOG(Media, "-[WebMediaSessionHelper clearCallback]");
     _callback = nil;
 }
 
 - (BOOL)hasWirelessTargetsAvailable
 {
+    LOG(Media, "-[WebMediaSessionHelper hasWirelessTargetsAvailable]");
     return [_volumeView areWirelessRoutesAvailable];
 }
 
@@ -268,8 +297,18 @@
     if (_airPlayPresenceRoutingController)
         return;
 
-    _airPlayPresenceRoutingController = adoptNS([[getMPAVRoutingControllerClass() alloc] initWithName:@"WebCore - HTML media element checking for AirPlay route presence"]);
-    [_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModePresence];
+    LOG(Media, "-[WebMediaSessionHelper startMonitoringAirPlayRoutes]");
+
+    RetainPtr<WebMediaSessionHelper> strongSelf = self;
+    callOnMainThread([strongSelf] () {
+        LOG(Media, "-[WebMediaSessionHelper startMonitoringAirPlayRoutes] - dipatched to MainThread");
+
+        if (strongSelf->_airPlayPresenceRoutingController)
+            return;
+
+        strongSelf->_airPlayPresenceRoutingController = adoptNS([[getMPAVRoutingControllerClass() alloc] initWithName:@"WebCore - HTML media element checking for AirPlay route presence"]);
+        [strongSelf->_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModePresence];
+    });
 }
 
 - (void)stopMonitoringAirPlayRoutes
@@ -277,8 +316,18 @@
     if (!_airPlayPresenceRoutingController)
         return;
 
-    [_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
-    _airPlayPresenceRoutingController = nil;
+    LOG(Media, "-[WebMediaSessionHelper stopMonitoringAirPlayRoutes]");
+
+    RetainPtr<WebMediaSessionHelper> strongSelf = self;
+    callOnMainThread([strongSelf] () {
+        LOG(Media, "-[WebMediaSessionHelper stopMonitoringAirPlayRoutes] - dipatched to MainThread");
+
+        if (!strongSelf->_airPlayPresenceRoutingController)
+            return;
+
+        [strongSelf->_airPlayPresenceRoutingController setDiscoveryMode:MPRouteDiscoveryModeDisabled];
+        strongSelf->_airPlayPresenceRoutingController = nil;
+    });
 }
 
 - (void)interruption:(NSNotification *)notification
@@ -289,6 +338,8 @@
     NSUInteger type = [[[notification userInfo] objectForKey:AVAudioSessionInterruptionTypeKey] unsignedIntegerValue];
     MediaSession::EndInterruptionFlags flags = MediaSession::NoFlags;
 
+    LOG(Media, "-[WebMediaSessionHelper interruption] - type = %i", (int)type);
+
     if (type == AVAudioSessionInterruptionTypeEnded && [[[notification userInfo] objectForKey:AVAudioSessionInterruptionOptionKey] unsignedIntegerValue] == AVAudioSessionInterruptionOptionShouldResume)
         flags = MediaSession::MayResumePlaying;
 
@@ -311,6 +362,8 @@
     if (!_callback)
         return;
 
+    LOG(Media, "-[WebMediaSessionHelper applicationWillEnterForeground]");
+
     WebThreadRun(^{
         if (!_callback)
             return;
@@ -326,6 +379,8 @@
     if (!_callback)
         return;
 
+    LOG(Media, "-[WebMediaSessionHelper applicationDidBecomeActive]");
+
     WebThreadRun(^{
         if (!_callback)
             return;
@@ -340,7 +395,9 @@
 
     if (!_callback)
         return;
-    
+
+    LOG(Media, "-[WebMediaSessionHelper applicationWillResignActive]");
+
     WebThreadRun(^{
         if (!_callback)
             return;
@@ -356,6 +413,8 @@
     if (!_callback)
         return;
 
+    LOG(Media, "-[WebMediaSessionHelper wirelessRoutesAvailableDidChange]");
+
     WebThreadRun(^{
         if (!_callback)
             return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to