mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-05-13 19:58:57 +00:00
baseaudioencoder: simplify latency variable handling
This commit is contained in:
parent
9ce2edc918
commit
e3cae1619c
2 changed files with 11 additions and 10 deletions
|
@ -208,9 +208,6 @@ struct _GstBaseAudioEncoderPrivate
|
|||
/* subclass currently being forcibly drained */
|
||||
gboolean force;
|
||||
|
||||
/* MT safe latency; taken from ctx */
|
||||
GstClockTime min_latency;
|
||||
GstClockTime max_latency;
|
||||
/* output bps estimatation */
|
||||
/* global in samples seen */
|
||||
guint64 samples_in;
|
||||
|
@ -971,23 +968,25 @@ gst_base_audio_encoder_sink_setcaps (GstPad * pad, GstCaps * caps)
|
|||
enc->ctx->lookahead = 0;
|
||||
|
||||
/* element might report latency */
|
||||
GST_OBJECT_LOCK (enc);
|
||||
old_min_latency = ctx->min_latency;
|
||||
old_max_latency = ctx->max_latency;
|
||||
GST_OBJECT_UNLOCK (enc);
|
||||
|
||||
if (klass->set_format)
|
||||
res = klass->set_format (enc, state);
|
||||
|
||||
/* notify if new latency */
|
||||
GST_OBJECT_LOCK (enc);
|
||||
if ((ctx->min_latency > 0 && ctx->min_latency != old_min_latency) ||
|
||||
(ctx->max_latency > 0 && ctx->max_latency != old_max_latency)) {
|
||||
GST_OBJECT_UNLOCK (enc);
|
||||
/* post latency message on the bus */
|
||||
gst_element_post_message (GST_ELEMENT (enc),
|
||||
gst_message_new_latency (GST_OBJECT (enc)));
|
||||
GST_OBJECT_LOCK (enc);
|
||||
enc->priv->min_latency = ctx->min_latency;
|
||||
enc->priv->max_latency = ctx->max_latency;
|
||||
GST_OBJECT_UNLOCK (enc);
|
||||
}
|
||||
GST_OBJECT_UNLOCK (enc);
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (enc, "new audio format identical to configured format");
|
||||
}
|
||||
|
@ -1460,9 +1459,9 @@ gst_base_audio_encoder_src_query (GstPad * pad, GstQuery * query)
|
|||
GST_OBJECT_LOCK (enc);
|
||||
/* add our latency */
|
||||
if (min_latency != -1)
|
||||
min_latency += enc->priv->min_latency;
|
||||
min_latency += enc->ctx->min_latency;
|
||||
if (max_latency != -1)
|
||||
max_latency += enc->priv->max_latency;
|
||||
max_latency += enc->ctx->max_latency;
|
||||
GST_OBJECT_UNLOCK (enc);
|
||||
|
||||
gst_query_set_latency (query, live, min_latency, max_latency);
|
||||
|
|
|
@ -117,7 +117,8 @@ typedef struct _GstAudioState {
|
|||
* or will be handed all available if 0.
|
||||
* @frame_max: max number of frames of size @frame_bytes accepted at once
|
||||
* (assumed minimally 1)
|
||||
* @latency: latency of element; should only be changed during configure
|
||||
* @min_latency: min latency of element
|
||||
* @max_latency: max latency of element
|
||||
* @lookahead: encoder lookahead (in units of input rate samples)
|
||||
*
|
||||
* Transparent #GstBaseAudioEncoderContext data structure.
|
||||
|
@ -129,9 +130,10 @@ struct _GstBaseAudioEncoderContext {
|
|||
/* output */
|
||||
gint frame_samples;
|
||||
gint frame_max;
|
||||
gint lookahead;
|
||||
/* MT-protected (with LOCK) */
|
||||
GstClockTime min_latency;
|
||||
GstClockTime max_latency;
|
||||
gint lookahead;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue