From 2c5976d355ed703288bcb0e832ddb999b157ba6e Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Tue, 17 Aug 2010 13:41:49 +0200 Subject: [PATCH] pulsesink: clear the PA mainloop if baseaudiosink failed to open the ring_buffer If the application requests a state-change and pulsesink fails to open the ring_buffer device the mainloop attribute of the sink should be cleaned up to avoid future state-change (NULL->READY) failures. --- ext/pulse/pulsesink.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index a8d019cc8a..5ae22ae191 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -2501,6 +2501,15 @@ gst_pulsesink_change_state (GstElement * element, GstStateChange transition) ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); + /* Clear the PA mainloop if baseaudiosink failed to open the ring_buffer */ + if (ret == GST_STATE_CHANGE_FAILURE + && transition == GST_STATE_CHANGE_NULL_TO_READY) { + g_assert (pulsesink->mainloop); + pa_threaded_mainloop_stop (pulsesink->mainloop); + pa_threaded_mainloop_free (pulsesink->mainloop); + pulsesink->mainloop = NULL; + } + switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: gst_element_post_message (element,