<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Hi all,<br>
</p>
<p><br>
</p>
<p>I have a rather general question about the refcounting within the<br>
</p>
<p>g_signal_emit_by_name()</p>
<p>API.<br>
</p>
<p><br>
</p>
<p>I was examining some older gstreamer code of mine and found the following use<br>
</p>
<p><br>
</p>
<p><br>
</p>
<p> GstBuffer *gst_buff = gst_buffer_new_allocate(...);<br>
</p>
<p> // prepare a video/x-raw GstBuffer<br>
</p>
<div> g_signal_emit_by_name(VideoCamPipelineGst.src, "push-buffer", gst_buff, &ret);</div>
<div> gst_buffer_unref(gst_buffer); // UNREF<br>
</div>
<p>}</p>
<p><br>
</p>
<p>To clarify, the <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">VideoCamPipelineGst.src</span> pointer is a pointer to a *appsrc* element.<br>
</p>
<div id="Signature">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">Now, the demonstrated code works (I've never seen it crash), but I have doubts as if it is stable or it might cause some unexpected seg fault.</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">The problem I see is that right after I "emit" the "push-buffer" signal I unref the gst_buff (on the line with UNREF comment)</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">which should be its only reference, unless the gst_buff's refcount is incremented within the <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">g_signal_emit_by_name</span>.</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px"><br>
</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">The question is: is the above idiomatic use legit (i.e. is the <span style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 16px; background-color: rgb(255, 255, 255);">g_signal_emit_by_name</span> increases the refcount
of the buffer)</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">or the above construction is illegal and I must switch to using</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">gst_app_src_push_buffer()<br>
</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">instead?</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px"><br>
</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">Many thanks</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px">Martin</span></div>
<div name="divtagdefaultwrapper" style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:; margin:0">
<span style="font-size:16px"><br>
</span></div>
</div>
</div>
</body>
</html>