Title: [171157] trunk/Source/WebCore
- Revision
- 171157
- Author
- [email protected]
- Date
- 2014-07-16 16:11:49 -0700 (Wed, 16 Jul 2014)
Log 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.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (171156 => 171157)
--- trunk/Source/WebCore/ChangeLog 2014-07-16 23:08:26 UTC (rev 171156)
+++ trunk/Source/WebCore/ChangeLog 2014-07-16 23:11:49 UTC (rev 171157)
@@ -1,3 +1,21 @@
+2014-07-16 Eric Carlson <[email protected]>
+
+ [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.
+
2014-07-16 Jer Noble <[email protected]>
[MSE] http/tests/media/media-source/mediasource-buffered.html is flakey
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h (171156 => 171157)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2014-07-16 23:08:26 UTC (rev 171156)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.h 2014-07-16 23:11:49 UTC (rev 171157)
@@ -205,6 +205,8 @@
virtual void syncTextTrackBounds() override;
#endif
+ void setAVPlayerItem(AVPlayerItem *);
+
void createImageGenerator();
void destroyImageGenerator();
RetainPtr<CGImageRef> createImageForTimeInRect(float, const IntRect&);
Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm (171156 => 171157)
--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-07-16 23:08:26 UTC (rev 171156)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaPlayerPrivateAVFoundationObjC.mm 2014-07-16 23:11:49 UTC (rev 171157)
@@ -106,6 +106,7 @@
@property (nonatomic, readonly) NSURL *resolvedURL;
@end
+typedef AVPlayer AVPlayerType;
typedef AVPlayerItem AVPlayerItemType;
typedef AVMetadataItem AVMetadataItemType;
@@ -763,6 +764,23 @@
setDelayCallbacks(false);
}
+void MediaPlayerPrivateAVFoundationObjC::setAVPlayerItem(AVPlayerItemType *item)
+{
+ if (!m_avPlayer)
+ return;
+
+ if (pthread_main_np()) {
+ [m_avPlayer replaceCurrentItemWithPlayerItem:item];
+ return;
+ }
+
+ RetainPtr<AVPlayerType> strongPlayer = m_avPlayer.get();
+ RetainPtr<AVPlayerItemType> strongItem = item;
+ dispatch_async(dispatch_get_main_queue(), [strongPlayer, strongItem] {
+ [strongPlayer replaceCurrentItemWithPlayerItem:strongItem.get()];
+ });
+}
+
void MediaPlayerPrivateAVFoundationObjC::createAVPlayer()
{
if (m_avPlayer)
@@ -791,7 +809,7 @@
createAVPlayerLayer();
if (m_avPlayerItem)
- [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
+ setAVPlayerItem(m_avPlayerItem.get());
setDelayCallbacks(false);
}
@@ -815,7 +833,7 @@
[m_avPlayerItem.get() addObserver:m_objcObserver.get() forKeyPath:keyName options:options context:(void *)MediaPlayerAVFoundationObservationContextPlayerItem];
if (m_avPlayer)
- [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
+ setAVPlayerItem(m_avPlayerItem.get());
#if PLATFORM(IOS)
AtomicString value;
@@ -2398,10 +2416,7 @@
if (!m_avPlayer)
return;
- if (m_shouldBufferData)
- [m_avPlayer.get() replaceCurrentItemWithPlayerItem:m_avPlayerItem.get()];
- else
- [m_avPlayer.get() replaceCurrentItemWithPlayerItem:nil];
+ setAVPlayerItem(shouldBuffer ? m_avPlayerItem.get() : nil);
}
#if ENABLE(DATACUE_VALUE)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes