Modified: branches/safari-538.34-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp (169098 => 169099)
--- branches/safari-538.34-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2014-05-20 02:49:33 UTC (rev 169098)
+++ branches/safari-538.34-branch/Source/WebCore/Modules/mediasource/SourceBuffer.cpp 2014-05-20 02:56:33 UTC (rev 169099)
@@ -107,6 +107,7 @@
, m_pendingRemoveEnd(MediaTime::invalidTime())
, m_removeTimer(this, &SourceBuffer::removeTimerFired)
{
+ ASSERT(m_private);
ASSERT(m_source);
m_private->setClient(this);
@@ -473,7 +474,7 @@
// 1. Loop Top: If the input buffer is empty, then jump to the need more data step below.
if (!m_pendingAppendData.size()) {
- sourceBufferPrivateAppendComplete(&m_private.get(), AppendSucceeded);
+ sourceBufferPrivateAppendComplete(m_private.get(), AppendSucceeded);
return;
}
Modified: branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (169098 => 169099)
--- branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2014-05-20 02:49:33 UTC (rev 169098)
+++ branches/safari-538.34-branch/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm 2014-05-20 02:56:33 UTC (rev 169099)
@@ -153,14 +153,14 @@
#pragma mark WebAVStreamDataParserListener
@interface WebAVStreamDataParserListener : NSObject {
- WeakPtr<WebCore::SourceBufferPrivateAVFObjC> _parent;
+ WebCore::SourceBufferPrivateAVFObjC* _parent;
AVStreamDataParser* _parser;
}
-- (id)initWithParser:(AVStreamDataParser*)parser parent:(WeakPtr<WebCore::SourceBufferPrivateAVFObjC>)parent;
+- (id)initWithParser:(AVStreamDataParser*)parser parent:(WebCore::SourceBufferPrivateAVFObjC*)parent;
@end
@implementation WebAVStreamDataParserListener
-- (id)initWithParser:(AVStreamDataParser*)parser parent:(WeakPtr<WebCore::SourceBufferPrivateAVFObjC>)parent
+- (id)initWithParser:(AVStreamDataParser*)parser parent:(WebCore::SourceBufferPrivateAVFObjC*)parent
{
self = [super init];
if (!self)
@@ -182,6 +182,7 @@
- (void)invalidate
{
[_parser setDelegate:nil];
+ _parent = nullptr;
_parser = nullptr;
}
@@ -191,12 +192,13 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
RetainPtr<AVAsset*> strongAsset = asset;
- callOnMainThread([strongSelf, strongAsset] {
- if (strongSelf->_parent)
- strongSelf->_parent->didParseStreamDataAsAsset(strongAsset.get());
+ callOnMainThread([strongParent, strongAsset] {
+ strongParent->didParseStreamDataAsAsset(strongAsset.get());
});
}
@@ -207,12 +209,13 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
RetainPtr<AVAsset*> strongAsset = asset;
- callOnMainThread([strongSelf, strongAsset] {
- if (strongSelf->_parent)
- strongSelf->_parent->didParseStreamDataAsAsset(strongAsset.get());
+ callOnMainThread([strongParent, strongAsset] {
+ strongParent->didParseStreamDataAsAsset(strongAsset.get());
});
}
@@ -222,12 +225,13 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
RetainPtr<NSError> strongError = error;
- callOnMainThread([strongSelf, strongError] {
- if (strongSelf->_parent)
- strongSelf->_parent->didFailToParseStreamDataWithError(strongError.get());
+ callOnMainThread([strongParent, strongError] {
+ strongParent->didFailToParseStreamDataWithError(strongError.get());
});
}
@@ -237,13 +241,14 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
RetainPtr<CMSampleBufferRef> strongSample = sample;
String mediaType = nsMediaType;
- callOnMainThread([strongSelf, strongSample, trackID, mediaType, flags] {
- if (strongSelf->_parent)
- strongSelf->_parent->didProvideMediaDataForTrackID(trackID, strongSample.get(), mediaType, flags);
+ callOnMainThread([strongParent, strongSample, trackID, mediaType, flags] {
+ strongParent->didProvideMediaDataForTrackID(trackID, strongSample.get(), mediaType, flags);
});
}
@@ -253,12 +258,13 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
String mediaType = nsMediaType;
- callOnMainThread([strongSelf, trackID, mediaType] {
- if (strongSelf->_parent)
- strongSelf->_parent->didReachEndOfTrackWithTrackID(trackID, mediaType);
+ callOnMainThread([strongParent, trackID, mediaType] {
+ strongParent->didReachEndOfTrackWithTrackID(trackID, mediaType);
});
}
@@ -268,12 +274,13 @@
UNUSED_PARAM(streamDataParser);
#endif
ASSERT(streamDataParser == _parser);
- RetainPtr<WebAVStreamDataParserListener> strongSelf = self;
+ RefPtr<WebCore::SourceBufferPrivateAVFObjC> strongParent = _parent;
+ if (!strongParent)
+ return;
RetainPtr<NSData> strongData = initData;
- callOnMainThread([strongSelf, strongData, trackID] {
- if (strongSelf->_parent)
- strongSelf->_parent->didProvideContentKeyRequestInitializationDataForTrackID(strongData.get(), trackID);
+ callOnMainThread([strongParent, strongData, trackID] {
+ strongParent->didProvideContentKeyRequestInitializationDataForTrackID(strongData.get(), trackID);
});
}
@end
@@ -379,9 +386,8 @@
}
SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
- : m_weakFactory(this)
- , m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
- , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:createWeakPtr()]))
+ : m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
+ , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:this]))
, m_mediaSource(parent)
, m_client(0)
, m_parsingSucceeded(true)
@@ -392,7 +398,6 @@
SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC()
{
- ASSERT(!m_client);
destroyParser();
destroyRenderers();
}
@@ -464,8 +469,7 @@
if (formatSize != m_cachedSize) {
LOG(Media, "SourceBufferPrivateAVFObjC::processCodedFrame(%p) - size change detected: {width=%lf, height=%lf", formatSize.width(), formatSize.height());
m_cachedSize = formatSize;
- if (m_mediaSource)
- m_mediaSource->player()->sizeChanged();
+ m_mediaSource->player()->sizeChanged();
}
}
if (m_client)
@@ -483,9 +487,6 @@
void SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(NSData* initData, int trackID)
{
- if (!m_mediaSource)
- return;
-
UNUSED_PARAM(trackID);
#if ENABLE(ENCRYPTED_MEDIA_V2)
LOG(Media, "SourceBufferPrivateAVFObjC::didProvideContentKeyRequestInitializationDataForTrackID(%p) - track:%d", this, trackID);
@@ -518,19 +519,15 @@
LOG(Media, "SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d", this, data, length);
RetainPtr<NSData> nsData = adoptNS([[NSData alloc] initWithBytes:data length:length]);
- WeakPtr<SourceBufferPrivateAVFObjC> weakThis = createWeakPtr();
- RetainPtr<AVStreamDataParser> parser = m_parser;
- RetainPtr<WebAVStreamDataParserListener> delegate = m_delegate;
+ RefPtr<SourceBufferPrivateAVFObjC> strongThis = this;
m_parsingSucceeded = true;
- dispatch_async(globalDataParserQueue(), [nsData, weakThis, parser, delegate] {
+ dispatch_async(globalDataParserQueue(), [nsData, strongThis] {
+ [strongThis->m_parser appendStreamData:nsData.get()];
- [parser appendStreamData:nsData.get()];
-
- callOnMainThread([weakThis] {
- if (weakThis)
- weakThis->appendCompleted();
+ callOnMainThread([strongThis] {
+ strongThis->appendCompleted();
});
});
}