audio{enc,dec}oder: Handle max_latency == GST_CLOCK_TIME_NONE

And initialize the latencies with 0 and NONE.
This commit is contained in:
Sebastian Dröge 2015-02-03 12:12:18 +01:00
parent efe54e50e9
commit f2a762a3a0
2 changed files with 10 additions and 2 deletions

View file

@ -518,6 +518,8 @@ gst_audio_decoder_init (GstAudioDecoder * dec, GstAudioDecoderClass * klass)
dec->priv->needs_format = DEFAULT_NEEDS_FORMAT;
/* init state */
dec->priv->ctx.min_latency = 0;
dec->priv->ctx.max_latency = GST_CLOCK_TIME_NONE;
gst_audio_decoder_reset (dec, TRUE);
GST_DEBUG_OBJECT (dec, "init ok");
}
@ -2667,7 +2669,7 @@ gst_audio_decoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
/* add our latency */
if (min_latency != -1)
min_latency += dec->priv->ctx.min_latency;
if (max_latency != -1)
if (max_latency != -1 && dec->priv->ctx.max_latency != -1)
max_latency += dec->priv->ctx.max_latency;
GST_OBJECT_UNLOCK (dec);
@ -3003,6 +3005,8 @@ gst_audio_decoder_set_latency (GstAudioDecoder * dec,
GstClockTime min, GstClockTime max)
{
g_return_if_fail (GST_IS_AUDIO_DECODER (dec));
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
g_return_if_fail (min <= max);
GST_OBJECT_LOCK (dec);
dec->priv->ctx.min_latency = min;

View file

@ -446,6 +446,8 @@ gst_audio_encoder_init (GstAudioEncoder * enc, GstAudioEncoderClass * bclass)
enc->priv->drainable = DEFAULT_DRAINABLE;
/* init state */
enc->priv->ctx.min_latency = 0;
enc->priv->ctx.max_latency = GST_CLOCK_TIME_NONE;
gst_audio_encoder_reset (enc, TRUE);
GST_DEBUG_OBJECT (enc, "init ok");
}
@ -1857,7 +1859,7 @@ gst_audio_encoder_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
/* add our latency */
if (min_latency != -1)
min_latency += enc->priv->ctx.min_latency;
if (max_latency != -1)
if (max_latency != -1 && enc->priv->ctx.max_latency != -1)
max_latency += enc->priv->ctx.max_latency;
GST_OBJECT_UNLOCK (enc);
@ -2140,6 +2142,8 @@ gst_audio_encoder_set_latency (GstAudioEncoder * enc,
GstClockTime min, GstClockTime max)
{
g_return_if_fail (GST_IS_AUDIO_ENCODER (enc));
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min));
g_return_if_fail (min <= max);
GST_OBJECT_LOCK (enc);
enc->priv->ctx.min_latency = min;