From f2a762a3a01ea62d0fdeb89246f0e0d5fc15a39d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Tue, 3 Feb 2015 12:12:18 +0100 Subject: [PATCH] audio{enc,dec}oder: Handle max_latency == GST_CLOCK_TIME_NONE And initialize the latencies with 0 and NONE. --- gst-libs/gst/audio/gstaudiodecoder.c | 6 +++++- gst-libs/gst/audio/gstaudioencoder.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/audio/gstaudiodecoder.c b/gst-libs/gst/audio/gstaudiodecoder.c index 40fa82a8bd..82997f445d 100644 --- a/gst-libs/gst/audio/gstaudiodecoder.c +++ b/gst-libs/gst/audio/gstaudiodecoder.c @@ -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; diff --git a/gst-libs/gst/audio/gstaudioencoder.c b/gst-libs/gst/audio/gstaudioencoder.c index d18a37d0eb..04d239ec24 100644 --- a/gst-libs/gst/audio/gstaudioencoder.c +++ b/gst-libs/gst/audio/gstaudioencoder.c @@ -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;