mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-27 17:48:26 +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);
|
query);
|
||||||
|
|
||||||
static GstClock *gst_audio_base_sink_provide_clock (GstElement * elem);
|
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,
|
static GstClockTime gst_audio_base_sink_get_time (GstClock * clock,
|
||||||
GstAudioBaseSink * sink);
|
GstAudioBaseSink * sink);
|
||||||
static void gst_audio_base_sink_callback (GstAudioRingBuffer * rbuf,
|
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. */
|
* amount of time. */
|
||||||
max_latency = (max_l == -1) ? -1 : (base_latency + max_l);
|
max_latency = (max_l == -1) ? -1 : (base_latency + max_l);
|
||||||
|
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (basesink,
|
GST_DEBUG_OBJECT (basesink,
|
||||||
"peer min %" GST_TIME_FORMAT ", our min latency: %"
|
"peer min %" GST_TIME_FORMAT ", our min latency: %"
|
||||||
GST_TIME_FORMAT, GST_TIME_ARGS (min_l),
|
GST_TIME_FORMAT, GST_TIME_ARGS (min_l),
|
||||||
|
@ -882,10 +885,7 @@ gst_audio_base_sink_setcaps (GstBaseSink * bsink, GstCaps * caps)
|
||||||
goto acquire_error;
|
goto acquire_error;
|
||||||
|
|
||||||
/* We need to resync since the ringbuffer restarted */
|
/* We need to resync since the ringbuffer restarted */
|
||||||
sink->priv->avg_skew = -1;
|
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||||
sink->next_sample = -1;
|
|
||||||
sink->priv->eos_time = -1;
|
|
||||||
sink->priv->discont_time = -1;
|
|
||||||
|
|
||||||
if (bsink->pad_mode == GST_PAD_MODE_PUSH) {
|
if (bsink->pad_mode == GST_PAD_MODE_PUSH) {
|
||||||
GST_DEBUG_OBJECT (sink, "activate ringbuffer");
|
GST_DEBUG_OBJECT (sink, "activate ringbuffer");
|
||||||
|
@ -957,6 +957,17 @@ gst_audio_base_sink_fixate (GstBaseSink * bsink, GstCaps * caps)
|
||||||
return 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
|
static void
|
||||||
gst_audio_base_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
|
gst_audio_base_sink_get_times (GstBaseSink * bsink, GstBuffer * buffer,
|
||||||
GstClockTime * start, GstClockTime * end)
|
GstClockTime * start, GstClockTime * end)
|
||||||
|
@ -1070,10 +1081,7 @@ gst_audio_base_sink_event (GstBaseSink * bsink, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
case GST_EVENT_FLUSH_STOP:
|
case GST_EVENT_FLUSH_STOP:
|
||||||
/* always resync on sample after a flush */
|
/* always resync on sample after a flush */
|
||||||
sink->priv->avg_skew = -1;
|
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||||
sink->next_sample = -1;
|
|
||||||
sink->priv->eos_time = -1;
|
|
||||||
sink->priv->discont_time = -1;
|
|
||||||
if (sink->ringbuffer)
|
if (sink->ringbuffer)
|
||||||
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||||
break;
|
break;
|
||||||
|
@ -1489,10 +1497,7 @@ gst_audio_base_sink_sync_latency (GstBaseSink * bsink, GstMiniObject * obj)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sink->priv->avg_skew = -1;
|
gst_audio_base_sink_reset_sync (sink, TRUE);
|
||||||
sink->next_sample = -1;
|
|
||||||
sink->priv->eos_time = -1;
|
|
||||||
sink->priv->discont_time = -1;
|
|
||||||
|
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
|
|
||||||
|
@ -2161,10 +2166,8 @@ gst_audio_base_sink_change_state (GstElement * element,
|
||||||
goto open_failed;
|
goto open_failed;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
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->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_set_flushing (sink->ringbuffer, FALSE);
|
||||||
gst_audio_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
gst_audio_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue