summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2013-11-30 11:11:30 -0500
committerMike Blumenkrantz <zmike@samsung.com>2013-11-30 11:11:30 -0500
commit8c1f521738ad3d2276b0b2c27bc2d6f3e8bd81d3 (patch)
tree6a59832b48dbf0575286de89353a2f02d267f2d0 /src/modules
parentbb4a21e98656fe2c7d98ba2163e6defe9a630e2b (diff)
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!
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/mixer/sys_pulse.c114
1 files changed, 14 insertions, 100 deletions
diff --git a/src/modules/mixer/sys_pulse.c b/src/modules/mixer/sys_pulse.c
index 23763359b..0a0e51b81 100644
--- a/src/modules/mixer/sys_pulse.c
+++ b/src/modules/mixer/sys_pulse.c
@@ -2,19 +2,14 @@
2#include "e_mod_mixer.h" 2#include "e_mod_mixer.h"
3#include "Pulse.h" 3#include "Pulse.h"
4 4
5#define PULSE_BUS "org.PulseAudio.Core1" 5static E_Exec_Instance *pulse_inst = NULL;
6#define PULSE_PATH "/org/pulseaudio/core1"
7#define PULSE_INTERFACE "org.PulseAudio.Core1"
8 6
9static Pulse *conn = NULL; 7static Pulse *conn = NULL;
10static Pulse_Server_Info *info = NULL; 8static Pulse_Server_Info *info = NULL;
11static Pulse_Sink *default_sink = NULL; 9static Pulse_Sink *default_sink = NULL;
12static Ecore_Event_Handler *ph = NULL; 10static Eina_List *handlers = NULL;
13static Ecore_Event_Handler *pch = NULL;
14static Ecore_Event_Handler *pdh = NULL;
15static Eina_List *sinks = NULL; 11static Eina_List *sinks = NULL;
16static Eina_List *sources = NULL; 12static Eina_List *sources = NULL;
17static Ecore_Poller *pulse_poller = NULL;
18static Eina_Hash *queue_states = NULL; 13static Eina_Hash *queue_states = NULL;
19static const char *_name = NULL; 14static const char *_name = NULL;
20 15
@@ -26,59 +21,13 @@ static unsigned int disc_count = 0;
26static unsigned int update_count = 0; 21static unsigned int update_count = 0;
27static Ecore_Timer *update_timer = NULL; 22static Ecore_Timer *update_timer = NULL;
28 23
29static Eina_Bool
30_pulse_poller_cb(void *d __UNUSED__)
31{
32 char buf[4096];
33
34 snprintf(buf, sizeof(buf), "%s/.pulse-cookie", getenv("HOME"));
35 if (ecore_file_exists(buf))
36 return !e_mixer_pulse_init();
37 return EINA_TRUE;
38}
39
40static void
41_dbus_poll(void *data EINA_UNUSED, const Eldbus_Message *msg)
42{
43 const char *name, *from, *to;
44 if (eldbus_message_arguments_get(msg, "sss", &name, &from, &to))
45 {
46 if (!strcmp(name, PULSE_BUS))
47 e_mixer_pulse_init();
48 }
49
50 if (dbus_handler)
51 {
52 eldbus_signal_handler_del(dbus_handler);
53 dbus_handler = NULL;
54 }
55 if (dbus)
56 {
57 eldbus_connection_unref(dbus);
58 dbus = NULL;
59 eldbus_shutdown();
60 }
61}
62 24
63static void 25static Eina_Bool
64_dbus_test(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) 26_pulse_started(void *data EINA_UNUSED, int type EINA_UNUSED, E_Exec_Instance *inst)
65{ 27{
66 if (eldbus_message_error_get(msg, NULL, NULL)) 28 if (inst != pulse_inst) return ECORE_CALLBACK_RENEW;
67 { 29 e_mixer_pulse_init();
68 if (dbus_handler) 30 return ECORE_CALLBACK_DONE;
69 {
70 eldbus_signal_handler_del(dbus_handler);
71 dbus_handler = NULL;
72 }
73 if (dbus)
74 {
75 eldbus_connection_unref(dbus);
76 dbus = NULL;
77 eldbus_shutdown();
78 }
79 e_mod_mixer_pulse_ready(EINA_FALSE);
80 return;
81 }
82} 31}
83 32
84static void 33static void
@@ -339,52 +288,22 @@ e_mixer_pulse_init(void)
339{ 288{
340 pulse_init(); 289 pulse_init();
341 conn = pulse_new(); 290 conn = pulse_new();
342 if (dbus) goto error;
343 if ((!conn) || (!pulse_connect(conn))) 291 if ((!conn) || (!pulse_connect(conn)))
344 { 292 {
345 Eldbus_Message *msg; 293 pulse_inst = e_exec(NULL, NULL, "pulseaudio -D", NULL, NULL);
346 double interval; 294 if (!pulse_inst) return EINA_FALSE;
347 295
348 eldbus_init(); 296 E_LIST_HANDLER_APPEND(handlers, E_EVENT_EXEC_NEW, (Ecore_Event_Handler_Cb)_pulse_started, NULL);
349 dbus = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION);
350
351 if (!dbus)
352 {
353 eldbus_shutdown();
354 return EINA_FALSE;
355 }
356
357 if (!pulse_poller)
358 {
359 interval = ecore_poller_poll_interval_get(ECORE_POLLER_CORE);
360 /* polling every 5 seconds or so I guess ? */
361 pulse_poller = ecore_poller_add(ECORE_POLLER_CORE, 5.0 / interval,
362 _pulse_poller_cb, NULL);
363 }
364 if (!dbus_handler)
365 dbus_handler = eldbus_signal_handler_add(dbus, ELDBUS_FDO_BUS,
366 ELDBUS_FDO_PATH,
367 ELDBUS_FDO_INTERFACE,
368 "NameOwnerChanged", _dbus_poll, NULL);
369
370 msg = eldbus_message_method_call_new(PULSE_BUS, PULSE_PATH, PULSE_INTERFACE, "suuuuuup");
371 eldbus_connection_send(dbus, msg, _dbus_test, NULL, -1); /* test for not running pulse */
372 pulse_free(conn); 297 pulse_free(conn);
373 conn = NULL; 298 conn = NULL;
374 pulse_shutdown(); 299 pulse_shutdown();
375 return EINA_TRUE; 300 return EINA_TRUE;
376 } 301 }
377 pulse_poller = NULL; 302 E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_CONNECTED, (Ecore_Event_Handler_Cb)_pulse_connected, conn);
378 ph = ecore_event_handler_add(PULSE_EVENT_CONNECTED, (Ecore_Event_Handler_Cb)_pulse_connected, conn); 303 E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_CHANGE, (Ecore_Event_Handler_Cb)_pulse_update, conn);
379 pch = ecore_event_handler_add(PULSE_EVENT_CHANGE, (Ecore_Event_Handler_Cb)_pulse_update, conn); 304 E_LIST_HANDLER_APPEND(handlers, PULSE_EVENT_DISCONNECTED, (Ecore_Event_Handler_Cb)_pulse_disconnected, conn);
380 pdh = ecore_event_handler_add(PULSE_EVENT_DISCONNECTED, (Ecore_Event_Handler_Cb)_pulse_disconnected, conn);
381 if (!_name) _name = eina_stringshare_add("Output"); 305 if (!_name) _name = eina_stringshare_add("Output");
382 return EINA_TRUE; 306 return EINA_TRUE;
383error:
384 pulse_free(conn);
385 conn = NULL;
386 pulse_shutdown();
387 return EINA_FALSE;
388} 307}
389 308
390void 309void
@@ -404,12 +323,7 @@ e_mixer_pulse_shutdown(void)
404 323
405 pulse_free(conn); 324 pulse_free(conn);
406 conn = NULL; 325 conn = NULL;
407 if (ph) ecore_event_handler_del(ph); 326 E_FREE_LIST(handlers, ecore_event_handler_del);
408 ph = NULL;
409 if (pch) ecore_event_handler_del(pch);
410 pch = NULL;
411 if (pdh) ecore_event_handler_del(pdh);
412 pdh = NULL;
413 if (queue_states) eina_hash_free(queue_states); 327 if (queue_states) eina_hash_free(queue_states);
414 queue_states = NULL; 328 queue_states = NULL;
415 if (dbus_handler) 329 if (dbus_handler)