forked from enlightenment/enlightenment
fix pulse mixer startup
dbus starting this is the wrong way to go I guess, e_exec is much simpler fix T410 just in time for release!
This commit is contained in:
parent
bb4a21e986
commit
8c1f521738
|
@ -2,19 +2,14 @@
|
||||||
#include "e_mod_mixer.h"
|
#include "e_mod_mixer.h"
|
||||||
#include "Pulse.h"
|
#include "Pulse.h"
|
||||||
|
|
||||||
#define PULSE_BUS "org.PulseAudio.Core1"
|
static E_Exec_Instance *pulse_inst = NULL;
|
||||||
#define PULSE_PATH "/org/pulseaudio/core1"
|
|
||||||
#define PULSE_INTERFACE "org.PulseAudio.Core1"
|
|
||||||
|
|
||||||
static Pulse *conn = NULL;
|
static Pulse *conn = NULL;
|
||||||
static Pulse_Server_Info *info = NULL;
|
static Pulse_Server_Info *info = NULL;
|
||||||
static Pulse_Sink *default_sink = NULL;
|
static Pulse_Sink *default_sink = NULL;
|
||||||
static Ecore_Event_Handler *ph = NULL;
|
static Eina_List *handlers = NULL;
|
||||||
static Ecore_Event_Handler *pch = NULL;
|
|
||||||
static Ecore_Event_Handler *pdh = NULL;
|
|
||||||
static Eina_List *sinks = NULL;
|
static Eina_List *sinks = NULL;
|
||||||
static Eina_List *sources = NULL;
|
static Eina_List *sources = NULL;
|
||||||
static Ecore_Poller *pulse_poller = NULL;
|
|
||||||
static Eina_Hash *queue_states = NULL;
|
static Eina_Hash *queue_states = NULL;
|
||||||
static const char *_name = NULL;
|
static const char *_name = NULL;
|
||||||
|
|
||||||
|
@ -26,59 +21,13 @@ static unsigned int disc_count = 0;
|
||||||
static unsigned int update_count = 0;
|
static unsigned int update_count = 0;
|
||||||
static Ecore_Timer *update_timer = NULL;
|
static Ecore_Timer *update_timer = NULL;
|
||||||
|
|
||||||
|
|
||||||
static Eina_Bool
|
static Eina_Bool
|
||||||
_pulse_poller_cb(void *d __UNUSED__)
|
_pulse_started(void *data EINA_UNUSED, int type EINA_UNUSED, E_Exec_Instance *inst)
|
||||||
{
|
{
|
||||||
char buf[4096];
|
if (inst != pulse_inst) return ECORE_CALLBACK_RENEW;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "%s/.pulse-cookie", getenv("HOME"));
|
|
||||||
if (ecore_file_exists(buf))
|
|
||||||
return !e_mixer_pulse_init();
|
|
||||||
return EINA_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_dbus_poll(void *data EINA_UNUSED, const Eldbus_Message *msg)
|
|
||||||
{
|
|
||||||
const char *name, *from, *to;
|
|
||||||
if (eldbus_message_arguments_get(msg, "sss", &name, &from, &to))
|
|
||||||
{
|
|
||||||
if (!strcmp(name, PULSE_BUS))
|
|
||||||
e_mixer_pulse_init();
|
e_mixer_pulse_init();
|
||||||
}
|
return ECORE_CALLBACK_DONE;
|
||||||
|
|
||||||
if (dbus_handler)
|
|
||||||
{
|
|
||||||
eldbus_signal_handler_del(dbus_handler);
|
|
||||||
dbus_handler = NULL;
|
|
||||||
}
|
|
||||||
if (dbus)
|
|
||||||
{
|
|
||||||
eldbus_connection_unref(dbus);
|
|
||||||
dbus = NULL;
|
|
||||||
eldbus_shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_dbus_test(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED)
|
|
||||||
{
|
|
||||||
if (eldbus_message_error_get(msg, NULL, NULL))
|
|
||||||
{
|
|
||||||
if (dbus_handler)
|
|
||||||
{
|
|
||||||
eldbus_signal_handler_del(dbus_handler);
|
|
||||||
dbus_handler = NULL;
|
|
||||||
}
|
|
||||||
if (dbus)
|
|
||||||
{
|
|
||||||
eldbus_connection_unref(dbus);
|
|
||||||
dbus = NULL;
|
|
||||||
eldbus_shutdown();
|
|
||||||
}
|
|
||||||
e_mod_mixer_pulse_ready(EINA_FALSE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -339,52 +288,22 @@ e_mixer_pulse_init(void)
|
||||||
{
|
{
|
||||||
pulse_init();
|
pulse_init();
|
||||||
conn = pulse_new();
|
conn = pulse_new();
|
||||||
if (dbus) goto error;
|
|
||||||
if ((!conn) || (!pulse_connect(conn)))
|
if ((!conn) || (!pulse_connect(conn)))
|
||||||
{
|
{
|
||||||
Eldbus_Message *msg;
|
pulse_inst = e_exec(NULL, NULL, "pulseaudio -D", NULL, NULL);
|
||||||
double interval;
|
if (!pulse_inst) return EINA_FALSE;
|
||||||
|
|
||||||
eldbus_init();
|
E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW, (Ecore_Event_Handler_Cb)_pulse_started, NULL);
|
||||||
dbus = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
|
|
||||||
|
|
||||||
if (!dbus)
|
|
||||||
{
|
|
||||||
eldbus_shutdown();
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!pulse_poller)
|
|
||||||
{
|
|
||||||
interval = ecore_poller_poll_interval_get(ECORE_POLLER_CORE);
|
|
||||||
/* polling every 5 seconds or so I guess ? */
|
|
||||||
pulse_poller = ecore_poller_add(ECORE_POLLER_CORE, 5.0 / interval,
|
|
||||||
_pulse_poller_cb, NULL);
|
|
||||||
}
|
|
||||||
if (!dbus_handler)
|
|
||||||
dbus_handler = eldbus_signal_handler_add(dbus, ELDBUS_FDO_BUS,
|
|
||||||
ELDBUS_FDO_PATH,
|
|
||||||
ELDBUS_FDO_INTERFACE,
|
|
||||||
"NameOwnerChanged", _dbus_poll, NULL);
|
|
||||||
|
|
||||||
msg = eldbus_message_method_call_new(PULSE_BUS, PULSE_PATH, PULSE_INTERFACE, "suuuuuup");
|
|
||||||
eldbus_connection_send(dbus, msg, _dbus_test, NULL, -1); /* test for not running pulse */
|
|
||||||
pulse_free(conn);
|
pulse_free(conn);
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
pulse_shutdown();
|
pulse_shutdown();
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
pulse_poller = NULL;
|
E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_CONNECTED, (Ecore_Event_Handler_Cb)_pulse_connected, conn);
|
||||||
ph = ecore_event_handler_add(PULSE_EVENT_CONNECTED, (Ecore_Event_Handler_Cb)_pulse_connected, conn);
|
E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_CHANGE, (Ecore_Event_Handler_Cb)_pulse_update, conn);
|
||||||
pch = ecore_event_handler_add(PULSE_EVENT_CHANGE, (Ecore_Event_Handler_Cb)_pulse_update, conn);
|
E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_DISCONNECTED, (Ecore_Event_Handler_Cb)_pulse_disconnected, conn);
|
||||||
pdh = ecore_event_handler_add(PULSE_EVENT_DISCONNECTED, (Ecore_Event_Handler_Cb)_pulse_disconnected, conn);
|
|
||||||
if (!_name) _name = eina_stringshare_add("Output");
|
if (!_name) _name = eina_stringshare_add("Output");
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
error:
|
|
||||||
pulse_free(conn);
|
|
||||||
conn = NULL;
|
|
||||||
pulse_shutdown();
|
|
||||||
return EINA_FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -404,12 +323,7 @@ e_mixer_pulse_shutdown(void)
|
||||||
|
|
||||||
pulse_free(conn);
|
pulse_free(conn);
|
||||||
conn = NULL;
|
conn = NULL;
|
||||||
if (ph) ecore_event_handler_del(ph);
|
E_FREE_LIST(handlers, ecore_event_handler_del);
|
||||||
ph = NULL;
|
|
||||||
if (pch) ecore_event_handler_del(pch);
|
|
||||||
pch = NULL;
|
|
||||||
if (pdh) ecore_event_handler_del(pdh);
|
|
||||||
pdh = NULL;
|
|
||||||
if (queue_states) eina_hash_free(queue_states);
|
if (queue_states) eina_hash_free(queue_states);
|
||||||
queue_states = NULL;
|
queue_states = NULL;
|
||||||
if (dbus_handler)
|
if (dbus_handler)
|
||||||
|
|
Loading…
Reference in New Issue