summaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-05-17 01:08:22 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-05-17 11:01:25 -0300
commitf5a44fe80fe0ae34fe9ec9587fea7ead67defd1b (patch)
treeeafc69d895746522f07ec9db94be73533261526a /src/bin
parente1c2ae60f826e8d5d0245029345c717ac8b9d884 (diff)
Checking when pulseadio dies
Informing the app/module that pulseaudio dies when then handling this situation properly avoiding crashes (in case of the module, avoiding crash the entire enlightenment).
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/playbacks_view.c23
-rw-r--r--src/bin/sinks_view.c20
2 files changed, 43 insertions, 0 deletions
diff --git a/src/bin/playbacks_view.c b/src/bin/playbacks_view.c
index 80d6a33..9cdad99 100644
--- a/src/bin/playbacks_view.c
+++ b/src/bin/playbacks_view.c
@@ -19,6 +19,7 @@ struct Playbacks_View
19 Eina_List *inputs; 19 Eina_List *inputs;
20 Eina_List *sinks; 20 Eina_List *sinks;
21 21
22 Ecore_Event_Handler *disconnected;
22 Ecore_Event_Handler *sink_input_added; 23 Ecore_Event_Handler *sink_input_added;
23 Ecore_Event_Handler *sink_input_changed; 24 Ecore_Event_Handler *sink_input_changed;
24 Ecore_Event_Handler *sink_input_removed; 25 Ecore_Event_Handler *sink_input_removed;
@@ -41,6 +42,25 @@ struct Sink_Input
41 Elm_Object_Item *item; 42 Elm_Object_Item *item;
42}; 43};
43 44
45 static Eina_Bool
46_disconnected_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED)
47{
48 struct Playbacks_View *pv = data;
49 struct Sink_Input *si;
50 struct Sink *sink;
51
52 EINA_LIST_FREE(pv->inputs, si)
53 elm_object_item_del(si->item);
54
55 EINA_LIST_FREE(pv->sinks, sink)
56 {
57 eina_stringshare_del(sink->name);
58 free(sink);
59 }
60
61 return ECORE_CALLBACK_PASS_ON;
62}
63
44static Eina_Bool 64static Eina_Bool
45_sink_input_add_cb(void *data, int type EINA_UNUSED, 65_sink_input_add_cb(void *data, int type EINA_UNUSED,
46 void *info) 66 void *info)
@@ -184,6 +204,7 @@ _del_cb(void *data,
184 pv->_handle = NULL; \ 204 pv->_handle = NULL; \
185 } 205 }
186 206
207 ECORE_EVENT_HANDLER_DEL(disconnected)
187 ECORE_EVENT_HANDLER_DEL(sink_input_added) 208 ECORE_EVENT_HANDLER_DEL(sink_input_added)
188 ECORE_EVENT_HANDLER_DEL(sink_input_changed) 209 ECORE_EVENT_HANDLER_DEL(sink_input_changed)
189 ECORE_EVENT_HANDLER_DEL(sink_input_removed) 210 ECORE_EVENT_HANDLER_DEL(sink_input_removed)
@@ -334,6 +355,8 @@ playbacks_view_add(Evas_Object *parent)
334 pv->genlist = elm_genlist_add(layout); 355 pv->genlist = elm_genlist_add(layout);
335 EINA_SAFETY_ON_NULL_GOTO(pv->genlist, err_genlist); 356 EINA_SAFETY_ON_NULL_GOTO(pv->genlist, err_genlist);
336 357
358 pv->disconnected = ecore_event_handler_add(DISCONNECTED,
359 _disconnected_cb, pv);
337 pv->sink_input_added = ecore_event_handler_add(SINK_INPUT_ADDED, 360 pv->sink_input_added = ecore_event_handler_add(SINK_INPUT_ADDED,
338 _sink_input_add_cb, pv); 361 _sink_input_add_cb, pv);
339 pv->sink_input_added = ecore_event_handler_add(SINK_INPUT_CHANGED, 362 pv->sink_input_added = ecore_event_handler_add(SINK_INPUT_CHANGED,
diff --git a/src/bin/sinks_view.c b/src/bin/sinks_view.c
index b8514fd..55003ee 100644
--- a/src/bin/sinks_view.c
+++ b/src/bin/sinks_view.c
@@ -29,6 +29,7 @@ struct Sinks_View
29 Elm_Genlist_Item_Class *itc; 29 Elm_Genlist_Item_Class *itc;
30 30
31 Eina_List *sinks; 31 Eina_List *sinks;
32 Ecore_Event_Handler *disconnected;
32 Ecore_Event_Handler *sink_added; 33 Ecore_Event_Handler *sink_added;
33 Ecore_Event_Handler *sink_changed; 34 Ecore_Event_Handler *sink_changed;
34 Ecore_Event_Handler *sink_removed; 35 Ecore_Event_Handler *sink_removed;
@@ -36,6 +37,18 @@ struct Sinks_View
36 37
37 38
38static Eina_Bool 39static Eina_Bool
40_disconnected_cb(void *data, int type EINA_UNUSED, void *info EINA_UNUSED)
41{
42 struct Sinks_View *sv = data;
43 struct Sink *sink;
44
45 EINA_LIST_FREE(sv->sinks, sink)
46 elm_object_item_del(sink->item);
47
48 return ECORE_CALLBACK_PASS_ON;
49}
50
51static Eina_Bool
39_sink_add_cb(void *data, int type EINA_UNUSED, void *info) 52_sink_add_cb(void *data, int type EINA_UNUSED, void *info)
40{ 53{
41 struct Sinks_View *sv = data; 54 struct Sinks_View *sv = data;
@@ -143,6 +156,11 @@ _del_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *o EINA_UNUSED,
143 ecore_event_handler_del(sv->sink_removed); 156 ecore_event_handler_del(sv->sink_removed);
144 sv->sink_removed = NULL; 157 sv->sink_removed = NULL;
145 } 158 }
159 if (sv->disconnected)
160 {
161 ecore_event_handler_del(sv->disconnected);
162 sv->disconnected = NULL;
163 }
146} 164}
147 165
148static char * 166static char *
@@ -289,6 +307,8 @@ sinks_view_add(Evas_Object *parent)
289 sv->genlist = elm_genlist_add(layout); 307 sv->genlist = elm_genlist_add(layout);
290 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist); 308 EINA_SAFETY_ON_NULL_GOTO(sv->genlist, err_genlist);
291 309
310 sv->disconnected = ecore_event_handler_add(DISCONNECTED,
311 _disconnected_cb, sv);
292 sv->sink_added = ecore_event_handler_add(SINK_ADDED, _sink_add_cb, sv); 312 sv->sink_added = ecore_event_handler_add(SINK_ADDED, _sink_add_cb, sv);
293 sv->sink_added = ecore_event_handler_add(SINK_CHANGED, _sink_changed_cb, sv); 313 sv->sink_added = ecore_event_handler_add(SINK_CHANGED, _sink_changed_cb, sv);
294 sv->sink_removed = ecore_event_handler_add(SINK_REMOVED, 314 sv->sink_removed = ecore_event_handler_add(SINK_REMOVED,