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)
downloadenlightenment-0a739058953f4569e082479ad9c8036daf9a9586.tar.gz
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 a53082d42b..bdc54e3924 100644
--- a/src/bin/e_client_volume.c
+++ b/src/bin/e_client_volume.c
@@ -3,6 +3,9 @@
E_API int E_EVENT_CLIENT_VOLUME = -1;
E_API int E_EVENT_CLIENT_MUTE = -1;
E_API int E_EVENT_CLIENT_UNMUTE = -1;
+E_API int E_EVENT_CLIENT_VOLUME_SINK_ADD = -1;
+E_API int E_EVENT_CLIENT_VOLUME_SINK_DEL = -1;
+E_API int E_EVENT_CLIENT_VOLUME_SINK_CHANGED = -1;
static void _e_client_volume_event_simple_free(void *d, E_Event_Client *ev);
static 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)
}
static void
+_e_client_volume_sink_event_simple_free(void *d EINA_UNUSED, E_Event_Client_Volume_Sink *ev)
+{
+ UNREFD(ev->ec, 3);
+ e_object_unref(E_OBJECT(ev->ec));
+ free(ev);
+}
+
+static void
+_e_client_volume_sink_event_simple(E_Client *ec, E_Client_Volume_Sink *sink, int type)
+{
+ E_Event_Client_Volume_Sink *ev;
+
+ ev = E_NEW(E_Event_Client_Volume_Sink, 1);
+ ev->ec = ec;
+ ev->sink = sink;
+ REFD(ec, 3);
+ e_object_ref(E_OBJECT(ec));
+ ecore_event_add(type, ev,
+ (Ecore_End_Cb)_e_client_volume_sink_event_simple_free, NULL);
+}
+
+static void
_e_client_volume_object_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
{
E_Client *ec;
@@ -107,6 +132,9 @@ e_client_volume_init(void)
E_EVENT_CLIENT_VOLUME = ecore_event_type_new();
E_EVENT_CLIENT_MUTE = ecore_event_type_new();
E_EVENT_CLIENT_UNMUTE = ecore_event_type_new();
+ E_EVENT_CLIENT_VOLUME_SINK_ADD = ecore_event_type_new();
+ E_EVENT_CLIENT_VOLUME_SINK_DEL = ecore_event_type_new();
+ E_EVENT_CLIENT_VOLUME_SINK_CHANGED = ecore_event_type_new();
return EINA_TRUE;
}
@@ -141,6 +169,8 @@ e_client_volume_sink_del(E_Client_Volume_Sink *sink)
{
ec->sinks = eina_list_remove(ec->sinks, sink);
e_comp_object_frame_volume_update(ec->frame);
+ _e_client_volume_sink_event_simple(ec, sink,
+ E_EVENT_CLIENT_VOLUME_SINK_DEL);
}
free(sink);
}
@@ -222,6 +252,8 @@ e_client_volume_sink_append(E_Client *ec, E_Client_Volume_Sink *sink)
ec->volume_control_enabled = EINA_TRUE;
}
e_comp_object_frame_volume_update(ec->frame);
+ _e_client_volume_sink_event_simple(ec, sink,
+ E_EVENT_CLIENT_VOLUME_SINK_ADD);
}
E_API void
@@ -231,6 +263,8 @@ e_client_volume_sink_remove(E_Client *ec, E_Client_Volume_Sink *sink)
ec->sinks = eina_list_remove(ec->sinks, sink);
sink->clients = eina_list_remove(sink->clients, ec);
e_comp_object_frame_volume_update(ec->frame);
+ _e_client_volume_sink_event_simple(ec, sink,
+ E_EVENT_CLIENT_VOLUME_SINK_DEL);
}
E_API void
@@ -246,7 +280,10 @@ e_client_volume_sink_update(E_Client_Volume_Sink *sink)
e_client_volume_sink_get(sink, &volume, &mute);
EINA_LIST_FOREACH(sink->clients, l, ec)
{
- e_client_volume_display_set(ec, volume, mute);
+ if (eina_list_count(ec->sinks) == 1)
+ e_client_volume_display_set(ec, volume, mute);
+ _e_client_volume_sink_event_simple(ec, sink,
+ E_EVENT_CLIENT_VOLUME_SINK_CHANGED);
}
}
diff --git a/src/bin/e_client_volume.h b/src/bin/e_client_volume.h
index 44de594f82..68e172b673 100644
--- a/src/bin/e_client_volume.h
+++ b/src/bin/e_client_volume.h
@@ -2,6 +2,7 @@
#define E_CLIENT_VOLUME_H_
typedef struct _E_Client_Volume_Sink E_Client_Volume_Sink;
+typedef struct _E_Event_Client_Volume_Sink E_Event_Client_Volume_Sink;
typedef void (*E_Client_Volume_Sink_Get)(int *volume, Eina_Bool *mute, void *data);
typedef 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);
E_API extern int E_EVENT_CLIENT_VOLUME;
E_API extern int E_EVENT_CLIENT_MUTE;
E_API extern int E_EVENT_CLIENT_UNMUTE;
+E_API extern int E_EVENT_CLIENT_VOLUME_SINK_ADD;
+E_API extern int E_EVENT_CLIENT_VOLUME_SINK_DEL;
+E_API extern int E_EVENT_CLIENT_VOLUME_SINK_CHANGED;
struct _E_Client_Volume_Sink
{
@@ -24,6 +28,12 @@ struct _E_Client_Volume_Sink
Eina_List *clients;
};
+struct _E_Event_Client_Volume_Sink
+{
+ E_Client *ec;
+ E_Client_Volume_Sink *sink;
+};
+
EINTERN int e_client_volume_init(void);
EINTERN 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 5c1880d7f5..aa9b6194c3 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)
{
if (sink->data == input)
{
- Eina_Bool update = EINA_TRUE;
- EINA_LIST_FOREACH(sink->clients, l, ec)
- {
- if (eina_list_count(ec->sinks) > 1)
- {
- update = EINA_FALSE;
- break;
- }
- }
- if (update)
- e_client_volume_sink_update(sink);
-
+ e_client_volume_sink_update(sink);
}
}
break;