make some more macros as inline functions

Make some macros as inline functions for added type checking.
USe new gst_caps_take() in typefind
This commit is contained in:
Wim Taymans 2011-12-05 10:24:34 +01:00
parent 2f836b5996
commit be0e58a637
3 changed files with 56 additions and 14 deletions

View file

@ -286,9 +286,9 @@ gst_caps_copy (const GstCaps * caps)
/**
* gst_caps_replace:
* @ocaps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be
* @old_caps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be
* replaced.
* @ncaps: (transfer none) (allow-none): pointer to a #GstCaps that will
* @new_caps: (transfer none) (allow-none): pointer to a #GstCaps that will
* replace the caps pointed to by @ocaps.
*
* Modifies a pointer to a #GstCaps to point to a different #GstCaps. The
@ -297,13 +297,41 @@ gst_caps_copy (const GstCaps * caps)
* caps is unreffed, the new is reffed).
*
* Either @ncaps or the #GstCaps pointed to by @ocaps may be NULL.
*
* Returns: TRUE if @new_caps was different from @old_caps
*/
#define gst_caps_replace(ocaps,ncaps) \
G_STMT_START { \
GstCaps **___ocapsaddr = (GstCaps **)(ocaps); \
gst_mini_object_replace ((GstMiniObject **)___ocapsaddr, \
GST_MINI_OBJECT_CAST (ncaps)); \
} G_STMT_END
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC gboolean gst_caps_replace (GstCaps **old_caps, GstCaps *new_caps);
#endif
static inline gboolean
gst_caps_replace (GstCaps **old_caps, GstCaps *new_caps)
{
return gst_mini_object_replace ((GstMiniObject **) old_caps, (GstMiniObject *) new_caps);
}
/**
* gst_caps_take:
* @old_caps: (inout) (transfer full): pointer to a pointer to a #GstCaps to be
* replaced.
* @new_caps: (transfer full) (allow-none): pointer to a #GstCaps that will
* replace the caps pointed to by @ocaps.
*
* Modifies a pointer to a #GstCaps to point to a different #GstCaps. This
* function is similar to gst_caps_replace() except that it takes ownership
* of @new_caps.
*
* Returns: TRUE if @new_caps was different from @old_caps
*/
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC gboolean gst_caps_take (GstCaps **old_caps, GstCaps *new_caps);
#endif
static inline gboolean
gst_caps_take (GstCaps **old_caps, GstCaps *new_caps)
{
return gst_mini_object_take ((GstMiniObject **) old_caps, (GstMiniObject *) new_caps);
}
/**
* GstCaps:

View file

@ -306,8 +306,16 @@ gst_event_replace (GstEvent **old_event, GstEvent *new_event)
*
* Returns: the #GstEvent that was in @old_event
*/
#define gst_event_steal(old_event) \
GST_EVENT_CAST (gst_mini_object_steal ((GstMiniObject **)(old_event)))
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC GstEvent * gst_event_steal (GstEvent **old_event);
#endif
static inline GstEvent *
gst_event_steal (GstEvent **old_event)
{
return GST_EVENT_CAST (gst_mini_object_steal ((GstMiniObject **) old_event));
}
/**
* gst_event_take:
* @old_event: (inout) (transfer full): pointer to a pointer to a #GstEvent
@ -323,8 +331,15 @@ gst_event_replace (GstEvent **old_event, GstEvent *new_event)
*
* Returns: TRUE if @new_event was different from @old_event
*/
#define gst_event_take(old_event,new_event) \
gst_mini_object_take ((GstMiniObject **)(old_event), GST_MINI_OBJECT_CAST (new_event))
#ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC gboolean gst_event_take (GstEvent **old_event, GstEvent *new_event);
#endif
static inline gboolean
gst_event_take (GstEvent **old_event, GstEvent *new_event)
{
return gst_mini_object_take ((GstMiniObject **) old_event, (GstMiniObject *) new_event);
}
/**
* GstQOSType:

View file

@ -211,8 +211,7 @@ helper_find_suggest (gpointer data, GstTypeFindProbability probability,
if (probability > helper->best_probability) {
GstCaps *copy = gst_caps_copy (caps);
gst_caps_replace (&helper->caps, copy);
gst_caps_unref (copy);
gst_caps_take (&helper->caps, copy);
helper->best_probability = probability;
}
}