typefind: remove const from refcounted GstCaps

Having const on refcounted objects require us to make copies instead of simply
taking a ref, don't do that.
This commit is contained in:
Wim Taymans 2012-03-10 09:25:43 +01:00
parent 6426145fc9
commit fe5fe438d3
5 changed files with 13 additions and 23 deletions

View file

@ -145,8 +145,7 @@ gst_type_find_peek (GstTypeFind * find, gint64 offset, guint size)
* It is up to the caller of the #GstTypeFindFunction to interpret these values. * It is up to the caller of the #GstTypeFindFunction to interpret these values.
*/ */
void void
gst_type_find_suggest (GstTypeFind * find, guint probability, gst_type_find_suggest (GstTypeFind * find, guint probability, GstCaps * caps)
const GstCaps * caps)
{ {
g_return_if_fail (find->suggest != NULL); g_return_if_fail (find->suggest != NULL);
g_return_if_fail (probability <= 100); g_return_if_fail (probability <= 100);

View file

@ -80,7 +80,7 @@ struct _GstTypeFind {
void (* suggest) (gpointer data, void (* suggest) (gpointer data,
guint probability, guint probability,
const GstCaps * caps); GstCaps *caps);
gpointer data; gpointer data;
@ -100,7 +100,7 @@ const guint8 * gst_type_find_peek (GstTypeFind * find,
void gst_type_find_suggest (GstTypeFind * find, void gst_type_find_suggest (GstTypeFind * find,
guint probability, guint probability,
const GstCaps * caps); GstCaps * caps);
void gst_type_find_suggest_simple (GstTypeFind * find, void gst_type_find_suggest_simple (GstTypeFind * find,
guint probability, guint probability,

View file

@ -43,7 +43,7 @@
/* ********************** typefinding in pull mode ************************ */ /* ********************** typefinding in pull mode ************************ */
static void static void
helper_find_suggest (gpointer data, guint probability, const GstCaps * caps); helper_find_suggest (gpointer data, guint probability, GstCaps * caps);
typedef struct typedef struct
{ {
@ -201,7 +201,7 @@ error:
*/ */
static void static void
helper_find_suggest (gpointer data, GstTypeFindProbability probability, helper_find_suggest (gpointer data, GstTypeFindProbability probability,
const GstCaps * caps) GstCaps * caps)
{ {
GstTypeFindHelper *helper = (GstTypeFindHelper *) data; GstTypeFindHelper *helper = (GstTypeFindHelper *) data;
@ -210,9 +210,7 @@ helper_find_suggest (gpointer data, GstTypeFindProbability probability,
GST_OBJECT_NAME (helper->factory), probability, caps); GST_OBJECT_NAME (helper->factory), probability, caps);
if (probability > helper->best_probability) { if (probability > helper->best_probability) {
GstCaps *copy = gst_caps_copy (caps); gst_caps_replace (&helper->caps, caps);
gst_caps_take (&helper->caps, copy);
helper->best_probability = probability; helper->best_probability = probability;
} }
} }
@ -445,7 +443,7 @@ buf_helper_find_peek (gpointer data, gint64 off, guint size)
*/ */
static void static void
buf_helper_find_suggest (gpointer data, GstTypeFindProbability probability, buf_helper_find_suggest (gpointer data, GstTypeFindProbability probability,
const GstCaps * caps) GstCaps * caps)
{ {
GstTypeFindBufHelper *helper = (GstTypeFindBufHelper *) data; GstTypeFindBufHelper *helper = (GstTypeFindBufHelper *) data;
@ -455,10 +453,7 @@ buf_helper_find_suggest (gpointer data, GstTypeFindProbability probability,
/* Note: not >= as we call typefinders in order of rank, highest first */ /* Note: not >= as we call typefinders in order of rank, highest first */
if (probability > helper->best_probability) { if (probability > helper->best_probability) {
GstCaps *copy = gst_caps_copy (caps); gst_caps_replace (&helper->caps, caps);
gst_caps_replace (&helper->caps, copy);
gst_caps_unref (copy);
helper->best_probability = probability; helper->best_probability = probability;
} }
} }

View file

@ -175,10 +175,8 @@ static guint gst_type_find_element_signals[LAST_SIGNAL] = { 0 };
static void static void
gst_type_find_element_have_type (GstTypeFindElement * typefind, gst_type_find_element_have_type (GstTypeFindElement * typefind,
guint probability, const GstCaps * caps) guint probability, GstCaps * caps)
{ {
GstCaps *copy;
g_assert (caps != NULL); g_assert (caps != NULL);
GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT ", probability=%u", GST_INFO_OBJECT (typefind, "found caps %" GST_PTR_FORMAT ", probability=%u",
@ -187,12 +185,10 @@ gst_type_find_element_have_type (GstTypeFindElement * typefind,
GST_OBJECT_LOCK (typefind); GST_OBJECT_LOCK (typefind);
if (typefind->caps) if (typefind->caps)
gst_caps_unref (typefind->caps); gst_caps_unref (typefind->caps);
typefind->caps = gst_caps_copy (caps); typefind->caps = gst_caps_ref (caps);
copy = gst_caps_ref (typefind->caps);
GST_OBJECT_UNLOCK (typefind); GST_OBJECT_UNLOCK (typefind);
gst_pad_push_event (typefind->src, gst_event_new_caps (copy)); gst_pad_push_event (typefind->src, gst_event_new_caps (caps));
gst_caps_unref (copy);
} }
static void static void

View file

@ -71,8 +71,8 @@ struct _GstTypeFindElementClass {
/* signals */ /* signals */
void (*have_type) (GstTypeFindElement *element, void (*have_type) (GstTypeFindElement *element,
guint probability, guint probability,
const GstCaps * caps); GstCaps *caps);
}; };
GType gst_type_find_element_get_type (void); GType gst_type_find_element_get_type (void);