<div dir="ltr">This is a very informative response that should be incorporated into to Gstreamer's application development manual.</div><div class="gmail_extra"><br><div class="gmail_quote">2015-01-09 10:02 GMT+01:00 Sebastian Dröge <span dir="ltr"><<a href="mailto:sebastian@centricular.com" target="_blank">sebastian@centricular.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Di, 2015-01-06 at 18:10 -0800, hxpax wrote:<br>
> That could be a big problem on some other platforms, more than just a<br>
> segfault.<br>
<br>
</span>It could result in worse situations, yes.<br>
<span class=""><br>
> I wonder are there any conventions for unref?<br>
<br>
</span>The docs would tell you, they now have annotations on parameters and<br>
return values hopefully everywhere. Like (transfer none), (transfer<br>
full), (transfer container) and (transfer floating).<br>
<br>
none: for return values you don't own it and must not unref it, for<br>
parameters you still own it and must unref it<br>
<br>
full: for return values you own it and must unref it, for parameters you<br>
don't own it anymore and must get another reference with ref before<br>
passing it to the function if you still need it afterwards<br>
<br>
container: only used for containers, e.g. lists. Means the same as<br>
transfer full for the actual container, but transfer none for the<br>
elements of the container<br>
<br>
floating: tricky one, check the documentation for floating references<br>
first. It means for return values that you get a floating reference, for<br>
parameters it means that it is transfer full for floating references and<br>
transfer none for non-floating references.<br>
<br>
<br>
General rule is that setter should be transfer none, getter transfer<br>
full, adder (e.g. gst_bin_add()) transfer full or transfer floating.<br>
Exception for getters (and things like gst_message_parse_*) are things<br>
like GstStructure, GstMessage, etc where the return value is transfer<br>
none and stays valid as long as you have a reference to its container.<br>
Functions that take a const pointer or return one are by definition<br>
transfer none.<br>
<br>
Things that pass buffers/messages/events on to other pads/elements are<br>
transfer full (e.g. gst_pad_push(), gst_element_post_message()), query<br>
related things are transfer none. Reason is that you usually want to get<br>
rid of the references of the former when passing it (also to keep<br>
buffers writable downstream if possible), while for queries you still<br>
want to own the reference (how would you otherwise get the query result<br>
later?).<br>
<br>
Unfortunately there are a few inconsistencies and exceptions to these<br>
rules.<br>
<br>
Hope this helps!<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Sebastian Dröge, Centricular Ltd · <a href="http://www.centricular.com" target="_blank">http://www.centricular.com</a><br>
</font></span><br>_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br>
<br></blockquote></div><br></div>