⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176471 in webkit


Ignore:
Timestamp:
Nov 21, 2014, 1:22:47 PM (12 years ago)
Author:
eric.carlson@apple.com
Message:

[iOS] allocate volume view on the main thread
https://bugs.webkit.org/show_bug.cgi?id=138971
rdar://problem/18016958

Reviewed by Jer Noble.

  • platform/audio/ios/MediaSessionManagerIOS.mm:

(-[WebMediaSessionHelper allocateVolumeView]): New, dispatch to the main thread if necessary before allocating

the volume view.

(-[WebMediaSessionHelper initWithCallback:]): Call allocateVolumeView.

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176470 r176471  
     12014-11-21  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [iOS] allocate volume view on the main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=138971
     5        rdar://problem/18016958
     6
     7        Reviewed by Jer Noble.
     8
     9        * platform/audio/ios/MediaSessionManagerIOS.mm:
     10        (-[WebMediaSessionHelper allocateVolumeView]): New, dispatch to the main thread if necessary before allocating
     11            the volume view.
     12        (-[WebMediaSessionHelper initWithCallback:]): Call allocateVolumeView.
     13
    1142014-11-21  Zalan Bujtas  <zalan@apple.com>
    215
  • trunk/Source/WebCore/platform/audio/ios/MediaSessionManagerIOS.mm

    r176448 r176471  
    9696
    9797- (id)initWithCallback:(MediaSessionManageriOS*)callback;
     98- (void)allocateVolumeView;
    9899- (void)clearCallback;
    99100- (void)interruption:(NSNotification *)notification;
     
    229230@implementation WebMediaSessionHelper
    230231
     232- (void)allocateVolumeView
     233{
     234    if (!isMainThread()) {
     235        // Call synchronously to the main thread so that _volumeView will be completely setup before the constructor completes
     236        // because hasWirelessTargetsAvailable is synchronous and can be called on the WebThread.
     237        RetainPtr<WebMediaSessionHelper> strongSelf = self;
     238        dispatch_sync(dispatch_get_main_queue(), [strongSelf]() {
     239            [strongSelf allocateVolumeView];
     240            return;
     241        });
     242    }
     243
     244    _volumeView = adoptNS([[getMPVolumeViewClass() alloc] init]);
     245    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
     246   
     247}
     248
    231249- (id)initWithCallback:(MediaSessionManageriOS*)callback
    232250{
     
    237255   
    238256    _callback = callback;
    239     _volumeView = adoptNS([[getMPVolumeViewClass() alloc] init]);
    240257
    241258    NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
     
    248265    [center addObserver:self selector:@selector(applicationWillResignActive:) name:UIApplicationWillResignActiveNotification object:nil];
    249266    [center addObserver:self selector:@selector(applicationWillResignActive:) name:WebUIApplicationWillResignActiveNotification object:nil];
    250     [center addObserver:self selector:@selector(wirelessRoutesAvailableDidChange:) name:MPVolumeViewWirelessRoutesAvailableDidChangeNotification object:_volumeView.get()];
     267
     268    [self allocateVolumeView];
    251269
    252270    // Now playing won't work unless we turn on the delivery of remote control events.
Note: See TracChangeset for help on using the changeset viewer.