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
devs/bu5hm4n/luncher_verbose
Michael Bouchaud 6 years ago committed by Michaël Bouchaud (yoz)
parent 939ac0b93d
commit 0a73905895
  1. 39
      src/bin/e_client_volume.c
  2. 10
      src/bin/e_client_volume.h
  3. 13
      src/modules/mixer/e_mod_main.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);
@ -32,6 +35,28 @@ _e_client_volume_event_simple(E_Client *ec, int type)
(Ecore_End_Cb)_e_client_volume_event_simple_free, NULL);
}
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)
{
@ -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);
}
}

@ -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);

@ -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;

Loading…
Cancel
Save