From: <wt...@fr...> - 2005-04-21 09:33:48
|
CVS Root: /cvs/gstreamer Module: gstreamer Changes by: wtay Date: Thu Apr 21 2005 19:33:46 EST Log message: * gst/gstmessage.c: (_gst_message_copy), (_gst_message_free), (gst_message_new), (gst_message_new_error), (gst_message_new_warning), (gst_message_new_tag), (gst_message_new_state_changed), (gst_message_new_application), (gst_message_get_structure): * gst/gstmessage.h: * gst/gststructure.c: (gst_structure_set_parent_refcount), (gst_structure_copy_conditional): Use parent refcount in GstMessage to ensure GstStructure consistency. Cleaned up headers a bit. Modified files: . : ChangeLog gst : gstmessage.c gstmessage.h gststructure.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/ChangeLog.diff?r1=1.1018&r2=1.1019 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstmessage.c.diff?r1=1.4&r2=1.5 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gstmessage.h.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gstreamer/gst/gststructure.c.diff?r1=1.42&r2=1.43 ====Begin Diffs==== Index: gstmessage.c =================================================================== RCS file: /cvs/gstreamer/gstreamer/gst/gstmessage.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- gstmessage.c 20 Apr 2005 09:10:41 -0000 1.4 +++ gstmessage.c 21 Apr 2005 09:33:31 -0000 1.5 @@ -75,8 +75,11 @@ gst_object_ref (GST_MESSAGE_SRC (copy)); } - if (copy->structure) - copy->structure = gst_structure_copy (copy->structure); + if (message->structure) { + copy->structure = gst_structure_copy (message->structure); + gst_structure_set_parent_refcount (copy->structure, + &GST_DATA_REFCOUNT (message)); + } return copy; } @@ -96,8 +99,10 @@ GST_MESSAGE_UNLOCK (message); - if (message->structure) + gst_structure_set_parent_refcount (message->structure, NULL); gst_structure_free (message->structure); _GST_DATA_DISPOSE (GST_DATA (message)); #ifndef GST_DISABLE_TRACE @@ -194,6 +199,7 @@ message = gst_message_new (GST_MESSAGE_ERROR, src); s = gst_structure_new ("GstMessageError", "gerror", G_TYPE_POINTER, error, "debug", G_TYPE_STRING, debug, NULL); + gst_structure_set_parent_refcount (s, &GST_DATA_REFCOUNT (message)); message->structure = s; return message; @@ -221,6 +227,7 @@ message = gst_message_new (GST_MESSAGE_WARNING, src); s = gst_structure_new ("GstMessageWarning", "gerror", G_TYPE_POINTER, error, @@ -242,7 +249,10 @@ { GstMessage *message; + g_return_val_if_fail (GST_IS_STRUCTURE (tag_list), NULL); + message = gst_message_new (GST_MESSAGE_TAG, src); + gst_structure_set_parent_refcount (tag_list, &GST_DATA_REFCOUNT (message)); message->structure = tag_list; @@ -271,6 +281,7 @@ s = gst_structure_new ("GstMessageError", "old-state", G_TYPE_INT, (gint) old, "new-state", G_TYPE_INT, (gint) new, NULL); @@ -293,7 +304,10 @@ + g_return_val_if_fail (GST_IS_STRUCTURE (structure), NULL); message = gst_message_new (GST_MESSAGE_APPLICATION, NULL); + gst_structure_set_parent_refcount (structure, &GST_DATA_REFCOUNT (message)); message->structure = structure; @@ -305,7 +319,9 @@ * * Access the structure of the message. - * Returns: The structure of the message, owned by the message. + * Returns: The structure of the message. The structure is still + * owned by the message, which means that you should not free it and + * that the pointer becomes invalid when you free the message. * MT safe. */ @@ -313,6 +329,7 @@ gst_message_get_structure (GstMessage * message) g_return_val_if_fail (GST_IS_MESSAGE (message), NULL); return message->structure; Index: gstmessage.h RCS file: /cvs/gstreamer/gstreamer/gst/gstmessage.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gstmessage.h 21 Mar 2005 17:34:00 -0000 1.2 +++ gstmessage.h 21 Apr 2005 09:33:31 -0000 1.3 @@ -114,11 +114,12 @@ GstMessage * gst_message_new (GstMessageType type, GstObject * src); /* refcounting */ -#define gst_message_ref(ev) GST_MESSAGE (gst_data_ref (GST_DATA (ev))) -#define gst_message_ref_by_count(ev,c) GST_MESSAGE (gst_data_ref_by_count (GST_DATA (ev), c)) -#define gst_message_unref(ev) gst_data_unref (GST_DATA (ev)) +#define gst_message_ref(msg) GST_MESSAGE (gst_data_ref (GST_DATA (msg))) +#define gst_message_ref_by_count(msg,c) GST_MESSAGE (gst_data_ref_by_count (GST_DATA (msg), (c))) +#define gst_message_unref(msg) gst_data_unref (GST_DATA (msg)) /* copy message */ -#define gst_message_copy(ev) GST_MESSAGE (gst_data_copy (GST_DATA (ev))) +#define gst_message_copy(msg) GST_MESSAGE (gst_data_copy (GST_DATA (msg))) +#define gst_message_copy_on_write(msg) GST_MESSAGE (gst_data_copy_on_write (GST_DATA (msg))) GstMessage * gst_message_new_eos (GstObject * src); GstMessage * gst_message_new_error (GstObject * src, GError * error, gchar * debug); @@ -128,13 +129,12 @@ GstElementState new_state); GstMessage * gst_message_new_application (GstStructure *structure); -const GstStructure * gst_message_get_structure (GstMessage *message); - +void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug); +void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug); void gst_message_parse_tag (GstMessage *message, GstTagList **tag_list); void gst_message_parse_state_changed (GstMessage *message, GstElementState *old_state, GstElementState *new_state); -void gst_message_parse_error (GstMessage *message, GError **gerror, gchar **debug); -void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug); +const GstStructure * gst_message_get_structure (GstMessage *message); G_END_DECLS Index: gststructure.c RCS file: /cvs/gstreamer/gstreamer/gst/gststructure.c,v retrieving revision 1.42 retrieving revision 1.43 diff -u -d -r1.42 -r1.43 --- gststructure.c 22 Mar 2005 14:23:49 -0000 1.42 +++ gststructure.c 21 Apr 2005 09:33:31 -0000 1.43 @@ -193,6 +193,10 @@ gst_structure_set_parent_refcount (GstStructure * structure, GstAtomicInt * refcount) + g_return_if_fail (structure != NULL); + /* if we have a parent_refcount already, we can only clear + * if with a NULL refcount */ if (structure->parent_refcount) g_return_if_fail (refcount == NULL); else @@ -240,7 +244,7 @@ * @structure: the #GstStructure to free * Frees a #GstStructure and all its fields and values. The structure must not - * parent when this function is called. + * have a parent when this function is called. void gst_structure_free (GstStructure * structure) Index: ChangeLog RCS file: /cvs/gstreamer/gstreamer/ChangeLog,v retrieving revision 1.1018 retrieving revision 1.1019 diff -u -d -r1.1018 -r1.1019 --- ChangeLog 20 Apr 2005 09:10:41 -0000 1.1018 +++ ChangeLog 21 Apr 2005 09:33:31 -0000 1.1019 @@ -1,3 +1,18 @@ +2005-04-21 Wim Taymans <wi...@fl...> + * gst/gstmessage.c: (_gst_message_copy), (_gst_message_free), + (gst_message_new), (gst_message_new_error), + (gst_message_new_warning), (gst_message_new_tag), + (gst_message_new_state_changed), (gst_message_new_application), + (gst_message_get_structure): + * gst/gstmessage.h: + * gst/gststructure.c: (gst_structure_set_parent_refcount), + (gst_structure_copy_conditional): + Use parent refcount in GstMessage to ensure GstStructure + consistency. + Cleaned up headers a bit. + 2005-04-20 Wim Taymans <wi...@fl...> * gst/base/gstbasesink.c: (gst_basesink_base_init), |