Changeset 171157 in webkit


Ignore:
Timestamp:
Jul 16, 2014 4:11:49 PM (10 years ago)
Author:
eric.carlson@apple.com
Message:

[Mac] replace AVPlayerItem on the main thread
https://bugs.webkit.org/show_bug.cgi?id=134983

Reviewed by Jer Noble.

No new tests, this fixes a problem with a thread configuration not present in the
test environment.

  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
  • platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:

(WebCore::MediaPlayerPrivateAVFoundationObjC::setAVPlayerItem): New, when called off of

the main thread, dispatch to the main thread before setting AVPlayerItem.

(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Call setAVPlayerItem.
(WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Ditto.
(WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldBufferData): Ditto.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r171151 r171157  
     12014-07-16  Eric Carlson  <eric.carlson@apple.com>
     2
     3        [Mac] replace AVPlayerItem on the main thread
     4        https://bugs.webkit.org/show_bug.cgi?id=134983
     5
     6        Reviewed by Jer Noble.
     7
     8        No new tests, this fixes a problem with a thread configuration not present in the
     9        test environment.
     10
     11        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h:
     12        * platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm:
     13        (WebCore::MediaPlayerPrivateAVFoundationObjC::setAVPlayerItem): New, when called off of
     14            the main thread, dispatch to the main thread before setting AVPlayerItem.
     15        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayer): Call setAVPlayerItem.
     16        (WebCore::MediaPlayerPrivateAVFoundationObjC::createAVPlayerItem): Ditto.
     17        (WebCore::MediaPlayerPrivateAVFoundationObjC::setShouldBufferData): Ditto.
     18
    1192014-07-16  Jer Noble  <jer.noble@apple.com>
    220
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h

    r170562 r171157  
    206206#endif
    207207
     208    void setAVPlayerItem(AVPlayerItem *);
     209
    208210    void createImageGenerator();
    209211    void destroyImageGenerator();
  • trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm

    r170562 r171157  
    107107@end
    108108
     109typedef AVPlayer AVPlayerType;
    109110typedef AVPlayerItem AVPlayerItemType;
    110111typedef AVMetadataItem AVMetadataItemType;
     
    764765}
    765766
     767void MediaPlayerPrivateAVFoundationObjC::setAVPlayerItem(AVPlayerItemType *item)
     768{
     769    if (!m_avPlayer)
     770        return;
     771
     772    if (pthread_main_np()) {
     773        [m_avPlayer replaceCurrentItemWithPlayerItem:item];
     774        return;
     775    }
     776
     777    RetainPtr<AVPlayerType> strongPlayer = m_avPlayer.get();
     778    RetainPtr<AVPlayerItemType> strongItem = item;
     779    dispatch_async(dispatch_get_main_queue(), [strongPlayer, strongItem] {
     780        [strongPlayer replaceCurrentItemWithPlayerItem:strongItem.get()];
     781    });
     782}
     783
    766784void MediaPlayerPrivateAVFoundationObjC::createAVPlayer()
    767785{
     
    792810
    793811    if (m_avPlayerItem)
    794         [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
     812        setAVPlayerItem(m_avPlayerItem.get());
    795813
    796814    setDelayCallbacks(false);
     
    816834
    817835    if (m_avPlayer)
    818         [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
     836        setAVPlayerItem(m_avPlayerItem.get());
    819837
    820838#if PLATFORM(IOS)
     
    23992417        return;
    24002418
    2401     if (m_shouldBufferData)
    2402         [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
    2403     else
    2404         [m_avPlayer.get() replaceCurrentItemWithPlayerItem:nil];
     2419    setAVPlayerItem(shouldBuffer ? m_avPlayerItem.get() : nil);
    24052420}
    24062421
Note: See TracChangeset for help on using the changeset viewer.