<!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>[210584] 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/210584">210584</a></dd>
<dt>Author</dt> <dd>carlosgc@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-11 03:27:38 -0800 (Wed, 11 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GStreamer] Use smart pointers and modernize code in WebKitWebAudioSourceGStreamer
https://bugs.webkit.org/show_bug.cgi?id=166886
Reviewed by Xabier Rodriguez-Calvar.
This patch doesn't change the behavior, so it's covered by existing Web Audio tests. It replaces pointers with
smart pointers, uses WTF::Vector instead of GSList and simplifies the code to map/unmap GstBuffers.
* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webKitWebAudioSrcConstructed):
(webKitWebAudioSrcFinalize):
(webKitWebAudioSrcLoop):
(webKitWebAudioSrcChangeState):
* platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
(WTF::derefGPtr<GstBufferList>):
(WTF::adoptGRef):
(WTF::refGPtr<GstBufferPool>):
(WTF::derefGPtr<GstBufferPool>):
* platform/graphics/gstreamer/GRefPtrGStreamer.h:
* platform/graphics/gstreamer/GStreamerUtilities.cpp:
(WebCore::mapGstBuffer):
* platform/graphics/gstreamer/GStreamerUtilities.h:
* platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
(StreamingClient::createReadBuffer):</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="#trunkSourceWebCoreplatformgraphicsgstreamerGRefPtrGStreamercpp">trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGRefPtrGStreamerh">trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiesh">trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.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 (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/ChangeLog        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2017-01-11 Carlos Garcia Campos <cgarcia@igalia.com>
+
+ [GStreamer] Use smart pointers and modernize code in WebKitWebAudioSourceGStreamer
+ https://bugs.webkit.org/show_bug.cgi?id=166886
+
+ Reviewed by Xabier Rodriguez-Calvar.
+
+ This patch doesn't change the behavior, so it's covered by existing Web Audio tests. It replaces pointers with
+ smart pointers, uses WTF::Vector instead of GSList and simplifies the code to map/unmap GstBuffers.
+
+ * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+ (webKitWebAudioSrcConstructed):
+ (webKitWebAudioSrcFinalize):
+ (webKitWebAudioSrcLoop):
+ (webKitWebAudioSrcChangeState):
+ * platform/graphics/gstreamer/GRefPtrGStreamer.cpp:
+ (WTF::derefGPtr<GstBufferList>):
+ (WTF::adoptGRef):
+ (WTF::refGPtr<GstBufferPool>):
+ (WTF::derefGPtr<GstBufferPool>):
+ * platform/graphics/gstreamer/GRefPtrGStreamer.h:
+ * platform/graphics/gstreamer/GStreamerUtilities.cpp:
+ (WebCore::mapGstBuffer):
+ * platform/graphics/gstreamer/GStreamerUtilities.h:
+ * platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp:
+ (StreamingClient::createReadBuffer):
+
</ins><span class="cx"> 2017-01-11 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r182947.
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformaudiogstreamerWebKitWebAudioSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -60,12 +60,15 @@
</span><span class="cx"> GRefPtr<GstTask> task;
</span><span class="cx"> GRecMutex mutex;
</span><span class="cx">
</span><del>- GSList* sources; // List of appsrc. One appsrc for each planar audio channel.
- GstPad* sourcePad; // src pad of the element, interleaved wav data is pushed to it.
</del><ins>+ // List of appsrc. One appsrc for each planar audio channel.
+ Vector<GRefPtr<GstElement>> sources;
</ins><span class="cx">
</span><ins>+ // src pad of the element, interleaved wav data is pushed to it.
+ GstPad* sourcePad;
+
</ins><span class="cx"> guint64 numberOfSamples;
</span><span class="cx">
</span><del>- GstBufferPool* pool;
</del><ins>+ GRefPtr<GstBufferPool> pool;
</ins><span class="cx"> };
</span><span class="cx">
</span><span class="cx"> enum {
</span><span class="lines">@@ -75,11 +78,6 @@
</span><span class="cx"> PROP_FRAMES
</span><span class="cx"> };
</span><span class="cx">
</span><del>-typedef struct {
- GstBuffer* buffer;
- GstMapInfo info;
-} AudioSrcBuffer;
-
</del><span class="cx"> static GstStaticPadTemplate srcTemplate = GST_STATIC_PAD_TEMPLATE("src",
</span><span class="cx"> GST_PAD_SRC,
</span><span class="cx"> GST_PAD_ALWAYS,
</span><span class="lines">@@ -220,7 +218,7 @@
</span><span class="cx"> // appsrc ! . which is plugged to a new interleave request sinkpad.
</span><span class="cx"> for (unsigned channelIndex = 0; channelIndex < priv->bus->numberOfChannels(); channelIndex++) {
</span><span class="cx"> GUniquePtr<gchar> appsrcName(g_strdup_printf("webaudioSrc%u", channelIndex));
</span><del>- GstElement* appsrc = gst_element_factory_make("appsrc", appsrcName.get());
</del><ins>+ GRefPtr<GstElement> appsrc = gst_element_factory_make("appsrc", appsrcName.get());
</ins><span class="cx"> GRefPtr<GstCaps> monoCaps = adoptGRef(getGStreamerMonoAudioCaps(priv->sampleRate));
</span><span class="cx">
</span><span class="cx"> GstAudioInfo info;
</span><span class="lines">@@ -229,16 +227,15 @@
</span><span class="cx"> GRefPtr<GstCaps> caps = adoptGRef(gst_audio_info_to_caps(&info));
</span><span class="cx">
</span><span class="cx"> // Configure the appsrc for minimal latency.
</span><del>- g_object_set(appsrc, "max-bytes", static_cast<guint64>(2 * priv->bufferSize), "block", TRUE,
</del><ins>+ g_object_set(appsrc.get(), "max-bytes", static_cast<guint64>(2 * priv->bufferSize), "block", TRUE,
</ins><span class="cx"> "blocksize", priv->bufferSize,
</span><span class="cx"> "format", GST_FORMAT_TIME, "caps", caps.get(), nullptr);
</span><span class="cx">
</span><del>- priv->sources = g_slist_prepend(priv->sources, gst_object_ref(appsrc));
</del><ins>+ priv->sources.append(appsrc);
</ins><span class="cx">
</span><del>- gst_bin_add(GST_BIN(src), appsrc);
- gst_element_link_pads_full(appsrc, "src", priv->interleave.get(), "sink_%u", GST_PAD_LINK_CHECK_NOTHING);
</del><ins>+ gst_bin_add(GST_BIN(src), appsrc.get());
+ gst_element_link_pads_full(appsrc.get(), "src", priv->interleave.get(), "sink_%u", GST_PAD_LINK_CHECK_NOTHING);
</ins><span class="cx"> }
</span><del>- priv->sources = g_slist_reverse(priv->sources);
</del><span class="cx">
</span><span class="cx"> // interleave's src pad is the only visible pad of our element.
</span><span class="cx"> GRefPtr<GstPad> targetPad = adoptGRef(gst_element_get_static_pad(priv->interleave.get(), "src"));
</span><span class="lines">@@ -252,8 +249,6 @@
</span><span class="cx">
</span><span class="cx"> g_rec_mutex_clear(&priv->mutex);
</span><span class="cx">
</span><del>- g_slist_free_full(priv->sources, reinterpret_cast<GDestroyNotify>(gst_object_unref));
-
</del><span class="cx"> priv->~WebKitWebAudioSourcePrivate();
</span><span class="cx"> GST_CALL_PARENT(G_OBJECT_CLASS, finalize, ((GObject* )(src)));
</span><span class="cx"> }
</span><span class="lines">@@ -319,26 +314,19 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+ ASSERT(priv->pool);
</ins><span class="cx"> GstClockTime timestamp = gst_util_uint64_scale(priv->numberOfSamples, GST_SECOND, priv->sampleRate);
</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>- GSList* channelBufferList = 0;
- for (int i = g_slist_length(priv->sources) - 1; i >= 0; i--) {
- AudioSrcBuffer* buffer = g_new(AudioSrcBuffer, 1);
- GstBuffer* channelBuffer;
-
- GstFlowReturn ret = gst_buffer_pool_acquire_buffer(priv->pool, &channelBuffer, nullptr);
-
</del><ins>+ Vector<GRefPtr<GstBuffer>> channelBufferList;
+ channelBufferList.reserveInitialCapacity(priv->sources.size());
+ for (unsigned i = 0; i < priv->sources.size(); ++i) {
+ GRefPtr<GstBuffer> buffer;
+ GstFlowReturn ret = gst_buffer_pool_acquire_buffer(priv->pool.get(), &buffer.outPtr(), nullptr);
</ins><span class="cx"> if (ret != GST_FLOW_OK) {
</span><del>- g_free(buffer);
- while (channelBufferList) {
- buffer = static_cast<AudioSrcBuffer*>(channelBufferList->data);
- gst_buffer_unmap(buffer->buffer, &buffer->info);
- gst_buffer_unref(buffer->buffer);
- g_free(buffer);
- channelBufferList = g_slist_delete_link(channelBufferList, channelBufferList);
- }
</del><ins>+ for (auto& buffer : channelBufferList)
+ unmapGstBuffer(buffer.get());
</ins><span class="cx">
</span><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="lines">@@ -347,44 +335,38 @@
</span><span class="cx"> return;
</span><span class="cx"> }
</span><span class="cx">
</span><del>- ASSERT(channelBuffer);
- buffer->buffer = channelBuffer;
- GST_BUFFER_TIMESTAMP(channelBuffer) = timestamp;
- GST_BUFFER_DURATION(channelBuffer) = duration;
- gst_buffer_map(channelBuffer, &buffer->info, (GstMapFlags) GST_MAP_READWRITE);
- priv->bus->setChannelMemory(i, reinterpret_cast<float*>(buffer->info.data), priv->framesToPull);
- channelBufferList = g_slist_prepend(channelBufferList, buffer);
</del><ins>+ ASSERT(buffer);
+ GST_BUFFER_TIMESTAMP(buffer.get()) = timestamp;
+ GST_BUFFER_DURATION(buffer.get()) = duration;
+ mapGstBuffer(buffer.get(), GST_MAP_READWRITE);
+ priv->bus->setChannelMemory(i, reinterpret_cast<float*>(getGstBufferDataPointer(buffer.get())), priv->framesToPull);
+ channelBufferList.uncheckedAppend(WTFMove(buffer));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> // FIXME: Add support for local/live audio input.
</span><span class="cx"> priv->provider->render(0, priv->bus, priv->framesToPull);
</span><span class="cx">
</span><del>- GSList* sourcesIt = priv->sources;
- GSList* buffersIt = channelBufferList;
</del><ins>+ ASSERT(channelBufferList.size() == priv->sources.size());
+ bool failed = false;
+ for (unsigned i = 0; i < priv->sources.size(); ++i) {
+ // Unmap before passing on the buffer.
+ auto& buffer = channelBufferList[i];
+ unmapGstBuffer(buffer.get());
</ins><span class="cx">
</span><del>- GstFlowReturn ret = GST_FLOW_OK;
- for (int i = 0; sourcesIt && buffersIt; sourcesIt = g_slist_next(sourcesIt), buffersIt = g_slist_next(buffersIt), ++i) {
- GstElement* appsrc = static_cast<GstElement*>(sourcesIt->data);
- AudioSrcBuffer* buffer = static_cast<AudioSrcBuffer*>(buffersIt->data);
- GstBuffer* channelBuffer = buffer->buffer;
</del><ins>+ if (failed)
+ continue;
</ins><span class="cx">
</span><del>- // Unmap before passing on the buffer.
- gst_buffer_unmap(channelBuffer, &buffer->info);
- g_free(buffer);
-
- if (ret == GST_FLOW_OK) {
- ret = gst_app_src_push_buffer(GST_APP_SRC(appsrc), channelBuffer);
- if (ret != GST_FLOW_OK) {
- // FLUSHING and EOS are not errors.
- if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED)
- GST_ELEMENT_ERROR(src, CORE, PAD, ("Internal WebAudioSrc error"), ("Failed to push buffer on %s flow: %s", GST_OBJECT_NAME(appsrc), gst_flow_get_name(ret)));
- gst_task_stop(src->priv->task.get());
- }
- } else
- gst_buffer_unref(channelBuffer);
</del><ins>+ auto& appsrc = priv->sources[i];
+ // Leak the buffer ref, because gst_app_src_push_buffer steals it.
+ GstFlowReturn ret = gst_app_src_push_buffer(GST_APP_SRC(appsrc.get()), buffer.leakRef());
+ if (ret != GST_FLOW_OK) {
+ // FLUSHING and EOS are not errors.
+ if (ret < GST_FLOW_EOS || ret == GST_FLOW_NOT_LINKED)
+ GST_ELEMENT_ERROR(src, CORE, PAD, ("Internal WebAudioSrc error"), ("Failed to push buffer on %s flow: %s", GST_OBJECT_NAME(appsrc.get()), gst_flow_get_name(ret)));
+ gst_task_stop(src->priv->task.get());
+ failed = true;
+ }
</ins><span class="cx"> }
</span><del>-
- g_slist_free(channelBufferList);
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static GstStateChangeReturn webKitWebAudioSrcChangeState(GstElement* element, GstStateChange transition)
</span><span class="lines">@@ -414,11 +396,12 @@
</span><span class="cx"> switch (transition) {
</span><span class="cx"> case GST_STATE_CHANGE_READY_TO_PAUSED: {
</span><span class="cx"> GST_DEBUG_OBJECT(src, "READY->PAUSED");
</span><ins>+
</ins><span class="cx"> src->priv->pool = gst_buffer_pool_new();
</span><del>- GstStructure* config = gst_buffer_pool_get_config(src->priv->pool);
</del><ins>+ GstStructure* config = gst_buffer_pool_get_config(src->priv->pool.get());
</ins><span class="cx"> gst_buffer_pool_config_set_params(config, nullptr, src->priv->bufferSize, 0, 0);
</span><del>- gst_buffer_pool_set_config(src->priv->pool, config);
- if (!gst_buffer_pool_set_active(src->priv->pool, TRUE))
</del><ins>+ gst_buffer_pool_set_config(src->priv->pool.get(), config);
+ if (!gst_buffer_pool_set_active(src->priv->pool.get(), TRUE))
</ins><span class="cx"> returnValue = GST_STATE_CHANGE_FAILURE;
</span><span class="cx"> else if (!gst_task_start(src->priv->task.get()))
</span><span class="cx"> returnValue = GST_STATE_CHANGE_FAILURE;
</span><span class="lines">@@ -426,13 +409,13 @@
</span><span class="cx"> }
</span><span class="cx"> case GST_STATE_CHANGE_PAUSED_TO_READY:
</span><span class="cx"> GST_DEBUG_OBJECT(src, "PAUSED->READY");
</span><ins>+
</ins><span class="cx"> #if GST_CHECK_VERSION(1, 4, 0)
</span><del>- gst_buffer_pool_set_flushing(src->priv->pool, TRUE);
</del><ins>+ gst_buffer_pool_set_flushing(src->priv->pool.get(), TRUE);
</ins><span class="cx"> #endif
</span><span class="cx"> if (!gst_task_join(src->priv->task.get()))
</span><span class="cx"> returnValue = GST_STATE_CHANGE_FAILURE;
</span><del>- gst_buffer_pool_set_active(src->priv->pool, FALSE);
- gst_object_unref(src->priv->pool);
</del><ins>+ gst_buffer_pool_set_active(src->priv->pool.get(), FALSE);
</ins><span class="cx"> src->priv->pool = nullptr;
</span><span class="cx"> break;
</span><span class="cx"> default:
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGRefPtrGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.cpp        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -221,6 +221,26 @@
</span><span class="cx"> gst_buffer_list_unref(ptr);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+template<> GRefPtr<GstBufferPool> adoptGRef(GstBufferPool* ptr)
+{
+ ASSERT(!ptr || !g_object_is_floating(ptr));
+ return GRefPtr<GstBufferPool>(ptr, GRefPtrAdopt);
+}
+
+template<> GstBufferPool* refGPtr<GstBufferPool>(GstBufferPool* ptr)
+{
+ if (ptr)
+ gst_object_ref_sink(GST_OBJECT(ptr));
+
+ return ptr;
+}
+
+template<> void derefGPtr<GstBufferPool>(GstBufferPool* ptr)
+{
+ if (ptr)
+ gst_object_unref(ptr);
+}
+
</ins><span class="cx"> template<> GRefPtr<GstSample> adoptGRef(GstSample* ptr)
</span><span class="cx"> {
</span><span class="cx"> return GRefPtr<GstSample>(ptr, GRefPtrAdopt);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGRefPtrGStreamerh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GRefPtrGStreamer.h        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -33,6 +33,7 @@
</span><span class="cx"> typedef struct _GstElementFactory GstElementFactory;
</span><span class="cx"> typedef struct _GstBuffer GstBuffer;
</span><span class="cx"> typedef struct _GstBufferList GstBufferList;
</span><ins>+typedef struct _GstBufferPool GstBufferPool;
</ins><span class="cx"> typedef struct _GstSample GstSample;
</span><span class="cx"> typedef struct _GstTagList GstTagList;
</span><span class="cx"> typedef struct _GstEvent GstEvent;
</span><span class="lines">@@ -83,6 +84,10 @@
</span><span class="cx"> template<> GstBufferList* refGPtr<GstBufferList>(GstBufferList*);
</span><span class="cx"> template<> void derefGPtr<GstBufferList>(GstBufferList*);
</span><span class="cx">
</span><ins>+template<> GRefPtr<GstBufferPool> adoptGRef(GstBufferPool*);
+template<> GstBufferPool* refGPtr<GstBufferPool>(GstBufferPool*);
+template<> void derefGPtr<GstBufferPool>(GstBufferPool*);
+
</ins><span class="cx"> template<> GRefPtr<GstSample> adoptGRef(GstSample* ptr);
</span><span class="cx"> template<> GstSample* refGPtr<GstSample>(GstSample* ptr);
</span><span class="cx"> template<> void derefGPtr<GstSample>(GstSample* ptr);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.cpp        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -120,10 +120,10 @@
</span><span class="cx"> return reinterpret_cast<char*>(mapInfo->data);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void mapGstBuffer(GstBuffer* buffer)
</del><ins>+void mapGstBuffer(GstBuffer* buffer, uint32_t flags)
</ins><span class="cx"> {
</span><span class="cx"> GstMapInfo* mapInfo = static_cast<GstMapInfo*>(fastMalloc(sizeof(GstMapInfo)));
</span><del>- if (!gst_buffer_map(buffer, mapInfo, GST_MAP_WRITE)) {
</del><ins>+ if (!gst_buffer_map(buffer, mapInfo, static_cast<GstMapFlags>(flags))) {
</ins><span class="cx"> fastFree(mapInfo);
</span><span class="cx"> gst_buffer_unref(buffer);
</span><span class="cx"> return;
</span><span class="lines">@@ -130,7 +130,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> GstMiniObject* miniObject = reinterpret_cast<GstMiniObject*>(buffer);
</span><del>- gst_mini_object_set_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString), mapInfo, 0);
</del><ins>+ gst_mini_object_set_qdata(miniObject, g_quark_from_static_string(webkitGstMapInfoQuarkString), mapInfo, nullptr);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void unmapGstBuffer(GstBuffer* buffer)
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerGStreamerUtilitiesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/GStreamerUtilities.h        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx"> GstBuffer* createGstBuffer(GstBuffer*);
</span><span class="cx"> GstBuffer* createGstBufferForData(const char* data, int length);
</span><span class="cx"> char* getGstBufferDataPointer(GstBuffer*);
</span><del>-void mapGstBuffer(GstBuffer*);
</del><ins>+void mapGstBuffer(GstBuffer*, uint32_t);
</ins><span class="cx"> void unmapGstBuffer(GstBuffer*);
</span><span class="cx"> bool initializeGStreamer();
</span><span class="cx"> unsigned getGstPlayFlag(const char* nick);
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformgraphicsgstreamerWebKitWebSourceGStreamercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp (210583 => 210584)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2017-01-11 09:08:11 UTC (rev 210583)
+++ trunk/Source/WebCore/platform/graphics/gstreamer/WebKitWebSourceGStreamer.cpp        2017-01-11 11:27:38 UTC (rev 210584)
</span><span class="lines">@@ -865,7 +865,7 @@
</span><span class="cx">
</span><span class="cx"> GstBuffer* buffer = gst_buffer_new_and_alloc(requestedSize);
</span><span class="cx">
</span><del>- mapGstBuffer(buffer);
</del><ins>+ mapGstBuffer(buffer, GST_MAP_WRITE);
</ins><span class="cx">
</span><span class="cx"> WTF::GMutexLocker<GMutex> locker(*GST_OBJECT_GET_LOCK(src));
</span><span class="cx"> priv->buffer = adoptGRef(buffer);
</span></span></pre>
</div>
</div>
</body>
</html>