summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Hervey <edward@centricular.com>2017-08-07 12:24:37 +0200
committerSebastian Dröge <sebastian@centricular.com>2017-08-11 11:00:50 +0300
commit52e8961e16b154aa1d279240d116310afc0431e0 (patch)
treeb16e78a61bb41388aef264ad71bf2cce9e201a27
parentf36083a99f464e64f7a118b950d631d4e8de9caf (diff)
queue2: Handle buffering levels on NOT_LINKED
When downstream returns NOT_LINKED, we return the buffering level as being 100%. Since the queue is no longer being consumed/used downstream, we want applications to essentially "ignore" this queue for buffering purposes. If other streams are still being used, those stream buffering levels will be used. If none are used, upstream will post an error message on the bus indicating no streams are used. https://bugzilla.gnome.org/show_bug.cgi?id=785799
-rw-r--r--plugins/elements/gstqueue2.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c
index 8d9283870..fab140246 100644
--- a/plugins/elements/gstqueue2.c
+++ b/plugins/elements/gstqueue2.c
@@ -958,11 +958,11 @@ get_buffering_level (GstQueue2 * queue, gboolean * is_buffering,
#define GET_BUFFER_LEVEL_FOR_QUANTITY(format,alt_max) \
normalize_to_buffering_level (queue->cur_level.format,queue->max_level.format,(alt_max))
- if (queue->is_eos) {
- /* on EOS we are always 100% full, we set the var here so that it we can
- * reuse the logic below to stop buffering */
+ if (queue->is_eos || queue->srcresult == GST_FLOW_NOT_LINKED) {
+ /* on EOS and NOT_LINKED we are always 100% full, we set the var
+ * here so that we can reuse the logic below to stop buffering */
buflevel = MAX_BUFFERING_LEVEL;
- GST_LOG_OBJECT (queue, "we are EOS");
+ GST_LOG_OBJECT (queue, "we are %s", queue->is_eos ? "EOS" : "NOT_LINKED");
} else {
GST_LOG_OBJECT (queue,
"Cur level bytes/time/buffers %u/%" GST_TIME_FORMAT "/%u",
@@ -3064,6 +3064,12 @@ out_flushing:
GST_QUEUE2_MUTEX_UNLOCK (queue);
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
"pause task, reason: %s", gst_flow_get_name (queue->srcresult));
+ /* Recalculate buffering levels before stopping since the source flow
+ * might cause a different buffering level (like NOT_LINKED making
+ * the queue appear as full) */
+ if (queue->use_buffering)
+ update_buffering (queue);
+ gst_queue2_post_buffering (queue);
/* let app know about us giving up if upstream is not expected to do so */
/* EOS is already taken care of elsewhere */
if (eos && (ret == GST_FLOW_NOT_LINKED || ret < GST_FLOW_EOS)) {