sample: Add gst_clear_sample() method

Similar to other GstMiniObject clear helper methods like
gst_clear_buffer().

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4473>
This commit is contained in:
Seungha Yang 2023-04-22 04:27:54 +09:00
parent b7083ad242
commit fafecf9cb3
3 changed files with 48 additions and 2 deletions

View file

@ -38632,11 +38632,11 @@ Free-function: gst_sample_unref</doc>
copy of the data the source sample contains.</doc> copy of the data the source sample contains.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstsample.h"/> <source-position filename="../subprojects/gstreamer/gst/gstsample.h"/>
<return-value transfer-ownership="full"> <return-value transfer-ownership="full">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">a new copy of @buf.</doc> <doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">a new copy of @sample.</doc>
<type name="Sample" c:type="GstSample*"/> <type name="Sample" c:type="GstSample*"/>
</return-value> </return-value>
<parameters> <parameters>
<instance-parameter name="buf" transfer-ownership="none"> <instance-parameter name="sample" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">a #GstSample.</doc> <doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">a #GstSample.</doc>
<type name="Sample" c:type="const GstSample*"/> <type name="Sample" c:type="const GstSample*"/>
</instance-parameter> </instance-parameter>
@ -49789,6 +49789,24 @@ reference count of the query is decreased and the pointer is set to %NULL.</doc>
</parameter> </parameter>
</parameters> </parameters>
</function> </function>
<function name="clear_sample" c:identifier="gst_clear_sample" version="1.24" introspectable="0">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">Clears a reference to a #GstSample
@sample_ptr must not be %NULL.
If the reference is %NULL then this function does nothing. Otherwise, the
reference count of the sample is decreased and the pointer is set to %NULL.</doc>
<source-position filename="../subprojects/gstreamer/gst/gstsample.h"/>
<return-value transfer-ownership="none">
<type name="none" c:type="void"/>
</return-value>
<parameters>
<parameter name="sample_ptr" transfer-ownership="none">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gstsample.c">a pointer to a #GstSample reference</doc>
<type name="Sample" c:type="GstSample**"/>
</parameter>
</parameters>
</function>
<function name="clear_structure" c:identifier="gst_clear_structure" version="1.16" introspectable="0"> <function name="clear_structure" c:identifier="gst_clear_structure" version="1.16" introspectable="0">
<doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">Clears a reference to a #GstStructure. <doc xml:space="preserve" filename="../subprojects/gstreamer/gst/gststructure.c">Clears a reference to a #GstStructure.

View file

@ -479,3 +479,22 @@ gst_sample_copy (const GstSample * sample)
GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST
(sample))); (sample)));
} }
/**
* gst_clear_sample: (skip)
* @sample_ptr: a pointer to a #GstSample reference
*
* Clears a reference to a #GstSample
*
* @sample_ptr must not be %NULL.
*
* If the reference is %NULL then this function does nothing. Otherwise, the
* reference count of the sample is decreased and the pointer is set to %NULL.
*
* Since: 1.24
*/
void
gst_clear_sample (GstSample ** sample_ptr)
{
gst_clear_mini_object ((GstMiniObject **) sample_ptr);
}

View file

@ -154,9 +154,18 @@ gst_sample_copy (const GstSample * sample)
{ {
return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (sample))); return GST_SAMPLE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (sample)));
} }
static inline void
gst_clear_sample (GstSample ** sample_ptr)
{
gst_clear_mini_object ((GstMiniObject **) sample_ptr);
}
#else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ #else /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
GST_API GST_API
GstSample * gst_sample_copy (const GstSample * sample); GstSample * gst_sample_copy (const GstSample * sample);
GST_API
void gst_clear_sample (GstSample ** sample_ptr);
#endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */ #endif /* GST_DISABLE_MINIOBJECT_INLINE_FUNCTIONS */
/** /**