<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[160281] trunk/Source/WebCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/160281">160281</a></dd>
<dt>Author</dt> <dd>jer.noble@apple.com</dd>
<dt>Date</dt> <dd>2013-12-07 22:39:39 -0800 (Sat, 07 Dec 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>[MSE][Mac] Crash when removing MediaSource from HTMLMediaElement.
https://bugs.webkit.org/show_bug.cgi?id=125269

Reviewed by Sam Weinig.

Fixes the media/media-source/media-source-fastseek.html test when run with MallocScribble enabled.

It's possible for a SourceBufferPrivateAVFObjC to outlive its MediaSourcePrivateAVFObjC, so
make sure to clear the pointer from the former to the latter when the latter is destroyed.
That means we now have to check to see if the pointer to the latter is still valid at every
call site.

As a drive-by fix, rename m_parent to m_mediaSource to more accurately reflect what the pointer
points to.

* platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
(WebCore::MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC): Clear the SourceBuffer's backpointer.
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
(WebCore::SourceBufferPrivateAVFObjC::clearMediaSource):
* platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
(WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): Rename m_parent -&gt; m_mediaSource.
(WebCore::SourceBufferPrivateAVFObjC::append): Check m_mediaSource before calling.
(WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::readyState): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::setReadyState): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Ditto.
(WebCore::SourceBufferPrivateAVFObjC::setActive): Ditto.
* platform/mock/mediasource/MockMediaSourcePrivate.cpp:
(WebCore::MockMediaSourcePrivate::~MockMediaSourcePrivate): Clear the SourceBuffer's backpointer.
* platform/mock/mediasource/MockSourceBufferPrivate.cpp:
(WebCore::MockSourceBufferPrivate::MockSourceBufferPrivate): Rename m_parent -&gt; m_mediaSource.
(WebCore::MockSourceBufferPrivate::removedFromMediaSource): Check m_mediaSource before calling.
(WebCore::MockSourceBufferPrivate::readyState): Ditto.
(WebCore::MockSourceBufferPrivate::setReadyState): Ditto.
(WebCore::MockSourceBufferPrivate::setActive): Ditto.
* platform/mock/mediasource/MockSourceBufferPrivate.h:
(WebCore::MockSourceBufferPrivate::clearMediaSource):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm">trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockMediaSourcePrivatecpp">trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivatecpp">trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivateh">trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/ChangeLog        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -1,3 +1,45 @@
</span><ins>+2013-12-04  Jer Noble  &lt;jer.noble@apple.com&gt;
+
+        [MSE][Mac] Crash when removing MediaSource from HTMLMediaElement.
+        https://bugs.webkit.org/show_bug.cgi?id=125269
+
+        Reviewed by Sam Weinig.
+
+        Fixes the media/media-source/media-source-fastseek.html test when run with MallocScribble enabled.
+
+        It's possible for a SourceBufferPrivateAVFObjC to outlive its MediaSourcePrivateAVFObjC, so
+        make sure to clear the pointer from the former to the latter when the latter is destroyed.
+        That means we now have to check to see if the pointer to the latter is still valid at every
+        call site.
+
+        As a drive-by fix, rename m_parent to m_mediaSource to more accurately reflect what the pointer
+        points to.
+
+        * platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm:
+        (WebCore::MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC): Clear the SourceBuffer's backpointer.
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h:
+        (WebCore::SourceBufferPrivateAVFObjC::clearMediaSource): 
+        * platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm:
+        (WebCore::SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC): Rename m_parent -&gt; m_mediaSource.
+        (WebCore::SourceBufferPrivateAVFObjC::append): Check m_mediaSource before calling.
+        (WebCore::SourceBufferPrivateAVFObjC::removedFromMediaSource): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::readyState): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::setReadyState): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::trackDidChangeEnabled): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::flushAndEnqueueNonDisplayingSamples): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::enqueueSample): Ditto.
+        (WebCore::SourceBufferPrivateAVFObjC::setActive): Ditto.
+        * platform/mock/mediasource/MockMediaSourcePrivate.cpp:
+        (WebCore::MockMediaSourcePrivate::~MockMediaSourcePrivate): Clear the SourceBuffer's backpointer.
+        * platform/mock/mediasource/MockSourceBufferPrivate.cpp:
+        (WebCore::MockSourceBufferPrivate::MockSourceBufferPrivate): Rename m_parent -&gt; m_mediaSource.
+        (WebCore::MockSourceBufferPrivate::removedFromMediaSource): Check m_mediaSource before calling.
+        (WebCore::MockSourceBufferPrivate::readyState): Ditto.
+        (WebCore::MockSourceBufferPrivate::setReadyState): Ditto.
+        (WebCore::MockSourceBufferPrivate::setActive): Ditto.
+        * platform/mock/mediasource/MockSourceBufferPrivate.h:
+        (WebCore::MockSourceBufferPrivate::clearMediaSource):
+
</ins><span class="cx"> 2013-12-07  Zoltan Horvath  &lt;zoltan@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         Remove statusWithDirection static function from RenderBlockLineLayout
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcMediaSourcePrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -57,6 +57,8 @@
</span><span class="cx"> 
</span><span class="cx"> MediaSourcePrivateAVFObjC::~MediaSourcePrivateAVFObjC()
</span><span class="cx"> {
</span><ins>+    for (auto it = m_sourceBuffers.begin(), end = m_sourceBuffers.end(); it != end; ++it)
+        (*it)-&gt;clearMediaSource();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaSourcePrivate::AddStatus MediaSourcePrivateAVFObjC::addSourceBuffer(const ContentType&amp; contentType, RefPtr&lt;SourceBufferPrivate&gt;&amp; outPrivate)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.h        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -59,6 +59,8 @@
</span><span class="cx">     static RefPtr&lt;SourceBufferPrivateAVFObjC&gt; create(MediaSourcePrivateAVFObjC*);
</span><span class="cx">     virtual ~SourceBufferPrivateAVFObjC();
</span><span class="cx"> 
</span><ins>+    void clearMediaSource() { m_mediaSource = nullptr; }
+
</ins><span class="cx">     // AVStreamDataParser delegate methods
</span><span class="cx">     void didParseStreamDataAsAsset(AVAsset*);
</span><span class="cx">     void didFailToParseStreamDataWithError(NSError*);
</span><span class="lines">@@ -101,7 +103,7 @@
</span><span class="cx">     RetainPtr&lt;AVSampleBufferDisplayLayer&gt; m_displayLayer;
</span><span class="cx">     RetainPtr&lt;NSObject&gt; m_delegate;
</span><span class="cx"> 
</span><del>-    MediaSourcePrivateAVFObjC* m_parent;
</del><ins>+    MediaSourcePrivateAVFObjC* m_mediaSource;
</ins><span class="cx">     SourceBufferPrivateClient* m_client;
</span><span class="cx"> 
</span><span class="cx">     bool m_parsingSucceeded;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsavfoundationobjcSourceBufferPrivateAVFObjCmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -284,7 +284,7 @@
</span><span class="cx"> SourceBufferPrivateAVFObjC::SourceBufferPrivateAVFObjC(MediaSourcePrivateAVFObjC* parent)
</span><span class="cx">     : m_parser(adoptNS([[getAVStreamDataParserClass() alloc] init]))
</span><span class="cx">     , m_delegate(adoptNS([[WebAVStreamDataParserListener alloc] initWithParser:m_parser.get() parent:this]))
</span><del>-    , m_parent(parent)
</del><ins>+    , m_mediaSource(parent)
</ins><span class="cx">     , m_client(0)
</span><span class="cx">     , m_parsingSucceeded(true)
</span><span class="cx"> {
</span><span class="lines">@@ -293,7 +293,8 @@
</span><span class="cx"> SourceBufferPrivateAVFObjC::~SourceBufferPrivateAVFObjC()
</span><span class="cx"> {
</span><span class="cx">     if (m_displayLayer) {
</span><del>-        m_parent-&gt;player()-&gt;removeDisplayLayer(m_displayLayer.get());
</del><ins>+        if (m_mediaSource)
+            m_mediaSource-&gt;player()-&gt;removeDisplayLayer(m_displayLayer.get());
</ins><span class="cx">         [m_displayLayer flushAndRemoveImage];
</span><span class="cx">         [m_displayLayer stopRequestingMediaData];
</span><span class="cx">         m_displayLayer = nullptr;
</span><span class="lines">@@ -386,8 +387,8 @@
</span><span class="cx">     LOG(Media, &quot;SourceBufferPrivateAVFObjC::append(%p) - data:%p, length:%d&quot;, this, data, length);
</span><span class="cx">     [m_parser appendStreamData:[NSData dataWithBytes:data length:length]];
</span><span class="cx"> 
</span><del>-    if (m_parsingSucceeded)
-        m_parent-&gt;player()-&gt;setLoadingProgresssed(true);
</del><ins>+    if (m_parsingSucceeded &amp;&amp; m_mediaSource)
+        m_mediaSource-&gt;player()-&gt;setLoadingProgresssed(true);
</ins><span class="cx"> 
</span><span class="cx">     return m_parsingSucceeded ? AppendSucceeded : ParsingFailed;
</span><span class="cx"> }
</span><span class="lines">@@ -400,23 +401,26 @@
</span><span class="cx"> void SourceBufferPrivateAVFObjC::removedFromMediaSource()
</span><span class="cx"> {
</span><span class="cx">     if (m_displayLayer) {
</span><del>-        m_parent-&gt;player()-&gt;removeDisplayLayer(m_displayLayer.get());
</del><ins>+        if (m_mediaSource)
+            m_mediaSource-&gt;player()-&gt;removeDisplayLayer(m_displayLayer.get());
</ins><span class="cx">         [m_displayLayer flush];
</span><span class="cx">         [m_displayLayer stopRequestingMediaData];
</span><span class="cx">         m_displayLayer = nullptr;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_parent-&gt;removeSourceBuffer(this);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;removeSourceBuffer(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaPlayer::ReadyState SourceBufferPrivateAVFObjC::readyState() const
</span><span class="cx"> {
</span><del>-    return m_parent-&gt;player()-&gt;readyState();
</del><ins>+    return m_mediaSource ? m_mediaSource-&gt;player()-&gt;readyState() : MediaPlayer::HaveNothing;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SourceBufferPrivateAVFObjC::setReadyState(MediaPlayer::ReadyState readyState)
</span><span class="cx"> {
</span><del>-    m_parent-&gt;player()-&gt;setReadyState(readyState);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;player()-&gt;setReadyState(readyState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SourceBufferPrivateAVFObjC::evictCodedFrames()
</span><span class="lines">@@ -453,6 +457,8 @@
</span><span class="cx">     if (!track-&gt;selected() &amp;&amp; m_enabledVideoTrackID == trackID) {
</span><span class="cx">         m_enabledVideoTrackID = -1;
</span><span class="cx">         [m_parser setShouldProvideMediaData:NO forTrackID:trackID];
</span><ins>+        if (m_mediaSource)
+            m_mediaSource-&gt;player()-&gt;removeDisplayLayer(m_displayLayer.get());
</ins><span class="cx">     } else if (track-&gt;selected()) {
</span><span class="cx">         m_enabledVideoTrackID = trackID;
</span><span class="cx">         [m_parser setShouldProvideMediaData:YES forTrackID:trackID];
</span><span class="lines">@@ -462,7 +468,8 @@
</span><span class="cx">                 if (m_client)
</span><span class="cx">                     m_client-&gt;sourceBufferPrivateDidBecomeReadyForMoreSamples(this);
</span><span class="cx">             }];
</span><del>-            m_parent-&gt;player()-&gt;addDisplayLayer(m_displayLayer.get());
</del><ins>+            if (m_mediaSource)
+                m_mediaSource-&gt;player()-&gt;addDisplayLayer(m_displayLayer.get());
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="lines">@@ -508,7 +515,8 @@
</span><span class="cx">         [m_displayLayer enqueueSampleBuffer:sampleBuffer.get()];
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_parent-&gt;player()-&gt;setHasAvailableVideoFrame(false);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;player()-&gt;setHasAvailableVideoFrame(false);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void SourceBufferPrivateAVFObjC::enqueueSample(PassRefPtr&lt;MediaSample&gt; prpMediaSample, AtomicString trackID)
</span><span class="lines">@@ -523,7 +531,8 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     [m_displayLayer enqueueSampleBuffer:platformSample.sample.cmSampleBuffer];
</span><del>-    m_parent-&gt;player()-&gt;setHasAvailableVideoFrame(true);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;player()-&gt;setHasAvailableVideoFrame(true);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool SourceBufferPrivateAVFObjC::isReadyForMoreSamples()
</span><span class="lines">@@ -533,7 +542,8 @@
</span><span class="cx"> 
</span><span class="cx"> void SourceBufferPrivateAVFObjC::setActive(bool isActive)
</span><span class="cx"> {
</span><del>-    m_parent-&gt;sourceBufferPrivateDidChangeActiveState(this, isActive);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;sourceBufferPrivateDidChangeActiveState(this, isActive);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaTime SourceBufferPrivateAVFObjC::fastSeekTimeForMediaTime(MediaTime time, MediaTime negativeThreshold, MediaTime positiveThreshold)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockMediaSourcePrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockMediaSourcePrivate.cpp        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -49,6 +49,8 @@
</span><span class="cx"> 
</span><span class="cx"> MockMediaSourcePrivate::~MockMediaSourcePrivate()
</span><span class="cx"> {
</span><ins>+    for (auto it = m_sourceBuffers.begin(), end = m_sourceBuffers.end(); it != end; ++it)
+        (*it)-&gt;clearMediaSource();
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaSourcePrivate::AddStatus MockMediaSourcePrivate::addSourceBuffer(const ContentType&amp; contentType, RefPtr&lt;SourceBufferPrivate&gt;&amp; outPrivate)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.cpp        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -100,7 +100,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MockSourceBufferPrivate::MockSourceBufferPrivate(MockMediaSourcePrivate* parent)
</span><del>-    : m_parent(parent)
</del><ins>+    : m_mediaSource(parent)
</ins><span class="cx">     , m_client(0)
</span><span class="cx"> {
</span><span class="cx"> }
</span><span class="lines">@@ -187,17 +187,19 @@
</span><span class="cx"> 
</span><span class="cx"> void MockSourceBufferPrivate::removedFromMediaSource()
</span><span class="cx"> {
</span><del>-    m_parent-&gt;removeSourceBuffer(this);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;removeSourceBuffer(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> MediaPlayer::ReadyState MockSourceBufferPrivate::readyState() const
</span><span class="cx"> {
</span><del>-    return m_parent-&gt;player()-&gt;readyState();
</del><ins>+    return m_mediaSource ? m_mediaSource-&gt;player()-&gt;readyState() : MediaPlayer::HaveNothing;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockSourceBufferPrivate::setReadyState(MediaPlayer::ReadyState readyState)
</span><span class="cx"> {
</span><del>-    m_parent-&gt;player()-&gt;setReadyState(readyState);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;player()-&gt;setReadyState(readyState);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void MockSourceBufferPrivate::evictCodedFrames()
</span><span class="lines">@@ -212,7 +214,8 @@
</span><span class="cx"> 
</span><span class="cx"> void MockSourceBufferPrivate::setActive(bool isActive)
</span><span class="cx"> {
</span><del>-    m_parent-&gt;sourceBufferPrivateDidChangeActiveState(this, isActive);
</del><ins>+    if (m_mediaSource)
+        m_mediaSource-&gt;sourceBufferPrivateDidChangeActiveState(this, isActive);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> bool MockSourceBufferPrivate::hasVideo() const
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformmockmediasourceMockSourceBufferPrivateh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h (160280 => 160281)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h        2013-12-08 06:17:18 UTC (rev 160280)
+++ trunk/Source/WebCore/platform/mock/mediasource/MockSourceBufferPrivate.h        2013-12-08 06:39:39 UTC (rev 160281)
</span><span class="lines">@@ -50,6 +50,8 @@
</span><span class="cx">     static RefPtr&lt;MockSourceBufferPrivate&gt; create(MockMediaSourcePrivate*);
</span><span class="cx">     virtual ~MockSourceBufferPrivate();
</span><span class="cx"> 
</span><ins>+    void clearMediaSource() { m_mediaSource = nullptr; }
+
</ins><span class="cx">     bool hasVideo() const;
</span><span class="cx">     bool hasAudio() const;
</span><span class="cx"> 
</span><span class="lines">@@ -77,7 +79,7 @@
</span><span class="cx">     void didReceiveInitializationSegment(const MockInitializationBox&amp;);
</span><span class="cx">     void didReceiveSample(const MockSampleBox&amp;);
</span><span class="cx"> 
</span><del>-    MockMediaSourcePrivate* m_parent;
</del><ins>+    MockMediaSourcePrivate* m_mediaSource;
</ins><span class="cx">     SourceBufferPrivateClient* m_client;
</span><span class="cx"> 
</span><span class="cx">     Vector&lt;char&gt; m_inputBuffer;
</span></span></pre>
</div>
</div>

</body>
</html>