mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-25 11:11:08 +00:00
tee: don't create a pool if none is needed
If the aggregated size is 0 and we create a pool, the pool would provide
buffers with no memory assigned. Handle that case and skip the pool.
This was the behaviour before cf803ea9f4
.
Add a test for this scenario.
https://bugzilla.gnome.org/show_bug.cgi?id=730758
This commit is contained in:
parent
944758aeda
commit
21c3f0ff22
2 changed files with 56 additions and 3 deletions
|
@ -797,9 +797,16 @@ gst_tee_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
if (ctx.num_pads > 1)
|
||||
ctx.min_buffers++;
|
||||
|
||||
/* Check that we actually have parameters besides the defaults. */
|
||||
if (ctx.params.align || ctx.params.prefix || ctx.params.padding) {
|
||||
gst_query_add_allocation_param (ctx.query, NULL, &ctx.params);
|
||||
}
|
||||
/* When size == 0, buffers created from this pool would have no memory
|
||||
* allocated. */
|
||||
if (ctx.size) {
|
||||
gst_query_add_allocation_pool (ctx.query, NULL, ctx.size,
|
||||
ctx.min_buffers, 0);
|
||||
}
|
||||
} else {
|
||||
gst_tee_clear_query_allocation_meta (query);
|
||||
}
|
||||
|
|
|
@ -698,6 +698,20 @@ GST_START_TEST (test_allow_not_linked)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
static gboolean
|
||||
allocation_query0 (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
GstAllocationParams param = { 0, 0, 0, 0 };
|
||||
|
||||
if (GST_QUERY_TYPE (query) != GST_QUERY_ALLOCATION)
|
||||
return gst_pad_query_default (pad, parent, query);
|
||||
|
||||
gst_query_add_allocation_pool (query, NULL, 0, 0, 0);
|
||||
gst_query_add_allocation_param (query, NULL, ¶m);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
allocation_query1 (GstPad * pad, GstObject * parent, GstQuery * query)
|
||||
{
|
||||
|
@ -901,6 +915,37 @@ GST_START_TEST (test_allocation_query_failure)
|
|||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (test_allocation_query_no_pool)
|
||||
{
|
||||
GstElement *tee;
|
||||
GstPad *sinkpad;
|
||||
GstCaps *caps;
|
||||
GstQuery *query;
|
||||
|
||||
tee = gst_check_setup_element ("tee");
|
||||
fail_unless (tee);
|
||||
|
||||
sinkpad = gst_element_get_static_pad (tee, "sink");
|
||||
add_sink_pad_and_setup_query_func (tee, allocation_query0);
|
||||
|
||||
caps = gst_caps_new_empty_simple ("test/test");
|
||||
|
||||
query = gst_query_new_allocation (caps, TRUE);
|
||||
fail_unless (gst_pad_query (sinkpad, query));
|
||||
|
||||
ck_assert_int_eq (gst_query_get_n_allocation_pools (query), 0);
|
||||
|
||||
gst_caps_unref (caps);
|
||||
gst_query_unref (query);
|
||||
gst_check_teardown_pad_by_name (tee, "src_0");
|
||||
gst_object_unref (sinkpad);
|
||||
gst_check_teardown_element (tee);
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
tee_suite (void)
|
||||
{
|
||||
|
@ -922,6 +967,7 @@ tee_suite (void)
|
|||
tcase_add_test (tc_chain, test_allocation_query_aggregation);
|
||||
tcase_add_test (tc_chain, test_allocation_query_allow_not_linked);
|
||||
tcase_add_test (tc_chain, test_allocation_query_failure);
|
||||
tcase_add_test (tc_chain, test_allocation_query_no_pool);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue