From 5d39cbbd4e8c80cae265971cb8c1f5a24d26a74d Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Wed, 24 Dec 2003 07:42:43 +0000 Subject: [PATCH] Make GstCaps parameter const. Copy caps parameter. Use _POINTER to marshal caps instead of _BOXED. Don't double-fre... Original commit message from CVS: Make GstCaps parameter const. Copy caps parameter. Use _POINTER to marshal caps instead of _BOXED. Don't double-free caps.Use GST_PAD_LINK_SUCCESSFUL. --- ChangeLog | 7 +++++++ gst/elements/gsttypefind.c | 11 ++++++----- gst/elements/gsttypefind.h | 2 +- gst/elements/gsttypefindelement.c | 11 ++++++----- gst/elements/gsttypefindelement.h | 2 +- gst/gstmarshal.list | 1 + plugins/elements/gsttypefind.c | 11 ++++++----- plugins/elements/gsttypefind.h | 2 +- plugins/elements/gsttypefindelement.c | 11 ++++++----- plugins/elements/gsttypefindelement.h | 2 +- 10 files changed, 36 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2cd27d..cb844d5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-12-24 Colin Walters + + * gst/elements/gsttypefindelement.c: + gst/elements/gsttypefindelement.h: Make GstCaps parameter const. + Copy caps parameter. Use _POINTER to marshal caps instead of _BOXED. + Don't double-free caps. + 2003-12-23 David Schleef * gst/gstelement.c, gst/gstpad.c, gst/parse/grammar.y, diff --git a/gst/elements/gsttypefind.c b/gst/elements/gsttypefind.c index c38099a..8162084 100644 --- a/gst/elements/gsttypefind.c +++ b/gst/elements/gsttypefind.c @@ -141,7 +141,7 @@ gst_type_find_element_get_type (void) return typefind_type; } static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { gchar *caps_str; @@ -151,7 +151,7 @@ gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability caps_str = gst_caps_to_string (caps); GST_INFO_OBJECT (typefind, "found caps %s", caps_str); g_free (caps_str); - gst_caps_replace (&typefind->caps, caps); + typefind->caps = gst_caps_copy (caps); if (gst_pad_try_set_caps (typefind->src, caps) < GST_PAD_LINK_OK) { gst_element_error (GST_ELEMENT (typefind), "could not set caps on source pad"); } @@ -195,8 +195,8 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data) gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, gst_caps_get_type()); + gst_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_POINTER); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } @@ -669,7 +669,8 @@ gst_type_find_element_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: stop_typefinding (typefind); - gst_caps_replace (&typefind->caps, NULL); + if (typefind->caps) + gst_caps_free (typefind->caps); break; default: break; diff --git a/gst/elements/gsttypefind.h b/gst/elements/gsttypefind.h index 7f508ba..03eeccd 100644 --- a/gst/elements/gsttypefind.h +++ b/gst/elements/gsttypefind.h @@ -66,7 +66,7 @@ struct _GstTypeFindElementClass { /* signals */ void (*have_type) (GstTypeFindElement *element, guint probability, - GstCaps * caps); + const GstCaps * caps); }; GType gst_type_find_element_get_type (void); diff --git a/gst/elements/gsttypefindelement.c b/gst/elements/gsttypefindelement.c index c38099a..8162084 100644 --- a/gst/elements/gsttypefindelement.c +++ b/gst/elements/gsttypefindelement.c @@ -141,7 +141,7 @@ gst_type_find_element_get_type (void) return typefind_type; } static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { gchar *caps_str; @@ -151,7 +151,7 @@ gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability caps_str = gst_caps_to_string (caps); GST_INFO_OBJECT (typefind, "found caps %s", caps_str); g_free (caps_str); - gst_caps_replace (&typefind->caps, caps); + typefind->caps = gst_caps_copy (caps); if (gst_pad_try_set_caps (typefind->src, caps) < GST_PAD_LINK_OK) { gst_element_error (GST_ELEMENT (typefind), "could not set caps on source pad"); } @@ -195,8 +195,8 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data) gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, gst_caps_get_type()); + gst_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_POINTER); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } @@ -669,7 +669,8 @@ gst_type_find_element_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: stop_typefinding (typefind); - gst_caps_replace (&typefind->caps, NULL); + if (typefind->caps) + gst_caps_free (typefind->caps); break; default: break; diff --git a/gst/elements/gsttypefindelement.h b/gst/elements/gsttypefindelement.h index 7f508ba..03eeccd 100644 --- a/gst/elements/gsttypefindelement.h +++ b/gst/elements/gsttypefindelement.h @@ -66,7 +66,7 @@ struct _GstTypeFindElementClass { /* signals */ void (*have_type) (GstTypeFindElement *element, guint probability, - GstCaps * caps); + const GstCaps * caps); }; GType gst_type_find_element_get_type (void); diff --git a/gst/gstmarshal.list b/gst/gstmarshal.list index fabedd9..f136fbb 100644 --- a/gst/gstmarshal.list +++ b/gst/gstmarshal.list @@ -11,5 +11,6 @@ VOID:OBJECT,STRING VOID:INT,INT VOID:INT64 VOID:UINT,BOXED +VOID:UINT,POINTER BOOLEAN:VOID BOOLEAN:POINTER diff --git a/plugins/elements/gsttypefind.c b/plugins/elements/gsttypefind.c index c38099a..8162084 100644 --- a/plugins/elements/gsttypefind.c +++ b/plugins/elements/gsttypefind.c @@ -141,7 +141,7 @@ gst_type_find_element_get_type (void) return typefind_type; } static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { gchar *caps_str; @@ -151,7 +151,7 @@ gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability caps_str = gst_caps_to_string (caps); GST_INFO_OBJECT (typefind, "found caps %s", caps_str); g_free (caps_str); - gst_caps_replace (&typefind->caps, caps); + typefind->caps = gst_caps_copy (caps); if (gst_pad_try_set_caps (typefind->src, caps) < GST_PAD_LINK_OK) { gst_element_error (GST_ELEMENT (typefind), "could not set caps on source pad"); } @@ -195,8 +195,8 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data) gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, gst_caps_get_type()); + gst_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_POINTER); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } @@ -669,7 +669,8 @@ gst_type_find_element_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: stop_typefinding (typefind); - gst_caps_replace (&typefind->caps, NULL); + if (typefind->caps) + gst_caps_free (typefind->caps); break; default: break; diff --git a/plugins/elements/gsttypefind.h b/plugins/elements/gsttypefind.h index 7f508ba..03eeccd 100644 --- a/plugins/elements/gsttypefind.h +++ b/plugins/elements/gsttypefind.h @@ -66,7 +66,7 @@ struct _GstTypeFindElementClass { /* signals */ void (*have_type) (GstTypeFindElement *element, guint probability, - GstCaps * caps); + const GstCaps * caps); }; GType gst_type_find_element_get_type (void); diff --git a/plugins/elements/gsttypefindelement.c b/plugins/elements/gsttypefindelement.c index c38099a..8162084 100644 --- a/plugins/elements/gsttypefindelement.c +++ b/plugins/elements/gsttypefindelement.c @@ -141,7 +141,7 @@ gst_type_find_element_get_type (void) return typefind_type; } static void -gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, GstCaps *caps) +gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability, const GstCaps *caps) { gchar *caps_str; @@ -151,7 +151,7 @@ gst_type_find_element_have_type (GstTypeFindElement *typefind, guint probability caps_str = gst_caps_to_string (caps); GST_INFO_OBJECT (typefind, "found caps %s", caps_str); g_free (caps_str); - gst_caps_replace (&typefind->caps, caps); + typefind->caps = gst_caps_copy (caps); if (gst_pad_try_set_caps (typefind->src, caps) < GST_PAD_LINK_OK) { gst_element_error (GST_ELEMENT (typefind), "could not set caps on source pad"); } @@ -195,8 +195,8 @@ gst_type_find_element_class_init (gpointer g_class, gpointer class_data) gst_type_find_element_signals[HAVE_TYPE] = g_signal_new ("have_type", G_TYPE_FROM_CLASS (g_class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstTypeFindElementClass, have_type), NULL, NULL, - gst_marshal_VOID__UINT_BOXED, G_TYPE_NONE, 2, - G_TYPE_UINT, gst_caps_get_type()); + gst_marshal_VOID__UINT_POINTER, G_TYPE_NONE, 2, + G_TYPE_UINT, G_TYPE_POINTER); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_type_find_element_change_state); } @@ -669,7 +669,8 @@ gst_type_find_element_change_state (GstElement *element) break; case GST_STATE_PAUSED_TO_READY: stop_typefinding (typefind); - gst_caps_replace (&typefind->caps, NULL); + if (typefind->caps) + gst_caps_free (typefind->caps); break; default: break; diff --git a/plugins/elements/gsttypefindelement.h b/plugins/elements/gsttypefindelement.h index 7f508ba..03eeccd 100644 --- a/plugins/elements/gsttypefindelement.h +++ b/plugins/elements/gsttypefindelement.h @@ -66,7 +66,7 @@ struct _GstTypeFindElementClass { /* signals */ void (*have_type) (GstTypeFindElement *element, guint probability, - GstCaps * caps); + const GstCaps * caps); }; GType gst_type_find_element_get_type (void); -- 2.7.4