Title: [168794] branches/safari-538.34-branch/Source/WebCore

Diff

Modified: branches/safari-538.34-branch/Source/WebCore/ChangeLog (168793 => 168794)


--- branches/safari-538.34-branch/Source/WebCore/ChangeLog	2014-05-14 06:39:49 UTC (rev 168793)
+++ branches/safari-538.34-branch/Source/WebCore/ChangeLog	2014-05-14 06:42:24 UTC (rev 168794)
@@ -1,5 +1,30 @@
 2014-04-17  Lucas Forschler  <[email protected]>
 
+        Merge r168536
+
+    2014-05-09  Jer Noble  <[email protected]>
+
+            [MSE][Mac] Destroy the AVStreamDataParser when the SourceBuffer is removed from its MediaSource.
+            https://bugs.webkit.org/show_bug.cgi?id=132710
+
+            Reviewed by Eric Carlson.
+
+            The AVStreamDataParser should be destroyed when the SourceBuffer is removed, so that subsequent
+            SourceBuffers can utilize resources released by the parser on destruction.
+
+            * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+            * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+            (-[WebAVStreamDataParserListener invalidate]):
+            (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]):  Protect against _parent being invalidated.
+            (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): Ditto.
+            (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): Ditto.
+            (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): Ditto.
+            (WebCore::SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC): Call destroyParser();.
+            (WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Ditto.
+            (WebCore::SourceBufferPrivateAVFObjC::destroyParser): Call -[WebAVStreamDataParserListener invalidate].
+
+2014-04-17  Lucas Forschler  <[email protected]>
+
         Merge r168519
 
     2014-05-08  Brent Fulgham  <[email protected]>

Modified: branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (168793 => 168794)


--- branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2014-05-14 06:39:49 UTC (rev 168793)
+++ branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h	2014-05-14 06:42:24 UTC (rev 168794)
@@ -45,6 +45,7 @@
 OBJC_CLASS NSData;
 OBJC_CLASS NSError;
 OBJC_CLASS NSObject;
+OBJC_CLASS WebAVStreamDataParserListener;
 typedef struct opaqueCMSampleBuffer *CMSampleBufferRef;
 typedef const struct opaqueCMFormatDescription *CMFormatDescriptionRef;
 
@@ -109,6 +110,7 @@
 
     void didBecomeReadyForMoreSamples(int trackID);
     void appendCompleted();
+    void destroyParser();
     void destroyRenderers();
 
     Vector<RefPtr<VideoTrackPrivateMediaSourceAVFObjC>> m_videoTracks;
@@ -118,7 +120,7 @@
     RetainPtr<AVAsset> m_asset;
     RetainPtr<AVSampleBufferDisplayLayer> m_displayLayer;
     std::map<int, RetainPtr<AVSampleBufferAudioRenderer>> m_audioRenderers;
-    RetainPtr<NSObject> m_delegate;
+    RetainPtr<WebAVStreamDataParserListener> m_delegate;
 
     MediaSourcePrivateAVFObjC* m_mediaSource;
     SourceBufferPrivateClient* m_client;

Modified: branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (168793 => 168794)


--- branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2014-05-14 06:39:49 UTC (rev 168793)
+++ branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm	2014-05-14 06:42:24 UTC (rev 168794)
@@ -179,6 +179,13 @@
     [super dealloc];
 }
 
+- (void)invalidate
+{
+    [_parser setDelegate:nil];
+    _parent = nullptr;
+    _parser = nullptr;
+}
+
 - (void)streamDataParser:(AVStreamDataParser *)streamDataParser didParseStreamDataAsAsset:(AVAsset *)asset
 {
 #if ASSERT_DISABLED
@@ -186,6 +193,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     RetainPtr<AVAsset*> strongAsset = asset;
     callOnMainThread([strongParent, strongAsset] {
         strongParent->didParseStreamDataAsAsset(strongAsset.get());
@@ -200,6 +210,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     RetainPtr<AVAsset*> strongAsset = asset;
     callOnMainThread([strongParent, strongAsset] {
         strongParent->didParseStreamDataAsAsset(strongAsset.get());
@@ -213,6 +226,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     RetainPtr<NSError> strongError = error;
     callOnMainThread([strongParent, strongError] {
         strongParent->didFailToParseStreamDataWithError(strongError.get());
@@ -226,6 +242,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     RetainPtr<CMSampleBufferRef> strongSample = sample;
     String mediaType = nsMediaType;
     callOnMainThread([strongParent, strongSample, trackID, mediaType, flags] {
@@ -240,6 +259,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     String mediaType = nsMediaType;
     callOnMainThread([strongParent, trackID, mediaType] {
         strongParent->didReachEndOfTrackWithTrackID(trackID, mediaType);
@@ -253,6 +275,9 @@
 #endif
     ASSERT(streamDataParser == _parser);
     RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+    if (!strongParent)
+        return;
+
     RetainPtr<NSData> strongData = initData;
     callOnMainThread([strongParent, strongData, trackID] {
         strongParent->didProvideContentKeyRequestInitializationDataForTrackID(strongData.get(), trackID);
@@ -373,6 +398,7 @@
 
 SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC()
 {
+    destroyParser();
     destroyRenderers();
 }
 
@@ -520,6 +546,13 @@
     notImplemented();
 }
 
+void SourceBufferPrivateAVFObjC::destroyParser()
+{
+    [m_delegate invalidate];
+    m_delegate = nullptr;
+    m_parser = nullptr;
+}
+
 void SourceBufferPrivateAVFObjC::destroyRenderers()
 {
     if (m_displayLayer) {
@@ -543,6 +576,7 @@
 
 void SourceBufferPrivateAVFObjC::removedFromMediaSource()
 {
+    destroyParser();
     destroyRenderers();
 
     if (m_mediaSource)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to