mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-25 17:50:36 +00:00
tee: Allocate one more buffer when multi-plexing
This extra buffer ensure that the downstream threads are not starved when multiplexing a stream. https://bugzilla.gnome.org/show_bug.cgi?id=730758
This commit is contained in:
parent
291400d819
commit
1cd0dd3503
2 changed files with 10 additions and 1 deletions
|
@ -573,6 +573,7 @@ struct AllocQueryCtx
|
|||
guint size;
|
||||
guint min_buffers;
|
||||
gboolean first_query;
|
||||
guint num_pads;
|
||||
};
|
||||
|
||||
/* This function will aggregate some of the allocation query information with
|
||||
|
@ -715,6 +716,7 @@ gst_tee_query_allocation (const GValue * item, GValue * ret, gpointer user_data)
|
|||
}
|
||||
|
||||
ctx->first_query = FALSE;
|
||||
ctx->num_pads++;
|
||||
gst_query_unref (query);
|
||||
|
||||
return TRUE;
|
||||
|
@ -758,6 +760,7 @@ gst_tee_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
gst_allocation_params_init (&ctx.params);
|
||||
ctx.size = 0;
|
||||
ctx.min_buffers = 0;
|
||||
ctx.num_pads = 0;
|
||||
gst_tee_clear_query_allocation_meta (query);
|
||||
}
|
||||
|
||||
|
@ -789,6 +792,11 @@ gst_tee_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Allocate one more buffers when multiplexing so we don't starve the
|
||||
* downstream threads. */
|
||||
if (ctx.num_pads > 1)
|
||||
ctx.min_buffers++;
|
||||
|
||||
gst_query_add_allocation_param (ctx.query, NULL, &ctx.params);
|
||||
gst_query_add_allocation_pool (ctx.query, NULL, ctx.size,
|
||||
ctx.min_buffers, 0);
|
||||
|
|
|
@ -802,7 +802,8 @@ GST_START_TEST (test_allocation_query)
|
|||
fail_unless (gst_query_get_n_allocation_pools (query), 1);
|
||||
gst_query_parse_nth_allocation_pool (query, 0, NULL, &size, &min, &max);
|
||||
fail_unless (size == 130);
|
||||
fail_unless (min == 2);
|
||||
/* The tee will allocate one more buffer when multiplexing */
|
||||
fail_unless (min == 2 + 1);
|
||||
fail_unless (max == 0);
|
||||
|
||||
fail_unless (gst_query_get_n_allocation_params (query), 1);
|
||||
|
|
Loading…
Reference in a new issue