mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-28 11:10:37 +00:00
baseaudiosink/baseaudiosrc: Post CLOCK-LOST/CLOCK-PROVIDE when going to/from READY
Otherwise the clocks are redistributed every time the pipeline goes to PAUSED, which is quite expensive.
This commit is contained in:
parent
f7ee816355
commit
b296c96169
2 changed files with 28 additions and 30 deletions
|
@ -1835,6 +1835,16 @@ gst_base_audio_sink_change_state (GstElement * element,
|
|||
sink->priv->eos_rendering = 0;
|
||||
gst_ring_buffer_set_flushing (sink->ringbuffer, FALSE);
|
||||
gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||
|
||||
/* Only post clock-provide messages if this is the clock that
|
||||
* we've created. If the subclass has overriden it the subclass
|
||||
* should post this messages whenever necessary */
|
||||
if (sink->provided_clock && GST_IS_AUDIO_CLOCK (sink->provided_clock) &&
|
||||
GST_AUDIO_CLOCK_CAST (sink->provided_clock)->func ==
|
||||
(GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time)
|
||||
gst_element_post_message (element,
|
||||
gst_message_new_clock_provide (GST_OBJECT_CAST (element),
|
||||
sink->provided_clock, TRUE));
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
GST_OBJECT_LOCK (sink);
|
||||
|
@ -1849,18 +1859,17 @@ gst_base_audio_sink_change_state (GstElement * element,
|
|||
/* sync rendering on eos needs running clock */
|
||||
gst_ring_buffer_start (sink->ringbuffer);
|
||||
}
|
||||
|
||||
/* Only post clock-provide messages if this is the clock that
|
||||
* we've created. If the subclass has overriden it the subclass
|
||||
* should post this messages whenever necessary */
|
||||
if (sink->provided_clock && GST_IS_AUDIO_CLOCK (sink->provided_clock) &&
|
||||
GST_AUDIO_CLOCK_CAST (sink->provided_clock)->func ==
|
||||
(GstAudioClockGetTimeFunc) gst_base_audio_sink_get_time)
|
||||
gst_element_post_message (element,
|
||||
gst_message_new_clock_provide (GST_OBJECT_CAST (element),
|
||||
sink->provided_clock, TRUE));
|
||||
break;
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
/* ringbuffer cannot start anymore */
|
||||
gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||
gst_ring_buffer_pause (sink->ringbuffer);
|
||||
|
||||
GST_OBJECT_LOCK (sink);
|
||||
sink->priv->sync_latency = FALSE;
|
||||
GST_OBJECT_UNLOCK (sink);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
/* Only post clock-lost messages if this is the clock that
|
||||
* we've created. If the subclass has overriden it the subclass
|
||||
* should post this messages whenever necessary */
|
||||
|
@ -1871,15 +1880,6 @@ gst_base_audio_sink_change_state (GstElement * element,
|
|||
gst_message_new_clock_lost (GST_OBJECT_CAST (element),
|
||||
sink->provided_clock));
|
||||
|
||||
/* ringbuffer cannot start anymore */
|
||||
gst_ring_buffer_may_start (sink->ringbuffer, FALSE);
|
||||
gst_ring_buffer_pause (sink->ringbuffer);
|
||||
|
||||
GST_OBJECT_LOCK (sink);
|
||||
sink->priv->sync_latency = FALSE;
|
||||
GST_OBJECT_UNLOCK (sink);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
/* make sure we unblock before calling the parent state change
|
||||
* so it can grab the STREAM_LOCK */
|
||||
gst_ring_buffer_set_flushing (sink->ringbuffer, TRUE);
|
||||
|
|
|
@ -1076,11 +1076,6 @@ gst_base_audio_src_change_state (GstElement * element,
|
|||
src->next_sample = -1;
|
||||
gst_ring_buffer_set_flushing (src->ringbuffer, FALSE);
|
||||
gst_ring_buffer_may_start (src->ringbuffer, FALSE);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
GST_DEBUG_OBJECT (src, "PAUSED->PLAYING");
|
||||
gst_ring_buffer_may_start (src->ringbuffer, TRUE);
|
||||
|
||||
/* Only post clock-provide messages if this is the clock that
|
||||
* we've created. If the subclass has overriden it the subclass
|
||||
* should post this messages whenever necessary */
|
||||
|
@ -1091,8 +1086,17 @@ gst_base_audio_src_change_state (GstElement * element,
|
|||
gst_message_new_clock_provide (GST_OBJECT_CAST (element),
|
||||
src->clock, TRUE));
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
|
||||
GST_DEBUG_OBJECT (src, "PAUSED->PLAYING");
|
||||
gst_ring_buffer_may_start (src->ringbuffer, TRUE);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
|
||||
GST_DEBUG_OBJECT (src, "PLAYING->PAUSED");
|
||||
gst_ring_buffer_may_start (src->ringbuffer, FALSE);
|
||||
gst_ring_buffer_pause (src->ringbuffer);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
GST_DEBUG_OBJECT (src, "PAUSED->READY");
|
||||
/* Only post clock-lost messages if this is the clock that
|
||||
* we've created. If the subclass has overriden it the subclass
|
||||
* should post this messages whenever necessary */
|
||||
|
@ -1101,12 +1105,6 @@ gst_base_audio_src_change_state (GstElement * element,
|
|||
(GstAudioClockGetTimeFunc) gst_base_audio_src_get_time)
|
||||
gst_element_post_message (element,
|
||||
gst_message_new_clock_lost (GST_OBJECT_CAST (element), src->clock));
|
||||
|
||||
gst_ring_buffer_may_start (src->ringbuffer, FALSE);
|
||||
gst_ring_buffer_pause (src->ringbuffer);
|
||||
break;
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
||||
GST_DEBUG_OBJECT (src, "PAUSED->READY");
|
||||
gst_ring_buffer_set_flushing (src->ringbuffer, TRUE);
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue