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
This commit is contained in:
parent
9320b0e4ea
commit
35bb87529f
|
@ -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;
|
||||
|
||||
|
@ -860,6 +875,16 @@ _shutdown(void)
|
|||
ctx = NULL;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue