diff --git a/gst-libs/gst/audio/gstaudiobasesink.c b/gst-libs/gst/audio/gstaudiobasesink.c index acd8c98a4a..3510754de2 100644 --- a/gst-libs/gst/audio/gstaudiobasesink.c +++ b/gst-libs/gst/audio/gstaudiobasesink.c @@ -2187,14 +2187,22 @@ gst_audio_base_sink_change_state (GstElement * element, GstAudioBaseSink *sink = GST_AUDIO_BASE_SINK (element); switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: - if (sink->ringbuffer == NULL) { - gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0); - sink->ringbuffer = gst_audio_base_sink_create_ringbuffer (sink); - } + case GST_STATE_CHANGE_NULL_TO_READY:{ + GstAudioRingBuffer *rb; + + gst_audio_clock_reset (GST_AUDIO_CLOCK (sink->provided_clock), 0); + rb = gst_audio_base_sink_create_ringbuffer (sink); + if (rb == NULL) + goto create_failed; + + GST_OBJECT_LOCK (sink); + sink->ringbuffer = rb; + GST_OBJECT_UNLOCK (sink); + if (!gst_audio_ring_buffer_open_device (sink->ringbuffer)) goto open_failed; break; + } case GST_STATE_CHANGE_READY_TO_PAUSED: gst_audio_base_sink_reset_sync (sink); gst_audio_ring_buffer_set_flushing (sink->ringbuffer, FALSE); @@ -2289,6 +2297,12 @@ gst_audio_base_sink_change_state (GstElement * element, return ret; /* ERRORS */ +create_failed: + { + /* subclass must post a meaningful error message */ + GST_DEBUG_OBJECT (sink, "create failed"); + return GST_STATE_CHANGE_FAILURE; + } open_failed: { /* subclass must post a meaningful error message */ diff --git a/gst-libs/gst/audio/gstaudiobasesrc.c b/gst-libs/gst/audio/gstaudiobasesrc.c index 38b22b54c9..7517cd88f1 100644 --- a/gst-libs/gst/audio/gstaudiobasesrc.c +++ b/gst-libs/gst/audio/gstaudiobasesrc.c @@ -1124,17 +1124,23 @@ gst_audio_base_src_change_state (GstElement * element, GstAudioBaseSrc *src = GST_AUDIO_BASE_SRC (element); switch (transition) { - case GST_STATE_CHANGE_NULL_TO_READY: + case GST_STATE_CHANGE_NULL_TO_READY:{ + GstAudioRingBuffer *rb; + GST_DEBUG_OBJECT (src, "NULL->READY"); + gst_audio_clock_reset (GST_AUDIO_CLOCK (src->clock), 0); + rb = gst_audio_base_src_create_ringbuffer (src); + if (rb == NULL) + goto create_failed; + GST_OBJECT_LOCK (src); - if (src->ringbuffer == NULL) { - gst_audio_clock_reset (GST_AUDIO_CLOCK (src->clock), 0); - src->ringbuffer = gst_audio_base_src_create_ringbuffer (src); - } + src->ringbuffer = rb; GST_OBJECT_UNLOCK (src); + if (!gst_audio_ring_buffer_open_device (src->ringbuffer)) goto open_failed; break; + } case GST_STATE_CHANGE_READY_TO_PAUSED: GST_DEBUG_OBJECT (src, "READY->PAUSED"); src->next_sample = -1; @@ -1197,6 +1203,12 @@ gst_audio_base_src_change_state (GstElement * element, return ret; /* ERRORS */ +create_failed: + { + /* subclass must post a meaningful error message */ + GST_DEBUG_OBJECT (src, "create failed"); + return GST_STATE_CHANGE_FAILURE; + } open_failed: { /* subclass must post a meaningful error message */