mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-05 05:52:37 +00:00
core/base: Only post latency messages if the latency values have actually changed
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1525 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3291>
This commit is contained in:
parent
74ec0d4b0c
commit
4925002d87
6 changed files with 130 additions and 25 deletions
|
@ -183,6 +183,9 @@ struct _GstAppSrcPrivate
|
||||||
|
|
||||||
guint64 min_latency;
|
guint64 min_latency;
|
||||||
guint64 max_latency;
|
guint64 max_latency;
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
gboolean emit_signals;
|
gboolean emit_signals;
|
||||||
guint min_percent;
|
guint min_percent;
|
||||||
gboolean handle_segment_change;
|
gboolean handle_segment_change;
|
||||||
|
@ -1103,6 +1106,7 @@ gst_app_src_stop (GstBaseSrc * bsrc)
|
||||||
priv->is_eos = FALSE;
|
priv->is_eos = FALSE;
|
||||||
priv->flushing = TRUE;
|
priv->flushing = TRUE;
|
||||||
priv->started = FALSE;
|
priv->started = FALSE;
|
||||||
|
priv->posted_latency_msg = FALSE;
|
||||||
gst_app_src_flush_queued (appsrc, TRUE);
|
gst_app_src_flush_queued (appsrc, TRUE);
|
||||||
g_cond_broadcast (&priv->cond);
|
g_cond_broadcast (&priv->cond);
|
||||||
g_mutex_unlock (&priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
@ -2325,6 +2329,10 @@ gst_app_src_set_latencies (GstAppSrc * appsrc, gboolean do_min, guint64 min,
|
||||||
priv->max_latency = max;
|
priv->max_latency = max;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
|
if (!priv->posted_latency_msg) {
|
||||||
|
priv->posted_latency_msg = TRUE;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
g_mutex_unlock (&priv->mutex);
|
g_mutex_unlock (&priv->mutex);
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|
|
@ -180,6 +180,8 @@ typedef struct _GstAudioDecoderContext
|
||||||
/* MT-protected (with LOCK) */
|
/* MT-protected (with LOCK) */
|
||||||
GstClockTime min_latency;
|
GstClockTime min_latency;
|
||||||
GstClockTime max_latency;
|
GstClockTime max_latency;
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
GstAllocationParams params;
|
GstAllocationParams params;
|
||||||
|
@ -555,6 +557,7 @@ gst_audio_decoder_reset (GstAudioDecoder * dec, gboolean full)
|
||||||
memset (&dec->priv->ctx, 0, sizeof (dec->priv->ctx));
|
memset (&dec->priv->ctx, 0, sizeof (dec->priv->ctx));
|
||||||
|
|
||||||
gst_audio_info_init (&dec->priv->ctx.info);
|
gst_audio_info_init (&dec->priv->ctx.info);
|
||||||
|
dec->priv->ctx.posted_latency_msg = FALSE;
|
||||||
GST_OBJECT_UNLOCK (dec);
|
GST_OBJECT_UNLOCK (dec);
|
||||||
dec->priv->ctx.had_output_data = FALSE;
|
dec->priv->ctx.had_output_data = FALSE;
|
||||||
dec->priv->ctx.had_input_data = FALSE;
|
dec->priv->ctx.had_input_data = FALSE;
|
||||||
|
@ -3391,24 +3394,43 @@ gst_audio_decoder_get_max_errors (GstAudioDecoder * dec)
|
||||||
* @min: minimum latency
|
* @min: minimum latency
|
||||||
* @max: maximum latency
|
* @max: maximum latency
|
||||||
*
|
*
|
||||||
* Sets decoder latency.
|
* Sets decoder latency. If the provided values changed from
|
||||||
|
* previously provided ones, this will also post a LATENCY message on the bus
|
||||||
|
* so the pipeline can reconfigure its global latency.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_audio_decoder_set_latency (GstAudioDecoder * dec,
|
gst_audio_decoder_set_latency (GstAudioDecoder * dec,
|
||||||
GstClockTime min, GstClockTime max)
|
GstClockTime min, GstClockTime max)
|
||||||
{
|
{
|
||||||
|
gboolean post_message = FALSE;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_AUDIO_DECODER (dec));
|
g_return_if_fail (GST_IS_AUDIO_DECODER (dec));
|
||||||
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
|
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
|
||||||
g_return_if_fail (min <= max);
|
g_return_if_fail (min <= max);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (dec,
|
||||||
|
"min_latency:%" GST_TIME_FORMAT " max_latency:%" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
||||||
|
|
||||||
GST_OBJECT_LOCK (dec);
|
GST_OBJECT_LOCK (dec);
|
||||||
dec->priv->ctx.min_latency = min;
|
if (dec->priv->ctx.min_latency != min) {
|
||||||
dec->priv->ctx.max_latency = max;
|
dec->priv->ctx.min_latency = min;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (dec->priv->ctx.max_latency != max) {
|
||||||
|
dec->priv->ctx.max_latency = max;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (!dec->priv->ctx.posted_latency_msg) {
|
||||||
|
dec->priv->ctx.posted_latency_msg = TRUE;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
GST_OBJECT_UNLOCK (dec);
|
GST_OBJECT_UNLOCK (dec);
|
||||||
|
|
||||||
/* post latency message on the bus */
|
/* post latency message on the bus */
|
||||||
gst_element_post_message (GST_ELEMENT (dec),
|
if (post_message)
|
||||||
gst_message_new_latency (GST_OBJECT (dec)));
|
gst_element_post_message (GST_ELEMENT (dec),
|
||||||
|
gst_message_new_latency (GST_OBJECT (dec)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -172,6 +172,9 @@ typedef struct _GstAudioEncoderContext
|
||||||
GstClockTime min_latency;
|
GstClockTime min_latency;
|
||||||
GstClockTime max_latency;
|
GstClockTime max_latency;
|
||||||
|
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
GList *headers;
|
GList *headers;
|
||||||
gboolean new_headers;
|
gboolean new_headers;
|
||||||
|
|
||||||
|
@ -487,6 +490,7 @@ gst_audio_encoder_reset (GstAudioEncoder * enc, gboolean full)
|
||||||
|
|
||||||
memset (&enc->priv->ctx, 0, sizeof (enc->priv->ctx));
|
memset (&enc->priv->ctx, 0, sizeof (enc->priv->ctx));
|
||||||
gst_audio_info_init (&enc->priv->ctx.info);
|
gst_audio_info_init (&enc->priv->ctx.info);
|
||||||
|
enc->priv->ctx.posted_latency_msg = FALSE;
|
||||||
GST_OBJECT_UNLOCK (enc);
|
GST_OBJECT_UNLOCK (enc);
|
||||||
|
|
||||||
if (enc->priv->upstream_tags) {
|
if (enc->priv->upstream_tags) {
|
||||||
|
@ -2308,27 +2312,43 @@ gst_audio_encoder_get_lookahead (GstAudioEncoder * enc)
|
||||||
* @min: minimum latency
|
* @min: minimum latency
|
||||||
* @max: maximum latency
|
* @max: maximum latency
|
||||||
*
|
*
|
||||||
* Sets encoder latency.
|
* Sets encoder latency. If the provided values changed from
|
||||||
|
* previously provided ones, this will also post a LATENCY message on the bus
|
||||||
|
* so the pipeline can reconfigure its global latency.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_audio_encoder_set_latency (GstAudioEncoder * enc,
|
gst_audio_encoder_set_latency (GstAudioEncoder * enc,
|
||||||
GstClockTime min, GstClockTime max)
|
GstClockTime min, GstClockTime max)
|
||||||
{
|
{
|
||||||
|
gboolean post_message = FALSE;
|
||||||
|
|
||||||
g_return_if_fail (GST_IS_AUDIO_ENCODER (enc));
|
g_return_if_fail (GST_IS_AUDIO_ENCODER (enc));
|
||||||
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
|
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
|
||||||
g_return_if_fail (min <= max);
|
g_return_if_fail (min <= max);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (enc);
|
GST_DEBUG_OBJECT (enc,
|
||||||
enc->priv->ctx.min_latency = min;
|
"min_latency:%" GST_TIME_FORMAT " max_latency:%" GST_TIME_FORMAT,
|
||||||
enc->priv->ctx.max_latency = max;
|
|
||||||
GST_OBJECT_UNLOCK (enc);
|
|
||||||
|
|
||||||
GST_LOG_OBJECT (enc, "set to %" GST_TIME_FORMAT "-%" GST_TIME_FORMAT,
|
|
||||||
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
GST_TIME_ARGS (min), GST_TIME_ARGS (max));
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (enc);
|
||||||
|
if (enc->priv->ctx.min_latency != min) {
|
||||||
|
enc->priv->ctx.min_latency = min;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (enc->priv->ctx.max_latency != max) {
|
||||||
|
enc->priv->ctx.max_latency = max;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (!enc->priv->ctx.posted_latency_msg) {
|
||||||
|
enc->priv->ctx.posted_latency_msg = TRUE;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (enc);
|
||||||
|
|
||||||
/* post latency message on the bus */
|
/* post latency message on the bus */
|
||||||
gst_element_post_message (GST_ELEMENT (enc),
|
if (post_message)
|
||||||
gst_message_new_latency (GST_OBJECT (enc)));
|
gst_element_post_message (GST_ELEMENT (enc),
|
||||||
|
gst_message_new_latency (GST_OBJECT (enc)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -134,6 +134,9 @@ struct _GstVideoEncoderPrivate
|
||||||
gint64 min_latency;
|
gint64 min_latency;
|
||||||
gint64 max_latency;
|
gint64 max_latency;
|
||||||
|
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
/* FIXME 2.0: Use a GQueue or similar, see GstVideoCodecFrame::events */
|
/* FIXME 2.0: Use a GQueue or similar, see GstVideoCodecFrame::events */
|
||||||
GList *current_frame_events;
|
GList *current_frame_events;
|
||||||
|
|
||||||
|
@ -524,6 +527,8 @@ gst_video_encoder_reset (GstVideoEncoder * encoder, gboolean hard)
|
||||||
|
|
||||||
priv->dropped = 0;
|
priv->dropped = 0;
|
||||||
priv->processed = 0;
|
priv->processed = 0;
|
||||||
|
|
||||||
|
priv->posted_latency_msg = FALSE;
|
||||||
} else {
|
} else {
|
||||||
GList *l;
|
GList *l;
|
||||||
|
|
||||||
|
@ -2864,22 +2869,41 @@ gst_video_encoder_set_output_state (GstVideoEncoder * encoder, GstCaps * caps,
|
||||||
* @min_latency: minimum latency
|
* @min_latency: minimum latency
|
||||||
* @max_latency: maximum latency
|
* @max_latency: maximum latency
|
||||||
*
|
*
|
||||||
* Informs baseclass of encoding latency.
|
* Informs baseclass of encoding latency. If the provided values changed from
|
||||||
|
* previously provided ones, this will also post a LATENCY message on the bus
|
||||||
|
* so the pipeline can reconfigure its global latency.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_video_encoder_set_latency (GstVideoEncoder * encoder,
|
gst_video_encoder_set_latency (GstVideoEncoder * encoder,
|
||||||
GstClockTime min_latency, GstClockTime max_latency)
|
GstClockTime min_latency, GstClockTime max_latency)
|
||||||
{
|
{
|
||||||
|
gboolean post_message = FALSE;
|
||||||
|
|
||||||
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency));
|
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency));
|
||||||
g_return_if_fail (max_latency >= min_latency);
|
g_return_if_fail (max_latency >= min_latency);
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (encoder,
|
||||||
|
"min_latency:%" GST_TIME_FORMAT " max_latency:%" GST_TIME_FORMAT,
|
||||||
|
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
||||||
|
|
||||||
GST_OBJECT_LOCK (encoder);
|
GST_OBJECT_LOCK (encoder);
|
||||||
encoder->priv->min_latency = min_latency;
|
if (encoder->priv->min_latency != min_latency) {
|
||||||
encoder->priv->max_latency = max_latency;
|
encoder->priv->min_latency = min_latency;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (encoder->priv->max_latency != max_latency) {
|
||||||
|
encoder->priv->max_latency = max_latency;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (!encoder->priv->posted_latency_msg) {
|
||||||
|
encoder->priv->posted_latency_msg = TRUE;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
GST_OBJECT_UNLOCK (encoder);
|
GST_OBJECT_UNLOCK (encoder);
|
||||||
|
|
||||||
gst_element_post_message (GST_ELEMENT_CAST (encoder),
|
if (post_message)
|
||||||
gst_message_new_latency (GST_OBJECT_CAST (encoder)));
|
gst_element_post_message (GST_ELEMENT_CAST (encoder),
|
||||||
|
gst_message_new_latency (GST_OBJECT_CAST (encoder)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -382,6 +382,8 @@ struct _GstAggregatorPrivate
|
||||||
|
|
||||||
GstClockTime sub_latency_min; /* protected by src_lock */
|
GstClockTime sub_latency_min; /* protected by src_lock */
|
||||||
GstClockTime sub_latency_max; /* protected by src_lock */
|
GstClockTime sub_latency_max; /* protected by src_lock */
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
GstClockTime upstream_latency_min; /* protected by src_lock */
|
GstClockTime upstream_latency_min; /* protected by src_lock */
|
||||||
|
|
||||||
|
@ -1897,6 +1899,7 @@ gst_aggregator_stop (GstAggregator * agg)
|
||||||
agg->priv->has_peer_latency = FALSE;
|
agg->priv->has_peer_latency = FALSE;
|
||||||
agg->priv->peer_latency_live = FALSE;
|
agg->priv->peer_latency_live = FALSE;
|
||||||
agg->priv->peer_latency_min = agg->priv->peer_latency_max = 0;
|
agg->priv->peer_latency_min = agg->priv->peer_latency_max = 0;
|
||||||
|
agg->priv->posted_latency_msg = FALSE;
|
||||||
|
|
||||||
if (agg->priv->tags)
|
if (agg->priv->tags)
|
||||||
gst_tag_list_unref (agg->priv->tags);
|
gst_tag_list_unref (agg->priv->tags);
|
||||||
|
@ -3667,7 +3670,7 @@ gst_aggregator_merge_tags (GstAggregator * self,
|
||||||
*
|
*
|
||||||
* Lets #GstAggregator sub-classes tell the baseclass what their internal
|
* Lets #GstAggregator sub-classes tell the baseclass what their internal
|
||||||
* latency is. Will also post a LATENCY message on the bus so the pipeline
|
* latency is. Will also post a LATENCY message on the bus so the pipeline
|
||||||
* can reconfigure its global latency.
|
* can reconfigure its global latency if the values changed.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_aggregator_set_latency (GstAggregator * self,
|
gst_aggregator_set_latency (GstAggregator * self,
|
||||||
|
@ -3688,6 +3691,10 @@ gst_aggregator_set_latency (GstAggregator * self,
|
||||||
self->priv->sub_latency_max = max_latency;
|
self->priv->sub_latency_max = max_latency;
|
||||||
changed = TRUE;
|
changed = TRUE;
|
||||||
}
|
}
|
||||||
|
if (!self->priv->posted_latency_msg) {
|
||||||
|
self->priv->posted_latency_msg = TRUE;
|
||||||
|
changed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
if (changed)
|
if (changed)
|
||||||
SRC_BROADCAST (self);
|
SRC_BROADCAST (self);
|
||||||
|
|
|
@ -231,6 +231,8 @@ struct _GstBaseParsePrivate
|
||||||
guint lead_in, lead_out;
|
guint lead_in, lead_out;
|
||||||
GstClockTime lead_in_ts, lead_out_ts;
|
GstClockTime lead_in_ts, lead_out_ts;
|
||||||
GstClockTime min_latency, max_latency;
|
GstClockTime min_latency, max_latency;
|
||||||
|
/* Tracks whether the latency message was posted at least once */
|
||||||
|
gboolean posted_latency_msg;
|
||||||
|
|
||||||
gboolean discont;
|
gboolean discont;
|
||||||
gboolean flushing;
|
gboolean flushing;
|
||||||
|
@ -899,6 +901,7 @@ gst_base_parse_reset (GstBaseParse * parse)
|
||||||
parse->priv->detect_buffers_size = 0;
|
parse->priv->detect_buffers_size = 0;
|
||||||
|
|
||||||
parse->priv->segment_seqnum = GST_SEQNUM_INVALID;
|
parse->priv->segment_seqnum = GST_SEQNUM_INVALID;
|
||||||
|
parse->priv->posted_latency_msg = FALSE;
|
||||||
GST_OBJECT_UNLOCK (parse);
|
GST_OBJECT_UNLOCK (parse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4071,23 +4074,44 @@ gst_base_parse_set_infer_ts (GstBaseParse * parse, gboolean infer_ts)
|
||||||
* @max_latency: maximum parse latency
|
* @max_latency: maximum parse latency
|
||||||
*
|
*
|
||||||
* Sets the minimum and maximum (which may likely be equal) latency introduced
|
* Sets the minimum and maximum (which may likely be equal) latency introduced
|
||||||
* by the parsing process. If there is such a latency, which depends on the
|
* by the parsing process. If there is such a latency, which depends on the
|
||||||
* particular parsing of the format, it typically corresponds to 1 frame duration.
|
* particular parsing of the format, it typically corresponds to 1 frame duration.
|
||||||
|
*
|
||||||
|
* If the provided values changed from previously provided ones, this will
|
||||||
|
* also post a LATENCY message on the bus so the pipeline can reconfigure its
|
||||||
|
* global latency.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_base_parse_set_latency (GstBaseParse * parse, GstClockTime min_latency,
|
gst_base_parse_set_latency (GstBaseParse * parse, GstClockTime min_latency,
|
||||||
GstClockTime max_latency)
|
GstClockTime max_latency)
|
||||||
{
|
{
|
||||||
|
gboolean post_message = FALSE;
|
||||||
|
|
||||||
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency));
|
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency));
|
||||||
g_return_if_fail (min_latency <= max_latency);
|
g_return_if_fail (min_latency <= max_latency);
|
||||||
|
|
||||||
GST_OBJECT_LOCK (parse);
|
|
||||||
parse->priv->min_latency = min_latency;
|
|
||||||
parse->priv->max_latency = max_latency;
|
|
||||||
GST_OBJECT_UNLOCK (parse);
|
|
||||||
GST_INFO_OBJECT (parse, "min/max latency %" GST_TIME_FORMAT ", %"
|
GST_INFO_OBJECT (parse, "min/max latency %" GST_TIME_FORMAT ", %"
|
||||||
GST_TIME_FORMAT, GST_TIME_ARGS (min_latency),
|
GST_TIME_FORMAT, GST_TIME_ARGS (min_latency),
|
||||||
GST_TIME_ARGS (max_latency));
|
GST_TIME_ARGS (max_latency));
|
||||||
|
|
||||||
|
GST_OBJECT_LOCK (parse);
|
||||||
|
if (parse->priv->min_latency != min_latency) {
|
||||||
|
parse->priv->min_latency = min_latency;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (parse->priv->max_latency != max_latency) {
|
||||||
|
parse->priv->max_latency = max_latency;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
if (!parse->priv->posted_latency_msg) {
|
||||||
|
parse->priv->posted_latency_msg = TRUE;
|
||||||
|
post_message = TRUE;
|
||||||
|
}
|
||||||
|
GST_OBJECT_UNLOCK (parse);
|
||||||
|
|
||||||
|
if (post_message)
|
||||||
|
gst_element_post_message (GST_ELEMENT_CAST (parse),
|
||||||
|
gst_message_new_latency (GST_OBJECT_CAST (parse)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue