Commit 1ea81114 authored by Sebastian Dröge's avatar Sebastian Dröge

decodebin: Store extra_buffer_required per group, not globally

It's only relevant for each group, and by storing it in the group
we have locking and everything else like for the other buffering-related
variables. Locking looks a bit fishy still, but it was like that for a long
time already so shouldn't be worse than before.
parent 5c8ef0ea
...@@ -186,8 +186,6 @@ struct _GstDecodeBin ...@@ -186,8 +186,6 @@ struct _GstDecodeBin
GList *filtered_errors; /* filtered error messages */ GList *filtered_errors; /* filtered error messages */
GList *buffering_status; /* element currently buffering messages */ GList *buffering_status; /* element currently buffering messages */
gboolean extra_buffer_required; /* whether to controll queue size or not */
}; };
struct _GstDecodeBinClass struct _GstDecodeBinClass
...@@ -287,10 +285,11 @@ static void type_found (GstElement * typefind, guint probability, ...@@ -287,10 +285,11 @@ static void type_found (GstElement * typefind, guint probability,
GstCaps * caps, GstDecodeBin * decode_bin); GstCaps * caps, GstDecodeBin * decode_bin);
static void decodebin_set_queue_size (GstDecodeBin * dbin, static void decodebin_set_queue_size (GstDecodeBin * dbin,
GstElement * multiqueue, gboolean preroll, gboolean seekable); GstElement * multiqueue, gboolean preroll, gboolean seekable,
gboolean extra_buffer_required);
static void decodebin_set_queue_size_full (GstDecodeBin * dbin, static void decodebin_set_queue_size_full (GstDecodeBin * dbin,
GstElement * multiqueue, gboolean use_buffering, gboolean preroll, GstElement * multiqueue, gboolean use_buffering, gboolean preroll,
gboolean seekable); gboolean seekable, gboolean extra_buffer_required);
static gboolean gst_decode_bin_autoplug_continue (GstElement * element, static gboolean gst_decode_bin_autoplug_continue (GstElement * element,
GstPad * pad, GstCaps * caps); GstPad * pad, GstCaps * caps);
...@@ -407,6 +406,7 @@ struct _GstDecodeGroup ...@@ -407,6 +406,7 @@ struct _GstDecodeGroup
gboolean overrun; /* TRUE if the multiqueue signaled overrun. This gboolean overrun; /* TRUE if the multiqueue signaled overrun. This
* means that we should really expose the group */ * means that we should really expose the group */
gboolean extra_buffer_required; /* whether we allow some extra buffering to happen because of overrun */
gboolean no_more_pads; /* TRUE if the demuxer signaled no-more-pads */ gboolean no_more_pads; /* TRUE if the demuxer signaled no-more-pads */
gboolean drained; /* TRUE if the all children are drained */ gboolean drained; /* TRUE if the all children are drained */
...@@ -1102,8 +1102,6 @@ gst_decode_bin_init (GstDecodeBin * decode_bin) ...@@ -1102,8 +1102,6 @@ gst_decode_bin_init (GstDecodeBin * decode_bin)
decode_bin->expose_allstreams = DEFAULT_EXPOSE_ALL_STREAMS; decode_bin->expose_allstreams = DEFAULT_EXPOSE_ALL_STREAMS;
decode_bin->connection_speed = DEFAULT_CONNECTION_SPEED; decode_bin->connection_speed = DEFAULT_CONNECTION_SPEED;
decode_bin->extra_buffer_required = FALSE;
} }
static void static void
...@@ -3051,13 +3049,15 @@ no_more_pads_cb (GstElement * element, GstDecodeChain * chain) ...@@ -3051,13 +3049,15 @@ no_more_pads_cb (GstElement * element, GstDecodeChain * chain)
GST_DEBUG_OBJECT (element, "Setting group %p to complete", group); GST_DEBUG_OBJECT (element, "Setting group %p to complete", group);
group->no_more_pads = TRUE; group->no_more_pads = TRUE;
group->dbin->extra_buffer_required = FALSE; group->extra_buffer_required = FALSE;
/* this group has prerolled enough to not need more pads, /* this group has prerolled enough to not need more pads,
* we can probably set its buffering state to playing now */ * we can probably set its buffering state to playing now */
GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to " GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to "
"'playing' buffering mode", group); "'playing' buffering mode", group);
decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE, decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
(group->parent ? group->parent->seekable : TRUE)); (group->parent ? group->parent->seekable : TRUE),
group->extra_buffer_required);
CHAIN_MUTEX_UNLOCK (chain); CHAIN_MUTEX_UNLOCK (chain);
EXPOSE_LOCK (chain->dbin); EXPOSE_LOCK (chain->dbin);
...@@ -3490,16 +3490,17 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group) ...@@ -3490,16 +3490,17 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group)
/* this group has prerolled enough to not need more pads, /* this group has prerolled enough to not need more pads,
* we can probably set its buffering state to playing now */ * we can probably set its buffering state to playing now */
if (!group->no_more_pads && group->parent->demuxer if (!group->no_more_pads && group->parent->demuxer
&& !dbin->extra_buffer_required) { && !group->extra_buffer_required) {
group->overrun = FALSE; group->overrun = FALSE;
dbin->extra_buffer_required = TRUE; group->extra_buffer_required = TRUE;
} else { } else {
GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to " GST_DEBUG_OBJECT (group->dbin, "Setting group %p multiqueue to "
"'playing' buffering mode", group); "'playing' buffering mode", group);
group->overrun = TRUE; group->overrun = TRUE;
dbin->extra_buffer_required = FALSE; group->extra_buffer_required = FALSE;
decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE, decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
(group->parent ? group->parent->seekable : TRUE)); (group->parent ? group->parent->seekable : TRUE),
group->extra_buffer_required);
} }
/* FIXME: We should make sure that everything gets exposed now /* FIXME: We should make sure that everything gets exposed now
...@@ -3514,17 +3515,17 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group) ...@@ -3514,17 +3515,17 @@ multi_queue_overrun_cb (GstElement * queue, GstDecodeGroup * group)
if (!gst_decode_bin_expose (dbin)) if (!gst_decode_bin_expose (dbin))
GST_WARNING_OBJECT (dbin, "Couldn't expose group"); GST_WARNING_OBJECT (dbin, "Couldn't expose group");
} else { } else {
dbin->extra_buffer_required = TRUE; group->extra_buffer_required = TRUE;
} }
} }
EXPOSE_UNLOCK (dbin); EXPOSE_UNLOCK (dbin);
if (dbin->extra_buffer_required) { if (group->extra_buffer_required) {
GST_DEBUG_OBJECT (group->dbin, GST_DEBUG_OBJECT (group->dbin,
"Setting group %p multiqueue to " "'extra_buffer_required' mode", "Setting group %p multiqueue to 'extra_buffer_required' mode", group);
group);
decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE, decodebin_set_queue_size (group->dbin, group->multiqueue, FALSE,
(group->parent ? group->parent->seekable : TRUE)); (group->parent ? group->parent->seekable : TRUE),
group->extra_buffer_required);
} }
} }
...@@ -3667,7 +3668,7 @@ gst_decode_chain_start_free_hidden_groups_thread (GstDecodeChain * chain) ...@@ -3667,7 +3668,7 @@ gst_decode_chain_start_free_hidden_groups_thread (GstDecodeChain * chain)
static void static void
decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue, decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue,
gboolean preroll, gboolean seekable) gboolean preroll, gboolean seekable, gboolean extra_buffer_required)
{ {
gboolean use_buffering; gboolean use_buffering;
...@@ -3675,21 +3676,22 @@ decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue, ...@@ -3675,21 +3676,22 @@ decodebin_set_queue_size (GstDecodeBin * dbin, GstElement * multiqueue,
g_object_get (multiqueue, "use-buffering", &use_buffering, NULL); g_object_get (multiqueue, "use-buffering", &use_buffering, NULL);
decodebin_set_queue_size_full (dbin, multiqueue, use_buffering, preroll, decodebin_set_queue_size_full (dbin, multiqueue, use_buffering, preroll,
seekable); seekable, extra_buffer_required);
} }
/* configure queue sizes, this depends on the buffering method and if we are /* configure queue sizes, this depends on the buffering method and if we are
* playing or prerolling. */ * playing or prerolling. */
static void static void
decodebin_set_queue_size_full (GstDecodeBin * dbin, GstElement * multiqueue, decodebin_set_queue_size_full (GstDecodeBin * dbin, GstElement * multiqueue,
gboolean use_buffering, gboolean preroll, gboolean seekable) gboolean use_buffering, gboolean preroll, gboolean seekable,
gboolean extra_buffer_required)
{ {
guint max_bytes, max_buffers; guint max_bytes, max_buffers;
guint64 max_time; guint64 max_time;
GST_DEBUG_OBJECT (multiqueue, GST_DEBUG_OBJECT (multiqueue,
"use buffering %d, add extra buffer size mode %d", use_buffering, "preroll: %d, use buffering: %d, seekable: %d, extra buffer mode: %d",
dbin->extra_buffer_required); preroll, use_buffering, seekable, extra_buffer_required);
if (preroll || use_buffering) { if (preroll || use_buffering) {
/* takes queue limits, initially we only queue up up to the max bytes limit, /* takes queue limits, initially we only queue up up to the max bytes limit,
...@@ -3705,7 +3707,7 @@ decodebin_set_queue_size_full (GstDecodeBin * dbin, GstElement * multiqueue, ...@@ -3705,7 +3707,7 @@ decodebin_set_queue_size_full (GstDecodeBin * dbin, GstElement * multiqueue,
max_time = seekable ? AUTO_PREROLL_SEEKABLE_SIZE_TIME : max_time = seekable ? AUTO_PREROLL_SEEKABLE_SIZE_TIME :
AUTO_PREROLL_NOT_SEEKABLE_SIZE_TIME; AUTO_PREROLL_NOT_SEEKABLE_SIZE_TIME;
} }
} else if (dbin->extra_buffer_required) { } else if (extra_buffer_required) {
max_bytes = AUTO_PREROLL_SIZE_BYTES + DEFAULT_EXTRA_SIZE_BUFFERS_BYTES; max_bytes = AUTO_PREROLL_SIZE_BYTES + DEFAULT_EXTRA_SIZE_BUFFERS_BYTES;
max_buffers = AUTO_PREROLL_SIZE_BUFFERS; max_buffers = AUTO_PREROLL_SIZE_BUFFERS;
if ((max_time = dbin->max_size_time) == 0) if ((max_time = dbin->max_size_time) == 0)
...@@ -3769,7 +3771,10 @@ gst_decode_group_new (GstDecodeBin * dbin, GstDecodeChain * parent) ...@@ -3769,7 +3771,10 @@ gst_decode_group_new (GstDecodeBin * dbin, GstDecodeChain * parent)
gst_object_unref (pad); gst_object_unref (pad);
} }
} }
decodebin_set_queue_size_full (dbin, mq, FALSE, TRUE, seekable); group->extra_buffer_required = FALSE;
decodebin_set_queue_size_full (dbin, mq, FALSE, TRUE, seekable,
group->extra_buffer_required);
group->overrunsig = g_signal_connect (mq, "overrun", group->overrunsig = g_signal_connect (mq, "overrun",
G_CALLBACK (multi_queue_overrun_cb), group); G_CALLBACK (multi_queue_overrun_cb), group);
...@@ -4247,7 +4252,8 @@ gst_decode_group_reset_buffering (GstDecodeGroup * group) ...@@ -4247,7 +4252,8 @@ gst_decode_group_reset_buffering (GstDecodeGroup * group)
} }
decodebin_set_queue_size_full (group->dbin, group->multiqueue, !ret, decodebin_set_queue_size_full (group->dbin, group->multiqueue, !ret,
FALSE, (group->parent ? group->parent->seekable : TRUE)); FALSE, (group->parent ? group->parent->seekable : TRUE),
group->extra_buffer_required);
if (ret) { if (ret) {
/* all chains are buffering already, no need to do it here */ /* all chains are buffering already, no need to do it here */
...@@ -5201,7 +5207,6 @@ gst_decode_bin_change_state (GstElement * element, GstStateChange transition) ...@@ -5201,7 +5207,6 @@ gst_decode_bin_change_state (GstElement * element, GstStateChange transition)
g_list_free_full (dbin->buffering_status, g_list_free_full (dbin->buffering_status,
(GDestroyNotify) gst_message_unref); (GDestroyNotify) gst_message_unref);
dbin->buffering_status = NULL; dbin->buffering_status = NULL;
dbin->extra_buffer_required = FALSE;
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment