summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-20 22:58:59 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-02-20 22:58:59 +0900
commit35bb87529f701f0128a338b2313092c4876c6737 (patch)
tree48c1d7df2a8b4b284d7bb60cc5c850340874e18b
parent9320b0e4ea566f396f592016ae1e076edfeaf243 (diff)
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.c40
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 4773e3552..596141037 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)
764 case PA_CONTEXT_FAILED: 764 case PA_CONTEXT_FAILED:
765 WRN("PA_CONTEXT_FAILED"); 765 WRN("PA_CONTEXT_FAILED");
766 if (!ctx->connect) 766 if (!ctx->connect)
767 ctx->connect = ecore_timer_loop_add(1.0, _pulse_connect, data); 767 ctx->connect = ecore_timer_loop_add(0.2, _pulse_connect, data);
768 goto err; 768 goto err;
769 case PA_CONTEXT_TERMINATED: 769 case PA_CONTEXT_TERMINATED:
770 ERR("PA_CONTEXT_TERMINATE:"); 770 ERR("PA_CONTEXT_TERMINATE:");
@@ -841,9 +841,24 @@ _pulse_connect(void *data)
841 return ECORE_CALLBACK_RENEW; 841 return ECORE_CALLBACK_RENEW;
842} 842}
843 843
844static Ecore_Exe *_pulse_exe = NULL;
845static Ecore_Event_Handler *_pulse_exe_handler = NULL;
846
844static void 847static void
845_shutdown(void) 848_shutdown(void)
846{ 849{
850 if (_pulse_exe)
851 {
852 ecore_exe_kill(_pulse_exe);
853 ecore_exe_free(_pulse_exe);
854 _pulse_exe = NULL;
855 }
856 if (_pulse_exe_handler)
857 {
858 ecore_event_handler_del(_pulse_exe_handler);
859 _pulse_exe_handler = NULL;
860 }
861
847 if (!ctx) 862 if (!ctx)
848 return; 863 return;
849 864
@@ -861,6 +876,16 @@ _shutdown(void)
861} 876}
862 877
863static Eina_Bool 878static Eina_Bool
879_pulse_exe_del(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
880{
881 Ecore_Exe_Event_Del *ev = event;
882
883 if (ev->exe != _pulse_exe) return ECORE_CALLBACK_PASS_ON;
884 _pulse_exe = NULL;
885 return ECORE_CALLBACK_DONE;
886}
887
888static Eina_Bool
864_init(Emix_Event_Cb cb, const void *data) 889_init(Emix_Event_Cb cb, const void *data)
865{ 890{
866 if (ctx) 891 if (ctx)
@@ -876,14 +901,13 @@ _init(Emix_Event_Cb cb, const void *data)
876 ctx->api = functable; 901 ctx->api = functable;
877 ctx->api.userdata = ctx; 902 ctx->api.userdata = ctx;
878 903
879 /* The reason of compares with EINA_TRUE is because ECORE_CALLBACK_RENEW 904 if (_pulse_connect(ctx) == EINA_TRUE) // true == failed and try again
880 is EINA_TRUE. The function _pulse_connect returns ECORE_CALLBACK_RENEW
881 when could not connect to pulse.
882 */
883 if (_pulse_connect(ctx) == EINA_TRUE)
884 { 905 {
885 _shutdown(); 906 _pulse_exe_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
886 return EINA_FALSE; 907 _pulse_exe_del, NULL);
908 _pulse_exe = ecore_exe_pipe_run
909 ("pulseaudio", ECORE_EXE_NOT_LEADER | ECORE_EXE_TERM_WITH_PARENT,
910 NULL);
887 } 911 }
888 912
889 ctx->cb = cb; 913 ctx->cb = cb;