mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
Convert unref/copy functions of GstMiniObject subclasses to static inline functions
unref and copy functions are sometimes used as function pointers for example in the case of g_hash_table_new_full as a GDestroyNotify function. Currently GstBuffer, GstEvent, GstMessage and GstQuery define their respective unref and copy functions as macros, making use of gst_mini_object_unref/copy. This approach works very well for most cases, except for some automatically generated bindings (currently Vala), where the memory management semantics are defined declaratively. The possible solutions would be to either convert all the macros into static inline function, or change the signature of gst_mini_object_unref to take a void* instead of a GstMiniObject*. Fixes bug #572480.
This commit is contained in:
parent
9192c7f9a5
commit
136cfb3bed
4 changed files with 87 additions and 15 deletions
|
@ -342,8 +342,6 @@ G_INLINE_FUNC GstBuffer * gst_buffer_ref (GstBuffer * buf);
|
|||
static inline GstBuffer *
|
||||
gst_buffer_ref (GstBuffer * buf)
|
||||
{
|
||||
/* not using a macro here because gcc-4.1 will complain
|
||||
* if the return value isn't used (because of the cast) */
|
||||
return (GstBuffer *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (buf));
|
||||
}
|
||||
|
||||
|
@ -355,7 +353,15 @@ gst_buffer_ref (GstBuffer * buf)
|
|||
* will be freed. If GST_BUFFER_MALLOCDATA() is non-NULL, this pointer will
|
||||
* also be freed at this time.
|
||||
*/
|
||||
#define gst_buffer_unref(buf) gst_mini_object_unref (GST_MINI_OBJECT_CAST (buf))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC void gst_buffer_unref (GstBuffer * buf);
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
gst_buffer_unref (GstBuffer * buf)
|
||||
{
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (buf));
|
||||
}
|
||||
|
||||
/* copy buffer */
|
||||
/**
|
||||
|
@ -365,7 +371,16 @@ gst_buffer_ref (GstBuffer * buf)
|
|||
* Create a copy of the given buffer. This will also make a newly allocated
|
||||
* copy of the data the source buffer contains.
|
||||
*/
|
||||
#define gst_buffer_copy(buf) GST_BUFFER_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buf)))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC GstBuffer * gst_buffer_copy (const GstBuffer * buf);
|
||||
#endif
|
||||
|
||||
static inline GstBuffer *
|
||||
gst_buffer_copy (const GstBuffer * buf)
|
||||
{
|
||||
return GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buf)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GstBufferCopyFlags:
|
||||
|
|
|
@ -350,8 +350,6 @@ G_INLINE_FUNC GstEvent * gst_event_ref (GstEvent * event);
|
|||
static inline GstEvent *
|
||||
gst_event_ref (GstEvent * ev)
|
||||
{
|
||||
/* not using a macro here because gcc-4.1 will complain
|
||||
* if the return value isn't used (because of the cast) */
|
||||
return (GstEvent *) gst_mini_object_ref (GST_MINI_OBJECT (ev));
|
||||
}
|
||||
|
||||
|
@ -361,7 +359,15 @@ gst_event_ref (GstEvent * ev)
|
|||
*
|
||||
* Decrease the refcount of an event, freeing it if the refcount reaches 0.
|
||||
*/
|
||||
#define gst_event_unref(ev) gst_mini_object_unref (GST_MINI_OBJECT (ev))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC void gst_event_unref (GstEvent * event);
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
gst_event_unref (GstEvent * ev)
|
||||
{
|
||||
gst_mini_object_unref (GST_MINI_OBJECT (ev));
|
||||
}
|
||||
|
||||
/* copy event */
|
||||
/**
|
||||
|
@ -370,7 +376,16 @@ gst_event_ref (GstEvent * ev)
|
|||
*
|
||||
* Copy the event using the event specific copy function.
|
||||
*/
|
||||
#define gst_event_copy(ev) GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT (ev)))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC void gst_event_copy (GstEvent * event);
|
||||
#endif
|
||||
|
||||
static inline GstEvent *
|
||||
gst_event_copy (const GstEvent * ev)
|
||||
{
|
||||
return GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT (ev)));
|
||||
}
|
||||
|
||||
|
||||
/* custom event */
|
||||
GstEvent* gst_event_new_custom (GstEventType type, GstStructure *structure);
|
||||
|
|
|
@ -260,8 +260,6 @@ G_INLINE_FUNC GstMessage * gst_message_ref (GstMessage * msg);
|
|||
static inline GstMessage *
|
||||
gst_message_ref (GstMessage * msg)
|
||||
{
|
||||
/* not using a macro here because gcc-4.1 will complain
|
||||
* if the return value isn't used (because of the cast) */
|
||||
return (GstMessage *) gst_mini_object_ref (GST_MINI_OBJECT (msg));
|
||||
}
|
||||
|
||||
|
@ -272,7 +270,16 @@ gst_message_ref (GstMessage * msg)
|
|||
* Convenience macro to decrease the reference count of the message, possibly
|
||||
* freeing it.
|
||||
*/
|
||||
#define gst_message_unref(msg) gst_mini_object_unref (GST_MINI_OBJECT (msg))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC void gst_message_unref (GstMessage * msg);
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
gst_message_unref (GstMessage * msg)
|
||||
{
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (msg));
|
||||
}
|
||||
|
||||
/* copy message */
|
||||
/**
|
||||
* gst_message_copy:
|
||||
|
@ -282,7 +289,16 @@ gst_message_ref (GstMessage * msg)
|
|||
*
|
||||
* MT safe
|
||||
*/
|
||||
#define gst_message_copy(msg) GST_MESSAGE (gst_mini_object_copy (GST_MINI_OBJECT (msg)))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC GstMessage * gst_message_copy (const GstMessage * msg);
|
||||
#endif
|
||||
|
||||
static inline GstMessage *
|
||||
gst_message_copy (const GstMessage * msg)
|
||||
{
|
||||
return GST_MESSAGE (gst_mini_object_copy (GST_MINI_OBJECT_CAST (msg)));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_message_make_writable:
|
||||
* @msg: the message to make writable
|
||||
|
|
|
@ -190,7 +190,16 @@ GstIterator* gst_query_type_iterate_definitions (void);
|
|||
*
|
||||
* Increases the refcount of the given query by one.
|
||||
*/
|
||||
#define gst_query_ref(q) GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT (q)))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC GstQuery * gst_query_ref (GstQuery * q);
|
||||
#endif
|
||||
|
||||
static inline GstQuery *
|
||||
gst_query_ref (GstQuery * q)
|
||||
{
|
||||
return GST_QUERY (gst_mini_object_ref (GST_MINI_OBJECT_CAST (q)));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_query_unref:
|
||||
* @q: a #GstQuery to decrease the refcount of.
|
||||
|
@ -198,7 +207,15 @@ GstIterator* gst_query_type_iterate_definitions (void);
|
|||
* Decreases the refcount of the query. If the refcount reaches 0, the query
|
||||
* will be freed.
|
||||
*/
|
||||
#define gst_query_unref(q) gst_mini_object_unref (GST_MINI_OBJECT (q))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC void gst_query_unref (GstQuery * q);
|
||||
#endif
|
||||
|
||||
static inline void
|
||||
gst_query_unref (GstQuery * q)
|
||||
{
|
||||
gst_mini_object_unref (GST_MINI_OBJECT_CAST (q));
|
||||
}
|
||||
|
||||
/* copy query */
|
||||
/**
|
||||
|
@ -208,7 +225,16 @@ GstIterator* gst_query_type_iterate_definitions (void);
|
|||
* Copies the given query using the copy function of the parent #GstData
|
||||
* structure.
|
||||
*/
|
||||
#define gst_query_copy(q) GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT (q)))
|
||||
#ifdef _FOOL_GTK_DOC_
|
||||
G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
|
||||
#endif
|
||||
|
||||
static inline GstQuery *
|
||||
gst_query_copy (const GstQuery * q)
|
||||
{
|
||||
return GST_QUERY (gst_mini_object_copy (GST_MINI_OBJECT_CAST (q)));
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_query_make_writable:
|
||||
* @q: a #GstQuery to make writable
|
||||
|
|
Loading…
Reference in a new issue