mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-23 07:38:16 +00:00
bufferlist: foreach: always remove as parent if buffer is changed
In case the buffer is not writable, the parent (the BufferList) is not removed before calling func. So if it is changed, the parent (the BufferList) of the previous buffer should be removed after calling func.
This commit is contained in:
parent
e3afb0ea8e
commit
687c0f0ce7
2 changed files with 24 additions and 1 deletions
|
@ -307,8 +307,11 @@ gst_buffer_list_foreach (GstBufferList * list, GstBufferListFunc func,
|
|||
gst_buffer_list_remove_range_internal (list, i, 1, !was_writable);
|
||||
--len;
|
||||
} else {
|
||||
if (!was_writable)
|
||||
if (!was_writable) {
|
||||
gst_mini_object_remove_parent (GST_MINI_OBJECT_CAST (buf),
|
||||
GST_MINI_OBJECT_CAST (list));
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
list->buffers[i] = buf_ret;
|
||||
gst_mini_object_add_parent (GST_MINI_OBJECT_CAST (buf_ret),
|
||||
|
|
|
@ -539,6 +539,24 @@ GST_START_TEST (test_foreach_modify_non_writeable_list)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
GST_START_TEST (test_foreach_modify_writeable_list)
|
||||
{
|
||||
GstBufferList *b = gst_buffer_list_new_sized (1);
|
||||
GstBuffer *buf;
|
||||
|
||||
buf = gst_buffer_new ();
|
||||
gst_buffer_list_add (b, gst_buffer_ref (buf));
|
||||
|
||||
fail_unless (gst_buffer_list_is_writable (b));
|
||||
|
||||
gst_buffer_list_foreach (b, foreach_replace_buffer, NULL);
|
||||
|
||||
gst_buffer_list_unref (b);
|
||||
gst_buffer_unref (buf);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
static Suite *
|
||||
gst_buffer_list_suite (void)
|
||||
{
|
||||
|
@ -546,6 +564,7 @@ gst_buffer_list_suite (void)
|
|||
TCase *tc_chain = tcase_create ("general");
|
||||
|
||||
suite_add_tcase (s, tc_chain);
|
||||
|
||||
tcase_add_checked_fixture (tc_chain, setup, cleanup);
|
||||
tcase_add_test (tc_chain, test_add_and_iterate);
|
||||
tcase_add_test (tc_chain, test_remove);
|
||||
|
@ -559,6 +578,7 @@ gst_buffer_list_suite (void)
|
|||
tcase_add_test (tc_chain, test_new_sized_0);
|
||||
tcase_add_test (tc_chain, test_multiple_mutable_buffer_references);
|
||||
tcase_add_test (tc_chain, test_foreach_modify_non_writeable_list);
|
||||
tcase_add_test (tc_chain, test_foreach_modify_writeable_list);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue