diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-02-20 22:58:59 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2017-02-20 22:58:59 +0900 |
commit | 35bb87529f701f0128a338b2313092c4876c6737 (patch) | |
tree | 48c1d7df2a8b4b284d7bb60cc5c850340874e18b | |
parent | 9320b0e4ea566f396f592016ae1e076edfeaf243 (diff) | |
download | enlightenment-35bb87529f701f0128a338b2313092c4876c6737.tar.gz |
e mixer module - run pulseaudio if connect fails
so i have a situatioon where pulse is not started automagically. if
e's mixer it set to pulse... then stick to it, run pulse and keep
trying to connect every 0.2 sec until connection works. this makes
sound "just work" tm as it should...
@fix
-rw-r--r-- | src/modules/mixer/lib/backends/pulseaudio/pulse.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/modules/mixer/lib/backends/pulseaudio/pulse.c b/src/modules/mixer/lib/backends/pulseaudio/pulse.c index 4773e35528..5961410373 100644 --- a/src/modules/mixer/lib/backends/pulseaudio/pulse.c +++ b/src/modules/mixer/lib/backends/pulseaudio/pulse.c @@ -764,7 +764,7 @@ _pulse_pa_state_cb(pa_context *context, void *data) case PA_CONTEXT_FAILED: WRN("PA_CONTEXT_FAILED"); if (!ctx->connect) - ctx->connect = ecore_timer_loop_add(1.0, _pulse_connect, data); + ctx->connect = ecore_timer_loop_add(0.2, _pulse_connect, data); goto err; case PA_CONTEXT_TERMINATED: ERR("PA_CONTEXT_TERMINATE:"); @@ -841,9 +841,24 @@ _pulse_connect(void *data) return ECORE_CALLBACK_RENEW; } +static Ecore_Exe *_pulse_exe = NULL; +static Ecore_Event_Handler *_pulse_exe_handler = NULL; + static void _shutdown(void) { + if (_pulse_exe) + { + ecore_exe_kill(_pulse_exe); + ecore_exe_free(_pulse_exe); + _pulse_exe = NULL; + } + if (_pulse_exe_handler) + { + ecore_event_handler_del(_pulse_exe_handler); + _pulse_exe_handler = NULL; + } + if (!ctx) return; @@ -861,6 +876,16 @@ _shutdown(void) } static Eina_Bool +_pulse_exe_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) +{ + Ecore_Exe_Event_Del *ev = event; + + if (ev->exe != _pulse_exe) return ECORE_CALLBACK_PASS_ON; + _pulse_exe = NULL; + return ECORE_CALLBACK_DONE; +} + +static Eina_Bool _init(Emix_Event_Cb cb, const void *data) { if (ctx) @@ -876,14 +901,13 @@ _init(Emix_Event_Cb cb, const void *data) ctx->api = functable; ctx->api.userdata = ctx; - /* The reason of compares with EINA_TRUE is because ECORE_CALLBACK_RENEW - is EINA_TRUE. The function _pulse_connect returns ECORE_CALLBACK_RENEW - when could not connect to pulse. - */ - if (_pulse_connect(ctx) == EINA_TRUE) + if (_pulse_connect(ctx) == EINA_TRUE) // true == failed and try again { - _shutdown(); - return EINA_FALSE; + _pulse_exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, + _pulse_exe_del, NULL); + _pulse_exe = ecore_exe_pipe_run + ("pulseaudio", ECORE_EXE_NOT_LEADER | ECORE_EXE_TERM_WITH_PARENT, + NULL); } ctx->cb = cb; |