diff options
author | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-08-04 15:18:37 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian.droege@collabora.co.uk> | 2010-08-04 15:19:42 +0200 |
commit | b296c96169bb5f5f2f09ea336b757e4547738700 (patch) | |
tree | 2569fc7ae76c1ed58c85b92a8c95485cd30b69ba | |
parent | f7ee816355df4dc49a16a48fa5b702ddd398401b (diff) |
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.
-rw-r--r-- | gst-libs/gst/audio/gstbaseaudiosink.c | 38 | ||||
-rw-r--r-- | gst-libs/gst/audio/gstbaseaudiosrc.c | 20 |
2 files changed, 28 insertions, 30 deletions
diff --git a/gst-libs/gst/audio/gstbaseaudiosink.c b/gst-libs/gst/audio/gstbaseaudiosink.c index 76efba9a1..4b40a5e31 100644 --- a/gst-libs/gst/audio/gstbaseaudiosink.c +++ b/gst-libs/gst/audio/gstbaseaudiosink.c @@ -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); diff --git a/gst-libs/gst/audio/gstbaseaudiosrc.c b/gst-libs/gst/audio/gstbaseaudiosrc.c index 468402c3a..b870ff4c4 100644 --- a/gst-libs/gst/audio/gstbaseaudiosrc.c +++ b/gst-libs/gst/audio/gstbaseaudiosrc.c @@ -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: |