mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-27 01:28:34 +00:00
videodecoder: Only post latency message if it changed
Posting latency messages causes a full and potentially expensive latency recalculation of the pipeline. While subclasses should check whether the latency really changed or not before calling this function, we ensure that we do not post such messages if it didn't change. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3291>
This commit is contained in:
parent
c29bfbe448
commit
74ec0d4b0c
1 changed files with 29 additions and 7 deletions
|
@ -446,6 +446,9 @@ struct _GstVideoDecoderPrivate
|
|||
gint64 min_latency;
|
||||
gint64 max_latency;
|
||||
|
||||
/* Tracks whether the latency message was posted at least once */
|
||||
gboolean posted_latency_msg;
|
||||
|
||||
/* upstream stream tags (global tags are passed through as-is) */
|
||||
GstTagList *upstream_tags;
|
||||
|
||||
|
@ -2384,6 +2387,8 @@ gst_video_decoder_reset (GstVideoDecoder * decoder, gboolean full,
|
|||
priv->dropped = 0;
|
||||
priv->processed = 0;
|
||||
|
||||
priv->posted_latency_msg = FALSE;
|
||||
|
||||
priv->decode_frame_number = 0;
|
||||
priv->base_picture_number = 0;
|
||||
|
||||
|
@ -5073,24 +5078,41 @@ gst_video_decoder_get_estimate_rate (GstVideoDecoder * dec)
|
|||
* @min_latency: minimum latency
|
||||
* @max_latency: maximum latency
|
||||
*
|
||||
* Lets #GstVideoDecoder sub-classes tell the baseclass what the decoder
|
||||
* latency is. Will also post a LATENCY message on the bus so the pipeline
|
||||
* can reconfigure its global latency.
|
||||
* Lets #GstVideoDecoder sub-classes tell the baseclass what the decoder latency
|
||||
* is. 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
|
||||
gst_video_decoder_set_latency (GstVideoDecoder * decoder,
|
||||
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 (max_latency >= min_latency);
|
||||
|
||||
GST_DEBUG_OBJECT (decoder,
|
||||
"min_latency:%" GST_TIME_FORMAT " max_latency:%" GST_TIME_FORMAT,
|
||||
GST_TIME_ARGS (min_latency), GST_TIME_ARGS (max_latency));
|
||||
|
||||
GST_OBJECT_LOCK (decoder);
|
||||
decoder->priv->min_latency = min_latency;
|
||||
decoder->priv->max_latency = max_latency;
|
||||
if (decoder->priv->min_latency != min_latency) {
|
||||
decoder->priv->min_latency = min_latency;
|
||||
post_message = TRUE;
|
||||
}
|
||||
if (decoder->priv->max_latency != max_latency) {
|
||||
decoder->priv->max_latency = max_latency;
|
||||
post_message = TRUE;
|
||||
}
|
||||
if (!decoder->priv->posted_latency_msg) {
|
||||
decoder->priv->posted_latency_msg = TRUE;
|
||||
post_message = TRUE;
|
||||
}
|
||||
GST_OBJECT_UNLOCK (decoder);
|
||||
|
||||
gst_element_post_message (GST_ELEMENT_CAST (decoder),
|
||||
gst_message_new_latency (GST_OBJECT_CAST (decoder)));
|
||||
if (post_message)
|
||||
gst_element_post_message (GST_ELEMENT_CAST (decoder),
|
||||
gst_message_new_latency (GST_OBJECT_CAST (decoder)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue