mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-13 10:55:34 +00:00
gstaudiobasesink: Factor out reset sync routine
This commit is contained in:
parent
b324d67586
commit
d35db35258
1 changed files with 18 additions and 15 deletions
|
@ -160,6 +160,8 @@ static gboolean gst_audio_base_sink_query (GstElement * element, GstQuery *
|
|||
query);
|
||||
|
||||
static GstClock *gst_audio_base_sink_provide_clock (GstElement * elem);
|
||||
static inline void gst_audio_base_sink_reset_sync (GstAudioBaseSink * sink,
|
||||
gboolean sync_skew);
|
||||
static GstClockTime gst_audio_base_sink_get_time (GstClock * clock,
|
||||
GstAudioBaseSink * sink);
|
||||
static void gst_audio_base_sink_callback (GstAudioRingBuffer * rbuf,
|
||||
|
@ -465,6 +467,7 @@ gst_audio_base_sink_query (GstElement * element, GstQuery * query)
|
|||
* amount of time. */
|
||||
max_latency = (max_l == -1) ? -1 : (base_latency + max_l);
|
||||
|
||||
|
||||
GST_DEBUG_OBJECT (basesink,
|
||||
"peer min %" GST_TIME_FORMAT ", our min latency: %"
|
||||
GST_TIME_FORMAT, GST_TIME_ARGS (min_l),
|
||||
|
@ -882,10 +885,7 @@ gst_audio_base_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
|||
goto acquire_error;
|
||||
|
||||
/* We need to resync since the ringbuffer restarted */
|
||||
sink->priv->avg_skew = -1;
|
||||
sink->next_sample = -1;
|
||||
sink->priv->eos_time = -1;
|
||||
sink->priv->discont_time = -1;
|
||||
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||
|
||||
if (bsink->pad_mode == GST_PAD_MODE_PUSH) {
|
||||
GST_DEBUG_OBJECT (sink, "activate ringbuffer");
|
||||
|
@ -957,6 +957,17 @@ gst_audio_base_sink_fixate (GstBaseSink * bsink, GstCaps * caps)
|
|||
return caps;
|
||||
}
|
||||
|
||||
static inline void
|
||||
gst_audio_base_sink_reset_sync (GstAudioBaseSink * sink, gboolean sync_skew)
|
||||
{
|
||||
sink->next_sample = -1;
|
||||
sink->priv->eos_time = -1;
|
||||
sink->priv->discont_time = -1;
|
||||
|
||||
if (sync_skew)
|
||||
sink->priv->avg_skew = -1;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_audio_base_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
|
||||
GstClockTime * start, GstClockTime * end)
|
||||
|
@ -1070,10 +1081,7 @@ gst_audio_base_sink_event (GstBaseSink * bsink, GstEvent * event)
|
|||
break;
|
||||
case GST_EVENT_FLUSH_STOP:
|
||||
/* always resync on sample after a flush */
|
||||
sink->priv->avg_skew = -1;
|
||||
sink->next_sample = -1;
|
||||
sink->priv->eos_time = -1;
|
||||
sink->priv->discont_time = -1;
|
||||
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||
if (sink->ringbuffer)
|
||||
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||
break;
|
||||
|
@ -1489,10 +1497,7 @@ gst_audio_base_sink_sync_latency (GstBaseSink * bsink, GstMiniObject * obj)
|
|||
break;
|
||||
}
|
||||
|
||||
sink->priv->avg_skew = -1;
|
||||
sink->next_sample = -1;
|
||||
sink->priv->eos_time = -1;
|
||||
sink->priv->discont_time = -1;
|
||||
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||
|
||||
return GST_FLOW_OK;
|
||||
|
||||
|
@ -2161,10 +2166,8 @@ gst_audio_base_sink_change_state (GstElement * element,
|
|||
goto open_failed;
|
||||
break;
|
||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
sink->next_sample = -1;
|
||||
gst_audio_base_sink_reset_sync (sink, FALSE);
|
||||
sink->priv->last_align = -1;
|
||||
sink->priv->eos_time = -1;
|
||||
sink->priv->discont_time = -1;
|
||||
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||
gst_audio_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||
|
||||
|
|
Loading…
Reference in a new issue