mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 03:00:35 +00:00
gst/: Use parent refcount in GstMessage to ensure GstStructure consistency.
Original commit message from CVS: * 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.
This commit is contained in:
parent
ee13415b38
commit
f059bb2c54
4 changed files with 49 additions and 13 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
|||
2005-04-21 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* 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 <wim@fluendo.com>
|
||||
|
||||
* gst/base/gstbasesink.c: (gst_basesink_base_init),
|
||||
|
|
|
@ -75,8 +75,11 @@ _gst_message_copy (GstMessage * message)
|
|||
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_free (GstMessage * message)
|
|||
GST_MESSAGE_UNLOCK (message);
|
||||
}
|
||||
|
||||
if (message->structure)
|
||||
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 @@ gst_message_new_error (GstObject * src, GError * error, gchar * debug)
|
|||
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 @@ gst_message_new_warning (GstObject * src, GError * error, gchar * debug)
|
|||
message = gst_message_new (GST_MESSAGE_WARNING, src);
|
||||
s = gst_structure_new ("GstMessageWarning", "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;
|
||||
|
@ -242,7 +249,10 @@ gst_message_new_tag (GstObject * src, GstTagList * tag_list)
|
|||
{
|
||||
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;
|
||||
|
||||
return message;
|
||||
|
@ -271,6 +281,7 @@ gst_message_new_state_changed (GstObject * src, GstElementState old,
|
|||
|
||||
s = gst_structure_new ("GstMessageError", "old-state", G_TYPE_INT, (gint) old,
|
||||
"new-state", G_TYPE_INT, (gint) new, NULL);
|
||||
gst_structure_set_parent_refcount (s, &GST_DATA_REFCOUNT (message));
|
||||
message->structure = s;
|
||||
|
||||
return message;
|
||||
|
@ -293,7 +304,10 @@ gst_message_new_application (GstStructure * structure)
|
|||
{
|
||||
GstMessage *message;
|
||||
|
||||
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;
|
||||
|
||||
return message;
|
||||
|
@ -305,7 +319,9 @@ gst_message_new_application (GstStructure * structure)
|
|||
*
|
||||
* 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 @@ const GstStructure *
|
|||
gst_message_get_structure (GstMessage * message)
|
||||
{
|
||||
g_return_val_if_fail (GST_IS_MESSAGE (message), NULL);
|
||||
|
||||
return message->structure;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,11 +114,12 @@ GType gst_message_get_type (void);
|
|||
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 @@ GstMessage * gst_message_new_state_changed (GstObject * src, GstElementState ol
|
|||
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
|
||||
|
|
|
@ -193,6 +193,10 @@ void
|
|||
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 @@ gst_structure_copy (const GstStructure * structure)
|
|||
* @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)
|
||||
|
|
Loading…
Reference in a new issue