summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-11 00:17:05 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-09-14 22:26:02 -0300
commit1e61ab2a9689a70ddfc6220ebe821c8604974703 (patch)
tree9f482f5348a889fad0b53f490e79ba203b3a9a12
parent25ab39d8830bfb9c60865f3c7f0b368b800c4f28 (diff)
Add volume meter functionality
-rw-r--r--data/themes/mixer.edc198
-rw-r--r--src/module/e_mod_main.c47
2 files changed, 146 insertions, 99 deletions
diff --git a/data/themes/mixer.edc b/data/themes/mixer.edc
index 75fd82b..b3c17c3 100644
--- a/data/themes/mixer.edc
+++ b/data/themes/mixer.edc
@@ -29,11 +29,10 @@ collections {
29 script { 29 script {
30 public message(Msg_Type:type, id, ...) { 30 public message(Msg_Type:type, id, ...) {
31 if ((type == MSG_INT_SET) && (id == 0)) { 31 if ((type == MSG_INT_SET) && (id == 0)) {
32 new m, l, r; 32 new m, v;
33 33
34 m = getarg(2); 34 m = getarg(2);
35 l = getarg(3); 35 v = getarg(3);
36 r = getarg(4);
37 36
38 if (m) { 37 if (m) {
39 run_program(PROGRAM:"mute"); 38 run_program(PROGRAM:"mute");
@@ -41,82 +40,84 @@ collections {
41 run_program(PROGRAM:"unmute"); 40 run_program(PROGRAM:"unmute");
42 } 41 }
43 42
44 if (l <= 0) { 43 if (v <= 0) {
45 run_program(PROGRAM:"l0-off"); 44 run_program(PROGRAM:"0-off");
46 run_program(PROGRAM:"l1-off"); 45 run_program(PROGRAM:"1-off");
47 run_program(PROGRAM:"l2-off"); 46 run_program(PROGRAM:"2-off");
48 run_program(PROGRAM:"l3-off"); 47 run_program(PROGRAM:"3-off");
49 run_program(PROGRAM:"l4-off"); 48 run_program(PROGRAM:"4-off");
50 } else if (l <= 20) { 49 } else if (v <= 20) {
51 run_program(PROGRAM:"l0-on"); 50 run_program(PROGRAM:"0-on");
52 run_program(PROGRAM:"l1-off"); 51 run_program(PROGRAM:"1-off");
53 run_program(PROGRAM:"l2-off"); 52 run_program(PROGRAM:"2-off");
54 run_program(PROGRAM:"l3-off"); 53 run_program(PROGRAM:"3-off");
55 run_program(PROGRAM:"l4-off"); 54 run_program(PROGRAM:"4-off");
56 } else if (l <= 40) { 55 } else if (v <= 40) {
57 run_program(PROGRAM:"l0-on"); 56 run_program(PROGRAM:"0-on");
58 run_program(PROGRAM:"l1-on"); 57 run_program(PROGRAM:"1-on");
59 run_program(PROGRAM:"l2-off"); 58 run_program(PROGRAM:"2-off");
60 run_program(PROGRAM:"l3-off"); 59 run_program(PROGRAM:"3-off");
61 run_program(PROGRAM:"l4-off"); 60 run_program(PROGRAM:"4-off");
62 } else if (l <= 60) { 61 } else if (v <= 60) {
63 run_program(PROGRAM:"l0-on"); 62 run_program(PROGRAM:"0-on");
64 run_program(PROGRAM:"l1-on"); 63 run_program(PROGRAM:"1-on");
65 run_program(PROGRAM:"l2-on"); 64 run_program(PROGRAM:"2-on");
66 run_program(PROGRAM:"l3-off"); 65 run_program(PROGRAM:"3-off");
67 run_program(PROGRAM:"l4-off"); 66 run_program(PROGRAM:"4-off");
68 } else if (l <= 80) { 67 } else if (v <= 80) {
69 run_program(PROGRAM:"l0-on"); 68 run_program(PROGRAM:"0-on");
70 run_program(PROGRAM:"l1-on"); 69 run_program(PROGRAM:"1-on");
71 run_program(PROGRAM:"l2-on"); 70 run_program(PROGRAM:"2-on");
72 run_program(PROGRAM:"l3-on"); 71 run_program(PROGRAM:"3-on");
73 run_program(PROGRAM:"l4-off"); 72 run_program(PROGRAM:"4-off");
74 } else { 73 } else {
75 run_program(PROGRAM:"l0-on"); 74 run_program(PROGRAM:"0-on");
76 run_program(PROGRAM:"l1-on"); 75 run_program(PROGRAM:"1-on");
77 run_program(PROGRAM:"l2-on"); 76 run_program(PROGRAM:"2-on");
78 run_program(PROGRAM:"l3-on"); 77 run_program(PROGRAM:"3-on");
79 run_program(PROGRAM:"l4-on"); 78 run_program(PROGRAM:"4-on");
80 } 79 }
81 80 } else if ((type == MSG_INT) && (id == 1)) {
82 if (r <= 0) { 81 new v;
83 run_program(PROGRAM:"r0-off"); 82 v = getarg(2);
84 run_program(PROGRAM:"r1-off"); 83 if (v <= 0) {
85 run_program(PROGRAM:"r2-off"); 84 run_program(PROGRAM:"0-off");
86 run_program(PROGRAM:"r3-off"); 85 run_program(PROGRAM:"1-off");
87 run_program(PROGRAM:"r4-off"); 86 run_program(PROGRAM:"2-off");
88 } else if (r <= 20) { 87 run_program(PROGRAM:"3-off");
89 run_program(PROGRAM:"r0-on"); 88 run_program(PROGRAM:"4-off");
90 run_program(PROGRAM:"r1-off"); 89 } else if (v <= 20) {
91 run_program(PROGRAM:"r2-off"); 90 run_program(PROGRAM:"0-on");
92 run_program(PROGRAM:"r3-off"); 91 run_program(PROGRAM:"1-off");
93 run_program(PROGRAM:"r4-off"); 92 run_program(PROGRAM:"2-off");
94 } else if (r <= 40) { 93 run_program(PROGRAM:"3-off");
95 run_program(PROGRAM:"r0-on"); 94 run_program(PROGRAM:"4-off");
96 run_program(PROGRAM:"r1-on"); 95 } else if (v <= 40) {
97 run_program(PROGRAM:"r2-off"); 96 run_program(PROGRAM:"0-on");
98 run_program(PROGRAM:"r3-off"); 97 run_program(PROGRAM:"1-on");
99 run_program(PROGRAM:"r4-off"); 98 run_program(PROGRAM:"2-off");
100 } else if (r <= 60) { 99 run_program(PROGRAM:"3-off");
101 run_program(PROGRAM:"r0-on"); 100 run_program(PROGRAM:"4-off");
102 run_program(PROGRAM:"r1-on"); 101 } else if (v <= 60) {
103 run_program(PROGRAM:"r2-on"); 102 run_program(PROGRAM:"0-on");
104 run_program(PROGRAM:"r3-off"); 103 run_program(PROGRAM:"1-on");
105 run_program(PROGRAM:"r4-off"); 104 run_program(PROGRAM:"2-on");
106 } else if (r <= 80) { 105 run_program(PROGRAM:"3-off");
107 run_program(PROGRAM:"r0-on"); 106 run_program(PROGRAM:"4-off");
108 run_program(PROGRAM:"r1-on"); 107 } else if (v <= 80) {
109 run_program(PROGRAM:"r2-on"); 108 run_program(PROGRAM:"0-on");
110 run_program(PROGRAM:"r3-on"); 109 run_program(PROGRAM:"1-on");
111 run_program(PROGRAM:"r4-off"); 110 run_program(PROGRAM:"2-on");
111 run_program(PROGRAM:"3-on");
112 run_program(PROGRAM:"4-off");
112 } else { 113 } else {
113 run_program(PROGRAM:"r0-on"); 114 run_program(PROGRAM:"0-on");
114 run_program(PROGRAM:"r1-on"); 115 run_program(PROGRAM:"1-on");
115 run_program(PROGRAM:"r2-on"); 116 run_program(PROGRAM:"2-on");
116 run_program(PROGRAM:"r3-on"); 117 run_program(PROGRAM:"3-on");
117 run_program(PROGRAM:"r4-on"); 118 run_program(PROGRAM:"4-on");
118 } 119 }
119 } 120 }
120 } 121 }
121 } 122 }
122 parts { 123 parts {
@@ -190,16 +191,16 @@ collections {
190 color: 255 255 255 255; \ 191 color: 255 255 255 255; \
191 } \ 192 } \
192 } 193 }
193 LED("r0", 99, 0, 1) 194 LED("r0", 99, 0, 1)
194 LED("r1", 99, 1, 9) 195 LED("r1", 99, 1, 9)
195 LED("r2", 99, 2, 15) 196 LED("r2", 99, 2, 15)
196 LED("r3", 99, 3, 21) 197 LED("r3", 99, 3, 21)
197 LED("r4", 99, 4, 27) 198 LED("r4", 99, 4, 27)
198 LED("l0", 61, 0, 1) 199 LED("l0", 61, 0, 1)
199 LED("l1", 61, -1, 9) 200 LED("l1", 61, -1, 9)
200 LED("l2", 61, -2, 15) 201 LED("l2", 61, -2, 15)
201 LED("l3", 61, -3, 21) 202 LED("l3", 61, -3, 21)
202 LED("l4", 61, -4, 27) 203 LED("l4", 61, -4, 27)
203#undef LED 204#undef LED
204 part { name: "over"; type: RECT; 205 part { name: "over"; type: RECT;
205 description { state: "default" 0.0; 206 description { state: "default" 0.0;
@@ -221,24 +222,23 @@ collections {
221#define PROG(_NAME) \ 222#define PROG(_NAME) \
222 program { name: _NAME"-on"; \ 223 program { name: _NAME"-on"; \
223 action: STATE_SET "active" 0.0; \ 224 action: STATE_SET "active" 0.0; \
224 target: _NAME; \ 225 target: "r"_NAME; \
225 target: _NAME"g"; \ 226 target: "l"_NAME; \
227 target: "r"_NAME"g"; \
228 target: "l"_NAME"g"; \
226 } \ 229 } \
227 program { name: _NAME"-off"; \ 230 program { name: _NAME"-off"; \
228 action: STATE_SET "default" 0.0; \ 231 action: STATE_SET "default" 0.0; \
229 target: _NAME; \ 232 target: "r"_NAME; \
230 target: _NAME"g"; \ 233 target: "l"_NAME; \
234 target: "r"_NAME"g"; \
235 target: "l"_NAME"g"; \
231 } 236 }
232 PROG("r0") 237 PROG("0")
233 PROG("r1") 238 PROG("1")
234 PROG("r2") 239 PROG("2")
235 PROG("r3") 240 PROG("3")
236 PROG("r4") 241 PROG("4")
237 PROG("l0")
238 PROG("l1")
239 PROG("l2")
240 PROG("l3")
241 PROG("l4")
242#undef PROG 242#undef PROG
243 } 243 }
244 } 244 }
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index 5512404..8ff5238 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -55,6 +55,11 @@ struct _Context
55 Eina_List *instances; 55 Eina_List *instances;
56 E_Menu *menu; 56 E_Menu *menu;
57 unsigned int notification_id; 57 unsigned int notification_id;
58 struct {
59 int value;
60 Emix_Sink *sink;
61 Ecore_Timer *timer;
62 } meter;
58 63
59 struct { 64 struct {
60 E_Action *incr; 65 E_Action *incr;
@@ -131,6 +136,23 @@ _mixer_popup_update(Instance *inst, int mute, int vol)
131 136
132static void _popup_del(Instance *inst); 137static void _popup_del(Instance *inst);
133 138
139static Eina_Bool
140_mixer_gadget_meter_update(void *data EINA_UNUSED)
141{
142 Edje_Message_Int msg;
143 Instance *inst;
144 Eina_List *l;
145
146 EINA_LIST_FOREACH(mixer_context->instances, l, inst)
147 {
148 msg.val = mixer_context->meter.value;
149 if (mixer_context->sink_default == mixer_context->meter.sink)
150 edje_object_message_send(inst->gadget, EDJE_MESSAGE_INT, 1, &msg);
151 }
152
153 return ECORE_CALLBACK_RENEW;
154}
155
134static void 156static void
135_mixer_gadget_update(void) 157_mixer_gadget_update(void)
136{ 158{
@@ -697,6 +719,29 @@ _backend_changed(const char *backend, void *data EINA_UNUSED)
697 ERR("Could not load backend: %s", backend); 719 ERR("Could not load backend: %s", backend);
698} 720}
699 721
722static void
723_volume_meter_cb(Emix_Sink *sink, double value, void *data EINA_UNUSED)
724{
725 mixer_context->meter.sink = sink;
726 mixer_context->meter.value = (int) (value * 100);
727
728 if (value == -1)
729 {
730 if (mixer_context->meter.timer)
731 {
732 ecore_timer_del(mixer_context->meter.timer);
733 mixer_context->meter.timer = NULL;
734 }
735 }
736 else
737 {
738 if (!mixer_context->meter.timer)
739 mixer_context->meter.timer = ecore_timer_add(0.2,
740 _mixer_gadget_meter_update,
741 NULL);
742 }
743}
744
700EAPI void * 745EAPI void *
701e_modapi_init(E_Module *m) 746e_modapi_init(E_Module *m)
702{ 747{
@@ -715,6 +760,8 @@ e_modapi_init(E_Module *m)
715 if (emix_backend_set(backend) == EINA_FALSE) 760 if (emix_backend_set(backend) == EINA_FALSE)
716 goto err; 761 goto err;
717 762
763 emix_volume_meter_callback_set(_volume_meter_cb, NULL);
764
718 if (!mixer_context) 765 if (!mixer_context)
719 { 766 {
720 mixer_context = E_NEW(Context, 1); 767 mixer_context = E_NEW(Context, 1);