ext/annodex/gstcmmlenc.c: Use copies of header buffers for caps to avoid circular refcounting problems (as in theorad...

Original commit message from CVS:
* ext/annodex/gstcmmlenc.c: (gst_cmml_enc_set_header_on_caps):
Use copies of header buffers for caps to avoid circular refcounting
problems (as in theoradec, vorbisdec).

* tests/check/elements/cmmldec.c: (GST_START_TEST):
Fix a typo in test that meant it was testing the wrong thing.

* tests/check/elements/cmmlenc.c: (check_headers):
Fix refcount checks now that we use buffer-copies for caps.
This commit is contained in:
Michael Smith 2006-04-10 15:48:55 +00:00
parent 2fb7648fbe
commit 683ed4dc0c
4 changed files with 29 additions and 7 deletions

View file

@ -1,3 +1,15 @@
2006-04-10 Michael Smith <msmith@fluendo.com>
* ext/annodex/gstcmmlenc.c: (gst_cmml_enc_set_header_on_caps):
Use copies of header buffers for caps to avoid circular refcounting
problems (as in theoradec, vorbisdec).
* tests/check/elements/cmmldec.c: (GST_START_TEST):
Fix a typo in test that meant it was testing the wrong thing.
* tests/check/elements/cmmlenc.c: (check_headers):
Fix refcount checks now that we use buffer-copies for caps.
2006-04-10 Tim-Philipp Müller <tim at centricular dot net> 2006-04-10 Tim-Philipp Müller <tim at centricular dot net>
* gst/matroska/matroska-demux.c: (gst_matroska_demux_base_init), * gst/matroska/matroska-demux.c: (gst_matroska_demux_base_init),

View file

@ -315,6 +315,7 @@ gst_cmml_enc_set_header_on_caps (GstCmmlEnc * enc, GstCaps * caps,
GValue array = { 0 }; GValue array = { 0 };
GValue value = { 0 }; GValue value = { 0 };
GstStructure *structure; GstStructure *structure;
GstBuffer *buffer;
caps = gst_caps_make_writable (caps); caps = gst_caps_make_writable (caps);
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
@ -322,12 +323,21 @@ gst_cmml_enc_set_header_on_caps (GstCmmlEnc * enc, GstCaps * caps,
g_value_init (&array, GST_TYPE_ARRAY); g_value_init (&array, GST_TYPE_ARRAY);
g_value_init (&value, GST_TYPE_BUFFER); g_value_init (&value, GST_TYPE_BUFFER);
gst_value_set_buffer (&value, ident); /* Make copies of header buffers to avoid circular references */
buffer = gst_buffer_copy (ident);
gst_value_set_buffer (&value, buffer);
gst_value_array_append_value (&array, &value); gst_value_array_append_value (&array, &value);
gst_value_set_buffer (&value, preamble); gst_buffer_unref (buffer);
buffer = gst_buffer_copy (preamble);
gst_value_set_buffer (&value, buffer);
gst_value_array_append_value (&array, &value); gst_value_array_append_value (&array, &value);
gst_value_set_buffer (&value, head); gst_buffer_unref (buffer);
buffer = gst_buffer_copy (head);
gst_value_set_buffer (&value, buffer);
gst_value_array_append_value (&array, &value); gst_value_array_append_value (&array, &value);
gst_buffer_unref (buffer);
GST_BUFFER_FLAG_SET (ident, GST_BUFFER_FLAG_IN_CAPS); GST_BUFFER_FLAG_SET (ident, GST_BUFFER_FLAG_IN_CAPS);
GST_BUFFER_FLAG_SET (preamble, GST_BUFFER_FLAG_IN_CAPS); GST_BUFFER_FLAG_SET (preamble, GST_BUFFER_FLAG_IN_CAPS);

View file

@ -312,7 +312,7 @@ GST_START_TEST (test_tags)
fail_unless (tag_val != NULL); fail_unless (tag_val != NULL);
tag = g_value_get_object (tag_val); tag = g_value_get_object (tag_val);
fail_unless (tags != NULL); fail_unless (tag != NULL);
g_object_get (tag, "title", &title, "base-uri", &base, "meta", &meta, NULL); g_object_get (tag, "title", &title, "base-uri", &base, "meta", &meta, NULL);
fail_unless_equals_string ("The Research Hunter", title); fail_unless_equals_string ("The Research Hunter", title);

View file

@ -220,15 +220,15 @@ check_headers ()
fail_unless_equals_int (g_list_length (current_buf), 3); fail_unless_equals_int (g_list_length (current_buf), 3);
/* check the ident header */ /* check the ident header */
check_output_buffer_is_equal ("cmml-ident-buffer", IDENT_HEADER, 2); check_output_buffer_is_equal ("cmml-ident-buffer", IDENT_HEADER, 1);
/* check the cmml processing instruction */ /* check the cmml processing instruction */
current_buf = current_buf->next; current_buf = current_buf->next;
check_output_buffer_is_equal ("cmml-preamble-buffer", PREAMBLE_ENCODED, 2); check_output_buffer_is_equal ("cmml-preamble-buffer", PREAMBLE_ENCODED, 1);
/* check the encoded head tag */ /* check the encoded head tag */
current_buf = current_buf->next; current_buf = current_buf->next;
check_output_buffer_is_equal ("head-tag-buffer", HEAD_TAG_ENCODED, 2); check_output_buffer_is_equal ("head-tag-buffer", HEAD_TAG_ENCODED, 1);
} }
static void static void