<!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>[236255] 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/236255">236255</a></dd>
<dt>Author</dt> <dd>philn@webkit.org</dd>
<dt>Date</dt> <dd>2018-09-20 02:18:01 -0700 (Thu, 20 Sep 2018)</dd>
</dl>

<h3>Log Message</h3>
<pre>[GStreamer] Utilities cleanups
https://bugs.webkit.org/show_bug.cgi?id=189699

Reviewed by Xabier Rodriguez-Calvar.

The GstMappedBuffer now has a move constructor so that it can be easily
reused in the webaudiosrc element. The now-unused corresponding
buffer-mapping utilities are removed from the code-base.

The HTTP source element used to handle a GstBuffer in its private
structure but this is no longer required since data is now pushed
in chunks, see bug #182829.

* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webKitWebAudioSrcLoop):
* platform/graphics/gstreamer/GStreamerCommon.cpp:
(WebCore::createGstBuffer): Deleted.
(WebCore::createGstBufferForData): Deleted.
(WebCore::getGstBufferDataPointer): Deleted.
(WebCore::mapGstBuffer): Deleted.
(WebCore::unmapGstBuffer): Deleted.
* platform/graphics/gstreamer/GStreamerCommon.h:
(WebCore::GstMappedBuffer::create): New method returning a
reference to a newly created GstMappedBuffer instance.
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(webKitWebSrcStop): Remove reference to unused GstBuffer.
(CachedResourceStreamingClient::dataReceived): Ditto.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreplatformaudiogstreamerWebKitWebAudioSourceGStreamercpp">trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommoncpp">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommonh">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (236254 => 236255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2018-09-20 09:00:15 UTC (rev 236254)
+++ trunk/Source/WebCore/ChangeLog      2018-09-20 09:18:01 UTC (rev 236255)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2018-09-20  Philippe Normand  <pnormand@igalia.com>
+
+        [GStreamer] Utilities cleanups
+        https://bugs.webkit.org/show_bug.cgi?id=189699
+
+        Reviewed by Xabier Rodriguez-Calvar.
+
+        The GstMappedBuffer now has a move constructor so that it can be easily
+        reused in the webaudiosrc element. The now-unused corresponding
+        buffer-mapping utilities are removed from the code-base.
+
+        The HTTP source element used to handle a GstBuffer in its private
+        structure but this is no longer required since data is now pushed
+        in chunks, see bug #182829.
+
+        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+        (webKitWebAudioSrcLoop):
+        * platform/graphics/gstreamer/GStreamerCommon.cpp:
+        (WebCore::createGstBuffer): Deleted.
+        (WebCore::createGstBufferForData): Deleted.
+        (WebCore::getGstBufferDataPointer): Deleted.
+        (WebCore::mapGstBuffer): Deleted.
+        (WebCore::unmapGstBuffer): Deleted.
+        * platform/graphics/gstreamer/GStreamerCommon.h:
+        (WebCore::GstMappedBuffer::create): New method returning a
+        reference to a newly created GstMappedBuffer instance.
+        * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+        (webKitWebSrcStop): Remove reference to unused GstBuffer.
+        (CachedResourceStreamingClient::dataReceived): Ditto.
+
</ins><span class="cx"> 2018-09-20  Simon Fraser  <simon.fraser@apple.com>
</span><span class="cx"> 
</span><span class="cx">         Fix crash under FontCache::purgeInactiveFontData() when a memory warning fires
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiogstreamerWebKitWebAudioSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (236254 => 236255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp  2018-09-20 09:00:15 UTC (rev 236254)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp     2018-09-20 09:18:01 UTC (rev 236255)
</span><span class="lines">@@ -308,7 +308,7 @@
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static void webKitWebAudioSrcLoop(WebKitWebAudioSrc* src)
</del><ins>+static std::optional<Vector<GRefPtr<GstBuffer>>> webKitWebAudioSrcAllocateBuffersAndRenderAudio(WebKitWebAudioSrc* src)
</ins><span class="cx"> {
</span><span class="cx">     WebKitWebAudioSourcePrivate* priv = src->priv;
</span><span class="cx"> 
</span><span class="lines">@@ -317,7 +317,7 @@
</span><span class="cx">     if (!priv->provider || !priv->bus) {
</span><span class="cx">         GST_ELEMENT_ERROR(src, CORE, FAILED, ("Internal WebAudioSrc error"), ("Can't start without provider or bus"));
</span><span class="cx">         gst_task_stop(src->priv->task.get());
</span><del>-        return;
</del><ins>+        return std::nullopt;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ASSERT(priv->pool);
</span><span class="lines">@@ -325,27 +325,25 @@
</span><span class="cx">     priv->numberOfSamples += priv->framesToPull;
</span><span class="cx">     GstClockTime duration = gst_util_uint64_scale(priv->numberOfSamples, GST_SECOND, priv->sampleRate) - timestamp;
</span><span class="cx"> 
</span><del>-    Vector<GRefPtr<GstBuffer>> channelBufferList;
-    channelBufferList.reserveInitialCapacity(priv->sources.size());
</del><ins>+    Vector<GRefPtr<GstBuffer>> channelBufferList(priv->sources.size());
+    Vector<GstMappedBuffer> mappedBuffers(priv->sources.size());
</ins><span class="cx">     for (unsigned i = 0; i < priv->sources.size(); ++i) {
</span><span class="cx">         GRefPtr<GstBuffer> buffer;
</span><span class="cx">         GstFlowReturn ret = gst_buffer_pool_acquire_buffer(priv->pool.get(), &buffer.outPtr(), nullptr);
</span><span class="cx">         if (ret != GST_FLOW_OK) {
</span><del>-            for (auto& buffer : channelBufferList)
-                unmapGstBuffer(buffer.get());
-
</del><span class="cx">             // FLUSHING and EOS are not errors.
</span><span class="cx">             if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED)
</span><span class="cx">                 GST_ELEMENT_ERROR(src, CORE, PAD, ("Internal WebAudioSrc error"), ("Failed to allocate buffer for flow: %s", gst_flow_get_name(ret)));
</span><del>-            gst_task_stop(src->priv->task.get());
-            return;
</del><ins>+            return std::nullopt;
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         ASSERT(buffer);
</span><span class="cx">         GST_BUFFER_TIMESTAMP(buffer.get()) = timestamp;
</span><span class="cx">         GST_BUFFER_DURATION(buffer.get()) = duration;
</span><del>-        mapGstBuffer(buffer.get(), GST_MAP_READWRITE);
-        priv->bus->setChannelMemory(i, reinterpret_cast<float*>(getGstBufferDataPointer(buffer.get())), priv->framesToPull);
</del><ins>+        GstMappedBuffer mappedBuffer(buffer.get(), GST_MAP_READWRITE);
+        ASSERT(mappedBuffer);
+        mappedBuffers.uncheckedAppend(WTFMove(mappedBuffer));
+        priv->bus->setChannelMemory(i, reinterpret_cast<float*>(mappedBuffers[i].data()), priv->framesToPull);
</ins><span class="cx">         channelBufferList.uncheckedAppend(WTFMove(buffer));
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -352,12 +350,24 @@
</span><span class="cx">     // FIXME: Add support for local/live audio input.
</span><span class="cx">     priv->provider->render(nullptr, priv->bus, priv->framesToPull);
</span><span class="cx"> 
</span><del>-    ASSERT(channelBufferList.size() == priv->sources.size());
</del><ins>+    return std::make_optional(channelBufferList);
+}
+
+static void webKitWebAudioSrcLoop(WebKitWebAudioSrc* src)
+{
+    WebKitWebAudioSourcePrivate* priv = src->priv;
+
+    std::optional<Vector<GRefPtr<GstBuffer>>> channelBufferList = webKitWebAudioSrcAllocateBuffersAndRenderAudio(src);
+    if (!channelBufferList) {
+        gst_task_stop(src->priv->task.get());
+        return;
+    }
+
+    ASSERT(channelBufferList->size() == priv->sources.size());
+
</ins><span class="cx">     bool failed = false;
</span><span class="cx">     for (unsigned i = 0; i < priv->sources.size(); ++i) {
</span><del>-        // Unmap before passing on the buffer.
-        auto& buffer = channelBufferList[i];
-        unmapGstBuffer(buffer.get());
</del><ins>+        auto& buffer = channelBufferList.value()[i];
</ins><span class="cx"> 
</span><span class="cx">         if (priv->enableGapBufferSupport && priv->bus->channel(i)->isSilent())
</span><span class="cx">             GST_BUFFER_FLAG_SET(buffer.get(), GST_BUFFER_FLAG_GAP);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommoncpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp (236254 => 236255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp     2018-09-20 09:00:15 UTC (rev 236254)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.cpp        2018-09-20 09:18:01 UTC (rev 236255)
</span><span class="lines">@@ -40,8 +40,6 @@
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><del>-const char* webkitGstMapInfoQuarkString = "webkit-gst-map-info";
-
</del><span class="cx"> GstPad* webkitGstGhostPadFromStaticTemplate(GstStaticPadTemplate* staticPadTemplate, const gchar* name, GstPad* target)
</span><span class="cx"> {
</span><span class="cx">     GstPad* pad;
</span><span class="lines">@@ -143,27 +141,7 @@
</span><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-GstBuffer* createGstBuffer(GstBuffer* buffer)
-{
-    gsize bufferSize = gst_buffer_get_size(buffer);
-    GstBuffer* newBuffer = gst_buffer_new_and_alloc(bufferSize);
</del><span class="cx"> 
</span><del>-    if (!newBuffer)
-        return 0;
-
-    gst_buffer_copy_into(newBuffer, buffer, static_cast<GstBufferCopyFlags>(GST_BUFFER_COPY_METADATA), 0, bufferSize);
-    return newBuffer;
-}
-
-GstBuffer* createGstBufferForData(const char* data, int length)
-{
-    GstBuffer* buffer = gst_buffer_new_and_alloc(length);
-
-    gst_buffer_fill(buffer, 0, data, length);
-
-    return buffer;
-}
-
</del><span class="cx"> const char* capsMediaType(const GstCaps* caps)
</span><span class="cx"> {
</span><span class="cx">     ASSERT(caps);
</span><span class="lines">@@ -205,38 +183,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-char* getGstBufferDataPointer(GstBuffer* buffer)
-{
-    GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
-    GstMapInfo* mapInfo = static_cast<GstMapInfo*>(gst_mini_object_get_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString)));
-    return reinterpret_cast<char*>(mapInfo->data);
-}
-
-void mapGstBuffer(GstBuffer* buffer, uint32_t flags)
-{
-    GstMapInfo* mapInfo = static_cast<GstMapInfo*>(fastMalloc(sizeof(GstMapInfo)));
-    if (!gst_buffer_map(buffer, mapInfo, static_cast<GstMapFlags>(flags))) {
-        fastFree(mapInfo);
-        gst_buffer_unref(buffer);
-        return;
-    }
-
-    GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
-    gst_mini_object_set_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString), mapInfo, nullptr);
-}
-
-void unmapGstBuffer(GstBuffer* buffer)
-{
-    GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
-    GstMapInfo* mapInfo = static_cast<GstMapInfo*>(gst_mini_object_steal_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString)));
-
-    if (!mapInfo)
-        return;
-
-    gst_buffer_unmap(buffer, mapInfo);
-    fastFree(mapInfo);
-}
-
</del><span class="cx"> Vector<String> extractGStreamerOptionsFromCommandLine()
</span><span class="cx"> {
</span><span class="cx">     GUniqueOutPtr<char> contents;
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerCommonh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h (236254 => 236255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h       2018-09-20 09:00:15 UTC (rev 236254)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerCommon.h  2018-09-20 09:18:01 UTC (rev 236255)
</span><span class="lines">@@ -63,14 +63,9 @@
</span><span class="cx"> std::optional<FloatSize> getVideoResolutionFromCaps(const GstCaps*);
</span><span class="cx"> bool getSampleVideoInfo(GstSample*, GstVideoInfo&);
</span><span class="cx"> #endif
</span><del>-GstBuffer* createGstBuffer(GstBuffer*);
-GstBuffer* createGstBufferForData(const char* data, int length);
-char* getGstBufferDataPointer(GstBuffer*);
</del><span class="cx"> const char* capsMediaType(const GstCaps*);
</span><span class="cx"> bool doCapsHaveType(const GstCaps*, const char*);
</span><span class="cx"> bool areEncryptedCaps(const GstCaps*);
</span><del>-void mapGstBuffer(GstBuffer*, uint32_t);
-void unmapGstBuffer(GstBuffer*);
</del><span class="cx"> Vector<String> extractGStreamerOptionsFromCommandLine();
</span><span class="cx"> bool initializeGStreamer(std::optional<Vector<String>>&& = std::nullopt);
</span><span class="cx"> unsigned getGstPlayFlag(const char* nick);
</span><span class="lines">@@ -84,11 +79,22 @@
</span><span class="cx"> class GstMappedBuffer {
</span><span class="cx">     WTF_MAKE_NONCOPYABLE(GstMappedBuffer);
</span><span class="cx"> public:
</span><ins>+
+    GstMappedBuffer() = default;
+    GstMappedBuffer(GstMappedBuffer&& other)
+        : m_buffer(other.m_buffer)
+        , m_info(other.m_info)
+        , m_isValid(other.m_isValid)
+    {
+        other.m_isValid = false;
+    }
+
</ins><span class="cx">     GstMappedBuffer(GstBuffer* buffer, GstMapFlags flags)
</span><span class="cx">         : m_buffer(buffer)
</span><span class="cx">     {
</span><span class="cx">         m_isValid = gst_buffer_map(m_buffer, &m_info, flags);
</span><span class="cx">     }
</span><ins>+
</ins><span class="cx">     // Unfortunately, GST_MAP_READWRITE is defined out of line from the MapFlags
</span><span class="cx">     // enum as an int, and C++ is careful to not implicity convert it to an enum.
</span><span class="cx">     GstMappedBuffer(GstBuffer* buffer, int flags)
</span><span class="lines">@@ -98,6 +104,7 @@
</span><span class="cx">     {
</span><span class="cx">         if (m_isValid)
</span><span class="cx">             gst_buffer_unmap(m_buffer, &m_info);
</span><ins>+        m_isValid = false;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     uint8_t* data() { ASSERT(m_isValid); return static_cast<uint8_t*>(m_info.data); }
</span><span class="lines">@@ -105,8 +112,8 @@
</span><span class="cx"> 
</span><span class="cx">     explicit operator bool() const { return m_isValid; }
</span><span class="cx"> private:
</span><del>-    GstBuffer* m_buffer;
-    GstMapInfo m_info;
</del><ins>+    GstBuffer* m_buffer { nullptr };
+    GstMapInfo m_info GST_MAP_INFO_INIT;
</ins><span class="cx">     bool m_isValid { false };
</span><span class="cx"> };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (236254 => 236255)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp    2018-09-20 09:00:15 UTC (rev 236254)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp       2018-09-20 09:18:01 UTC (rev 236255)
</span><span class="lines">@@ -103,7 +103,6 @@
</span><span class="cx">     uint64_t minimumBlocksize;
</span><span class="cx"> 
</span><span class="cx">     RefPtr<MainThreadNotifier<MainThreadSourceNotification>> notifier;
</span><del>-    GRefPtr<GstBuffer> buffer;
</del><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> enum {
</span><span class="lines">@@ -366,11 +365,6 @@
</span><span class="cx"> 
</span><span class="cx">     bool wasSeeking = std::exchange(priv->isSeeking, false);
</span><span class="cx"> 
</span><del>-    if (priv->buffer) {
-        unmapGstBuffer(priv->buffer.get());
-        priv->buffer.clear();
-    }
-
</del><span class="cx">     priv->paused = false;
</span><span class="cx"> 
</span><span class="cx">     priv->offset = 0;
</span><span class="lines">@@ -891,16 +885,8 @@
</span><span class="cx">     WebKitWebSrc* src = WEBKIT_WEB_SRC(m_src.get());
</span><span class="cx">     WebKitWebSrcPrivate* priv = src->priv;
</span><span class="cx"> 
</span><del>-    GST_LOG_OBJECT(src, "Have %lld bytes of data", priv->buffer ? static_cast<long long>(gst_buffer_get_size(priv->buffer.get())) : length);
-
-    ASSERT(!priv->buffer || data == getGstBufferDataPointer(priv->buffer.get()));
-
-    if (priv->buffer)
-        unmapGstBuffer(priv->buffer.get());
-
</del><span class="cx">     if (priv->isSeeking) {
</span><span class="cx">         GST_DEBUG_OBJECT(src, "Seek in progress, ignoring data");
</span><del>-        priv->buffer.clear();
</del><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -909,7 +895,6 @@
</span><span class="cx">         if (priv->offset + length <= priv->requestedOffset) {
</span><span class="cx">             // Discard all the buffers coming before the requested seek position.
</span><span class="cx">             priv->offset += length;
</span><del>-            priv->buffer.clear();
</del><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -917,8 +902,6 @@
</span><span class="cx">             guint64 offset = priv->requestedOffset - priv->offset;
</span><span class="cx">             data += offset;
</span><span class="cx">             length -= offset;
</span><del>-            if (priv->buffer)
-                gst_buffer_resize(priv->buffer.get(), offset, -1);
</del><span class="cx">             priv->offset = priv->requestedOffset;
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="lines">@@ -925,13 +908,6 @@
</span><span class="cx">         priv->requestedOffset = 0;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    // Ports using the GStreamer backend but not the soup implementation of ResourceHandle
-    // won't be using buffers provided by this client, the buffer is created here in that case.
-    if (!priv->buffer)
-        priv->buffer = adoptGRef(createGstBufferForData(data, length));
-    else
-        gst_buffer_set_size(priv->buffer.get(), static_cast<gssize>(length));
-
</del><span class="cx">     checkUpdateBlocksize(length);
</span><span class="cx"> 
</span><span class="cx">     uint64_t startingOffset = priv->offset;
</span><span class="lines">@@ -956,7 +932,7 @@
</span><span class="cx">         uint64_t subBufferOffset = startingOffset + currentOffset;
</span><span class="cx">         uint64_t currentOffsetSize = std::min(blockSize, bufferSize - currentOffset);
</span><span class="cx"> 
</span><del>-        GstBuffer* subBuffer = gst_buffer_copy_region(priv->buffer.get(), GST_BUFFER_COPY_ALL, currentOffset, currentOffsetSize);
</del><ins>+        GstBuffer* subBuffer = gst_buffer_new_wrapped(g_memdup(data + currentOffset, currentOffsetSize), currentOffsetSize);
</ins><span class="cx">         if (UNLIKELY(!subBuffer)) {
</span><span class="cx">             GST_ELEMENT_ERROR(src, CORE, FAILED, ("Failed to allocate sub-buffer"), (nullptr));
</span><span class="cx">             break;
</span><span class="lines">@@ -985,8 +961,6 @@
</span><span class="cx">             break;
</span><span class="cx">         }
</span><span class="cx">     }
</span><del>-
-    priv->buffer.clear();
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CachedResourceStreamingClient::accessControlCheckFailed(PlatformMediaResource&, const ResourceError& error)
</span></span></pre>
</div>
</div>

</body>
</html>