mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 02:45:35 +00:00
pad: Accumulate live/non-live latency values separately
And only ever use the non-live values if all pads are non-live,
otherwise only use the results of all live pads.
It's unclear what one would use the values for in the non-live case, but
by this we at least pass them through correctly then.
This is a follow-up for 794944f779
, which
causes wrong latency calculations if the first pad is non-live but a
later pad is actually live. In that case the live values would be
accumulated together with the values of the non-live first pad,
generally causing wrong min/max latencies to be calculated.
This commit is contained in:
parent
6fc136ad84
commit
f5783e1cac
1 changed files with 33 additions and 21 deletions
54
gst/gstpad.c
54
gst/gstpad.c
|
@ -3242,9 +3242,9 @@ done:
|
||||||
/* Default latency implementation */
|
/* Default latency implementation */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
guint count;
|
|
||||||
gboolean live;
|
gboolean live;
|
||||||
GstClockTime min, max;
|
GstClockTime live_min, live_max;
|
||||||
|
GstClockTime non_live_min, non_live_max;
|
||||||
} LatencyFoldData;
|
} LatencyFoldData;
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -3268,25 +3268,29 @@ query_latency_default_fold (const GValue * item, GValue * ret,
|
||||||
if (res) {
|
if (res) {
|
||||||
gboolean live;
|
gboolean live;
|
||||||
GstClockTime min, max;
|
GstClockTime min, max;
|
||||||
|
GstClockTime *min_store, *max_store;
|
||||||
|
|
||||||
gst_query_parse_latency (query, &live, &min, &max);
|
gst_query_parse_latency (query, &live, &min, &max);
|
||||||
|
|
||||||
GST_LOG_OBJECT (pad, "got latency live:%s min:%" G_GINT64_FORMAT
|
GST_LOG_OBJECT (pad, "got latency live:%s min:%" G_GINT64_FORMAT
|
||||||
" max:%" G_GINT64_FORMAT, live ? "true" : "false", min, max);
|
" max:%" G_GINT64_FORMAT, live ? "true" : "false", min, max);
|
||||||
|
|
||||||
/* FIXME : Why do we only take values into account if it's live ? */
|
if (live) {
|
||||||
if (live || fold_data->count == 0) {
|
min_store = &fold_data->live_min;
|
||||||
if (min > fold_data->min)
|
max_store = &fold_data->live_max;
|
||||||
fold_data->min = min;
|
|
||||||
|
|
||||||
if (fold_data->max == GST_CLOCK_TIME_NONE)
|
|
||||||
fold_data->max = max;
|
|
||||||
else if (max < fold_data->max)
|
|
||||||
fold_data->max = max;
|
|
||||||
|
|
||||||
fold_data->live = live;
|
fold_data->live = live;
|
||||||
|
} else {
|
||||||
|
min_store = &fold_data->non_live_min;
|
||||||
|
max_store = &fold_data->non_live_max;
|
||||||
}
|
}
|
||||||
fold_data->count += 1;
|
|
||||||
|
if (min > *min_store)
|
||||||
|
*min_store = min;
|
||||||
|
|
||||||
|
if (*max_store == GST_CLOCK_TIME_NONE)
|
||||||
|
*max_store = max;
|
||||||
|
else if (max < *max_store)
|
||||||
|
*max_store = max;
|
||||||
} else if (peer) {
|
} else if (peer) {
|
||||||
GST_DEBUG_OBJECT (pad, "latency query failed");
|
GST_DEBUG_OBJECT (pad, "latency query failed");
|
||||||
g_value_set_boolean (ret, FALSE);
|
g_value_set_boolean (ret, FALSE);
|
||||||
|
@ -3317,10 +3321,9 @@ gst_pad_query_latency_default (GstPad * pad, GstQuery * query)
|
||||||
g_value_init (&ret, G_TYPE_BOOLEAN);
|
g_value_init (&ret, G_TYPE_BOOLEAN);
|
||||||
|
|
||||||
retry:
|
retry:
|
||||||
fold_data.count = 0;
|
|
||||||
fold_data.live = FALSE;
|
fold_data.live = FALSE;
|
||||||
fold_data.min = 0;
|
fold_data.live_min = fold_data.non_live_min = 0;
|
||||||
fold_data.max = GST_CLOCK_TIME_NONE;
|
fold_data.live_max = fold_data.non_live_max = GST_CLOCK_TIME_NONE;
|
||||||
|
|
||||||
g_value_set_boolean (&ret, TRUE);
|
g_value_set_boolean (&ret, TRUE);
|
||||||
res = gst_iterator_fold (it, query_latency_default_fold, &ret, &fold_data);
|
res = gst_iterator_fold (it, query_latency_default_fold, &ret, &fold_data);
|
||||||
|
@ -3344,15 +3347,24 @@ retry:
|
||||||
|
|
||||||
query_ret = g_value_get_boolean (&ret);
|
query_ret = g_value_get_boolean (&ret);
|
||||||
if (query_ret) {
|
if (query_ret) {
|
||||||
GST_LOG_OBJECT (pad, "got latency live:%s min:%" G_GINT64_FORMAT
|
GstClockTime min, max;
|
||||||
" max:%" G_GINT64_FORMAT, fold_data.live ? "true" : "false",
|
|
||||||
fold_data.min, fold_data.max);
|
|
||||||
|
|
||||||
if (fold_data.min > fold_data.max) {
|
if (fold_data.live) {
|
||||||
|
min = fold_data.live_min;
|
||||||
|
max = fold_data.live_max;
|
||||||
|
} else {
|
||||||
|
min = fold_data.non_live_min;
|
||||||
|
max = fold_data.non_live_max;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_LOG_OBJECT (pad, "got latency live:%s min:%" G_GINT64_FORMAT
|
||||||
|
" max:%" G_GINT64_FORMAT, fold_data.live ? "true" : "false", min, max);
|
||||||
|
|
||||||
|
if (min > max) {
|
||||||
GST_ERROR_OBJECT (pad, "minimum latency bigger than maximum latency");
|
GST_ERROR_OBJECT (pad, "minimum latency bigger than maximum latency");
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_query_set_latency (query, fold_data.live, fold_data.min, fold_data.max);
|
gst_query_set_latency (query, fold_data.live, min, max);
|
||||||
} else {
|
} else {
|
||||||
GST_LOG_OBJECT (pad, "latency query failed");
|
GST_LOG_OBJECT (pad, "latency query failed");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue