summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Bouchaud <michael.bouchaud@ext.actia.fr>2017-02-20 00:45:41 +0100
committerMichaƫl Bouchaud (yoz) <yoz@efl.so>2017-02-20 02:21:14 +0100
commit0a739058953f4569e082479ad9c8036daf9a9586 (patch)
treeb7bd373c90f3a5988f73d39ba65942400f7713e1
parent939ac0b93d580bd6bdd12eb6b29871abd91d5061 (diff)
e_client_volume: add E_EVENT_CLIENT_VOLUME_SINK handler
This commit introduce 3 new handlers to e_client_volume API. These allow to catch event about sink add, del and update
-rw-r--r--src/bin/e_client_volume.c39
-rw-r--r--src/bin/e_client_volume.h10
-rw-r--r--src/modules/mixer/e_mod_main.c13
3 files changed, 49 insertions, 13 deletions
diff --git a/src/bin/e_client_volume.c b/src/bin/e_client_volume.c
index a53082d42..bdc54e392 100644
--- a/src/bin/e_client_volume.c
+++ b/src/bin/e_client_volume.c
@@ -3,6 +3,9 @@
3E_API int E_EVENT_CLIENT_VOLUME = -1; 3E_API int E_EVENT_CLIENT_VOLUME = -1;
4E_API int E_EVENT_CLIENT_MUTE = -1; 4E_API int E_EVENT_CLIENT_MUTE = -1;
5E_API int E_EVENT_CLIENT_UNMUTE = -1; 5E_API int E_EVENT_CLIENT_UNMUTE = -1;
6E_API int E_EVENT_CLIENT_VOLUME_SINK_ADD = -1;
7E_API int E_EVENT_CLIENT_VOLUME_SINK_DEL = -1;
8E_API int E_EVENT_CLIENT_VOLUME_SINK_CHANGED = -1;
6 9
7static void _e_client_volume_event_simple_free(void *d, E_Event_Client *ev); 10static void _e_client_volume_event_simple_free(void *d, E_Event_Client *ev);
8static void _e_client_volume_event_simple(E_Client *ec, int type); 11static void _e_client_volume_event_simple(E_Client *ec, int type);
@@ -33,6 +36,28 @@ _e_client_volume_event_simple(E_Client *ec, int type)
33} 36}
34 37
35static void 38static void
39_e_client_volume_sink_event_simple_free(void *d EINA_UNUSED, E_Event_Client_Volume_Sink *ev)
40{
41 UNREFD(ev->ec, 3);
42 e_object_unref(E_OBJECT(ev->ec));
43 free(ev);
44}
45
46static void
47_e_client_volume_sink_event_simple(E_Client *ec, E_Client_Volume_Sink *sink, int type)
48{
49 E_Event_Client_Volume_Sink *ev;
50
51 ev = E_NEW(E_Event_Client_Volume_Sink, 1);
52 ev->ec = ec;
53 ev->sink = sink;
54 REFD(ec, 3);
55 e_object_ref(E_OBJECT(ec));
56 ecore_event_add(type, ev,
57 (Ecore_End_Cb)_e_client_volume_sink_event_simple_free, NULL);
58}
59
60static void
36_e_client_volume_object_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) 61_e_client_volume_object_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
37{ 62{
38 E_Client *ec; 63 E_Client *ec;
@@ -107,6 +132,9 @@ e_client_volume_init(void)
107 E_EVENT_CLIENT_VOLUME = ecore_event_type_new(); 132 E_EVENT_CLIENT_VOLUME = ecore_event_type_new();
108 E_EVENT_CLIENT_MUTE = ecore_event_type_new(); 133 E_EVENT_CLIENT_MUTE = ecore_event_type_new();
109 E_EVENT_CLIENT_UNMUTE = ecore_event_type_new(); 134 E_EVENT_CLIENT_UNMUTE = ecore_event_type_new();
135 E_EVENT_CLIENT_VOLUME_SINK_ADD = ecore_event_type_new();
136 E_EVENT_CLIENT_VOLUME_SINK_DEL = ecore_event_type_new();
137 E_EVENT_CLIENT_VOLUME_SINK_CHANGED = ecore_event_type_new();
110 138
111 return EINA_TRUE; 139 return EINA_TRUE;
112} 140}
@@ -141,6 +169,8 @@ e_client_volume_sink_del(E_Client_Volume_Sink *sink)
141 { 169 {
142 ec->sinks = eina_list_remove(ec->sinks, sink); 170 ec->sinks = eina_list_remove(ec->sinks, sink);
143 e_comp_object_frame_volume_update(ec->frame); 171 e_comp_object_frame_volume_update(ec->frame);
172 _e_client_volume_sink_event_simple(ec, sink,
173 E_EVENT_CLIENT_VOLUME_SINK_DEL);
144 } 174 }
145 free(sink); 175 free(sink);
146} 176}
@@ -222,6 +252,8 @@ e_client_volume_sink_append(E_Client *ec, E_Client_Volume_Sink *sink)
222 ec->volume_control_enabled = EINA_TRUE; 252 ec->volume_control_enabled = EINA_TRUE;
223 } 253 }
224 e_comp_object_frame_volume_update(ec->frame); 254 e_comp_object_frame_volume_update(ec->frame);
255 _e_client_volume_sink_event_simple(ec, sink,
256 E_EVENT_CLIENT_VOLUME_SINK_ADD);
225} 257}
226 258
227E_API void 259E_API void
@@ -231,6 +263,8 @@ e_client_volume_sink_remove(E_Client *ec, E_Client_Volume_Sink *sink)
231 ec->sinks = eina_list_remove(ec->sinks, sink); 263 ec->sinks = eina_list_remove(ec->sinks, sink);
232 sink->clients = eina_list_remove(sink->clients, ec); 264 sink->clients = eina_list_remove(sink->clients, ec);
233 e_comp_object_frame_volume_update(ec->frame); 265 e_comp_object_frame_volume_update(ec->frame);
266 _e_client_volume_sink_event_simple(ec, sink,
267 E_EVENT_CLIENT_VOLUME_SINK_DEL);
234} 268}
235 269
236E_API void 270E_API void
@@ -246,7 +280,10 @@ e_client_volume_sink_update(E_Client_Volume_Sink *sink)
246 e_client_volume_sink_get(sink, &volume, &mute); 280 e_client_volume_sink_get(sink, &volume, &mute);
247 EINA_LIST_FOREACH(sink->clients, l, ec) 281 EINA_LIST_FOREACH(sink->clients, l, ec)
248 { 282 {
249 e_client_volume_display_set(ec, volume, mute); 283 if (eina_list_count(ec->sinks) == 1)
284 e_client_volume_display_set(ec, volume, mute);
285 _e_client_volume_sink_event_simple(ec, sink,
286 E_EVENT_CLIENT_VOLUME_SINK_CHANGED);
250 } 287 }
251} 288}
252 289
diff --git a/src/bin/e_client_volume.h b/src/bin/e_client_volume.h
index 44de594f8..68e172b67 100644
--- a/src/bin/e_client_volume.h
+++ b/src/bin/e_client_volume.h
@@ -2,6 +2,7 @@
2#define E_CLIENT_VOLUME_H_ 2#define E_CLIENT_VOLUME_H_
3 3
4typedef struct _E_Client_Volume_Sink E_Client_Volume_Sink; 4typedef struct _E_Client_Volume_Sink E_Client_Volume_Sink;
5typedef struct _E_Event_Client_Volume_Sink E_Event_Client_Volume_Sink;
5 6
6typedef void (*E_Client_Volume_Sink_Get)(int *volume, Eina_Bool *mute, void *data); 7typedef void (*E_Client_Volume_Sink_Get)(int *volume, Eina_Bool *mute, void *data);
7typedef void (*E_Client_Volume_Sink_Set)(int volume, Eina_Bool mute, void *data); 8typedef void (*E_Client_Volume_Sink_Set)(int volume, Eina_Bool mute, void *data);
@@ -12,6 +13,9 @@ typedef const char *(*E_Client_Volume_Sink_Name_Get)(void *data);
12E_API extern int E_EVENT_CLIENT_VOLUME; 13E_API extern int E_EVENT_CLIENT_VOLUME;
13E_API extern int E_EVENT_CLIENT_MUTE; 14E_API extern int E_EVENT_CLIENT_MUTE;
14E_API extern int E_EVENT_CLIENT_UNMUTE; 15E_API extern int E_EVENT_CLIENT_UNMUTE;
16E_API extern int E_EVENT_CLIENT_VOLUME_SINK_ADD;
17E_API extern int E_EVENT_CLIENT_VOLUME_SINK_DEL;
18E_API extern int E_EVENT_CLIENT_VOLUME_SINK_CHANGED;
15 19
16struct _E_Client_Volume_Sink 20struct _E_Client_Volume_Sink
17{ 21{
@@ -24,6 +28,12 @@ struct _E_Client_Volume_Sink
24 Eina_List *clients; 28 Eina_List *clients;
25}; 29};
26 30
31struct _E_Event_Client_Volume_Sink
32{
33 E_Client *ec;
34 E_Client_Volume_Sink *sink;
35};
36
27 37
28EINTERN int e_client_volume_init(void); 38EINTERN int e_client_volume_init(void);
29EINTERN void e_client_volume_shutdown(void); 39EINTERN void e_client_volume_shutdown(void);
diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c
index 5c1880d7f..aa9b6194c 100644
--- a/src/modules/mixer/e_mod_main.c
+++ b/src/modules/mixer/e_mod_main.c
@@ -964,18 +964,7 @@ _sink_input_event(int type, Emix_Sink_Input *input)
964 { 964 {
965 if (sink->data == input) 965 if (sink->data == input)
966 { 966 {
967 Eina_Bool update = EINA_TRUE; 967 e_client_volume_sink_update(sink);
968 EINA_LIST_FOREACH(sink->clients, l, ec)
969 {
970 if (eina_list_count(ec->sinks) > 1)
971 {
972 update = EINA_FALSE;
973 break;
974 }
975 }
976 if (update)
977 e_client_volume_sink_update(sink);
978
979 } 968 }
980 } 969 }
981 break; 970 break;