diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-02-11 13:43:11 +0100 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-02-11 17:53:49 +0200 |
commit | 8547594727a554b040ebe86ff3181f7da8cadbe9 (patch) | |
tree | 18886df59f2e2840b72478bd18075d53cd97c777 | |
parent | cdd86d025a7c2e1c00e7a86731168793e6104276 (diff) |
Improve and fix LATENCY query handling
This now follows the design docs everywhere, especially the maximum latency
handling.
https://bugzilla.gnome.org/show_bug.cgi?id=744106
-rw-r--r-- | gst-libs/gst/app/gstappsrc.c | 4 | ||||
-rw-r--r-- | gst-libs/gst/audio/gstaudiobasesink.c | 1 | ||||
-rw-r--r-- | gst-libs/gst/audio/gstaudiodecoder.c | 9 | ||||
-rw-r--r-- | gst-libs/gst/audio/gstaudioencoder.c | 9 | ||||
-rw-r--r-- | gst-libs/gst/video/gstvideodecoder.c | 11 | ||||
-rw-r--r-- | gst-libs/gst/video/gstvideoencoder.c | 11 | ||||
-rw-r--r-- | gst/adder/gstadder.c | 16 | ||||
-rw-r--r-- | gst/playback/gsturidecodebin.c | 22 |
8 files changed, 43 insertions, 40 deletions
diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index 9d27a67c8..f3a56b356 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -887,10 +887,10 @@ gst_app_src_query (GstBaseSrc * src, GstQuery * query) /* overwrite with our values when we need to */ g_mutex_lock (&priv->mutex); - if (priv->min_latency != -1) + if (priv->min_latency != -1) { min = priv->min_latency; - if (priv->max_latency != -1) max = priv->max_latency; + } g_mutex_unlock (&priv->mutex); gst_query_set_latency (query, live, min, max); diff --git a/gst-libs/gst/audio/gstaudiobasesink.c b/gst-libs/gst/audio/gstaudiobasesink.c index 3ad7e31eb..ece99d44b 100644 --- a/gst-libs/gst/audio/gstaudiobasesink.c +++ b/gst-libs/gst/audio/gstaudiobasesink.c @@ -464,7 +464,6 @@ gst_audio_base_sink_query (GstElement * element, GstQuery * query) * amount of time. */ max_latency = (max_l == -1) ? -1 : (base_latency + max_l); - GST_DEBUG_OBJECT (basesink, "peer min %" GST_TIME_FORMAT ", our min latency: %" GST_TIME_FORMAT, GST_TIME_ARGS (min_l), diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index 991371ed7..37395d522 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -521,7 +521,7 @@ gst_audio_decoder_init (GstAudioDecoder * dec, GstAudioDecoderClass * klass) /* init state */ dec->priv->ctx.min_latency = 0; - dec->priv->ctx.max_latency = GST_CLOCK_TIME_NONE; + dec->priv->ctx.max_latency = 0; gst_audio_decoder_reset (dec, TRUE); GST_DEBUG_OBJECT (dec, "init ok"); } @@ -2692,9 +2692,10 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query) GST_OBJECT_LOCK (dec); /* add our latency */ - if (min_latency != -1) - min_latency += dec->priv->ctx.min_latency; - if (max_latency != -1 && dec->priv->ctx.max_latency != -1) + min_latency += dec->priv->ctx.min_latency; + if (max_latency == -1 || dec->priv->ctx.max_latency == -1) + max_latency = -1; + else max_latency += dec->priv->ctx.max_latency; GST_OBJECT_UNLOCK (dec); diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c index 3f2027264..3747a0b42 100644 --- a/gst-libs/gst/audio/gstaudioencoder.c +++ b/gst-libs/gst/audio/gstaudioencoder.c @@ -447,7 +447,7 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass) /* init state */ enc->priv->ctx.min_latency = 0; - enc->priv->ctx.max_latency = GST_CLOCK_TIME_NONE; + enc->priv->ctx.max_latency = 0; gst_audio_encoder_reset (enc, TRUE); GST_DEBUG_OBJECT (enc, "init ok"); } @@ -1837,9 +1837,10 @@ gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query) GST_OBJECT_LOCK (enc); /* add our latency */ - if (min_latency != -1) - min_latency += enc->priv->ctx.min_latency; - if (max_latency != -1 && enc->priv->ctx.max_latency != -1) + min_latency += enc->priv->ctx.min_latency; + if (max_latency == -1 || enc->priv->ctx.max_latency == -1) + max_latency = -1; + else max_latency += enc->priv->ctx.max_latency; GST_OBJECT_UNLOCK (enc); diff --git a/gst-libs/gst/video/gstvideodecoder.c b/gst-libs/gst/video/gstvideodecoder.c index 1bb3c4015..5d822099c 100644 --- a/gst-libs/gst/video/gstvideodecoder.c +++ b/gst-libs/gst/video/gstvideodecoder.c @@ -569,7 +569,7 @@ gst_video_decoder_init (GstVideoDecoder * decoder, GstVideoDecoderClass * klass) decoder->priv->needs_format = FALSE; decoder->priv->min_latency = 0; - decoder->priv->max_latency = GST_CLOCK_TIME_NONE; + decoder->priv->max_latency = 0; gst_video_decoder_reset (decoder, TRUE, TRUE); } @@ -1541,12 +1541,11 @@ gst_video_decoder_src_query_default (GstVideoDecoder * dec, GstQuery * query) GST_OBJECT_LOCK (dec); min_latency += dec->priv->min_latency; - if (max_latency != GST_CLOCK_TIME_NONE - && dec->priv->max_latency != GST_CLOCK_TIME_NONE) { + if (max_latency == GST_CLOCK_TIME_NONE + || dec->priv->max_latency == GST_CLOCK_TIME_NONE) + max_latency = GST_CLOCK_TIME_NONE; + else max_latency += dec->priv->max_latency; - } else if (dec->priv->max_latency != GST_CLOCK_TIME_NONE) { - max_latency = dec->priv->max_latency; - } GST_OBJECT_UNLOCK (dec); gst_query_set_latency (query, live, min_latency, max_latency); diff --git a/gst-libs/gst/video/gstvideoencoder.c b/gst-libs/gst/video/gstvideoencoder.c index 8d64d4e34..063a3d9c2 100644 --- a/gst-libs/gst/video/gstvideoencoder.c +++ b/gst-libs/gst/video/gstvideoencoder.c @@ -454,7 +454,7 @@ gst_video_encoder_init (GstVideoEncoder * encoder, GstVideoEncoderClass * klass) priv->new_headers = FALSE; priv->min_latency = 0; - priv->max_latency = GST_CLOCK_TIME_NONE; + priv->max_latency = 0; gst_video_encoder_reset (encoder, TRUE); } @@ -1199,12 +1199,11 @@ gst_video_encoder_src_query_default (GstVideoEncoder * enc, GstQuery * query) GST_OBJECT_LOCK (enc); min_latency += priv->min_latency; - if (max_latency != GST_CLOCK_TIME_NONE - && enc->priv->max_latency != GST_CLOCK_TIME_NONE) { + if (max_latency == GST_CLOCK_TIME_NONE + || enc->priv->max_latency == GST_CLOCK_TIME_NONE) + max_latency = GST_CLOCK_TIME_NONE; + else max_latency += enc->priv->max_latency; - } else if (enc->priv->max_latency != GST_CLOCK_TIME_NONE) { - max_latency = enc->priv->max_latency; - } GST_OBJECT_UNLOCK (enc); gst_query_set_latency (query, live, min_latency, max_latency); diff --git a/gst/adder/gstadder.c b/gst/adder/gstadder.c index 96d182a36..92f2b985d 100644 --- a/gst/adder/gstadder.c +++ b/gst/adder/gstadder.c @@ -527,15 +527,17 @@ gst_adder_query_latency (GstAdder * adder, GstQuery * query) if (res) { gst_query_parse_latency (peerquery, &live_cur, &min_cur, &max_cur); - if (min_cur > min) - min = min_cur; + if (live_cur) { + if (min_cur > min) + min = min_cur; - if (max_cur != GST_CLOCK_TIME_NONE && - ((max != GST_CLOCK_TIME_NONE && max_cur > max) || - (max == GST_CLOCK_TIME_NONE))) - max = max_cur; + if (max == GST_CLOCK_TIME_NONE) + max = max_cur; + else if (max_cur < max) + max = max_cur; - live = live || live_cur; + live = TRUE; + } } gst_query_unref (peerquery); diff --git a/gst/playback/gsturidecodebin.c b/gst/playback/gsturidecodebin.c index 49ce818b5..3f4c05840 100644 --- a/gst/playback/gsturidecodebin.c +++ b/gst/playback/gsturidecodebin.c @@ -2564,16 +2564,18 @@ decoder_query_latency_fold (const GValue * item, GValue * ret, QueryFold * fold) "got latency min %" GST_TIME_FORMAT ", max %" GST_TIME_FORMAT ", live %d", GST_TIME_ARGS (min), GST_TIME_ARGS (max), live); - /* for the combined latency we collect the MAX of all min latencies and - * the MIN of all max latencies */ - if (min > fold->min) - fold->min = min; - if (fold->max == -1) - fold->max = max; - else if (max < fold->max) - fold->max = max; - if (!fold->live) - fold->live = live; + if (live) { + /* for the combined latency we collect the MAX of all min latencies and + * the MIN of all max latencies */ + if (min > fold->min) + fold->min = min; + if (fold->max == -1) + fold->max = max; + else if (max < fold->max) + fold->max = max; + + fold->live = TRUE; + } } return TRUE; |