From 6db0ff42291ff4c44815df3a5f77c31ae1bad1ac Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Wed, 24 Jun 2015 14:43:07 +0900 Subject: [PATCH] Ecore_Audio: Avoid abort() in PulseAudio In some cases (stress test), pulseaudio fails to play a sound and pa_stream_drain() returns NULL, making pa_operation_unref() crash right after. --- src/lib/ecore_audio/ecore_audio_obj_out_pulse.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c index 901d9f6..eab7464 100644 --- a/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c +++ b/src/lib/ecore_audio/ecore_audio_obj_out_pulse.c @@ -184,6 +184,7 @@ _ecore_audio_out_pulse_ecore_audio_out_input_detach(Eo *eo_obj, Ecore_Audio_Out_ { pa_stream *stream = NULL; Eina_Bool ret2 = EINA_FALSE; + pa_operation *op; eo_do_super(eo_obj, MY_CLASS, ret2 = ecore_audio_obj_out_input_detach(in)); if (!ret2) @@ -192,8 +193,14 @@ _ecore_audio_out_pulse_ecore_audio_out_input_detach(Eo *eo_obj, Ecore_Audio_Out_ eo_do(in, stream = eo_key_data_get("pulse_data")); pa_stream_set_write_callback(stream, NULL, NULL); - pa_operation_unref(pa_stream_drain(stream, _drain_cb, NULL)); + op = pa_stream_drain(stream, _drain_cb, NULL); + if (!op) + { + ERR("Failed to drain PulseAudio stream."); + return EINA_FALSE; + } + pa_operation_unref(op); return EINA_TRUE; } -- 2.7.4