summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-09-07 11:02:02 +0200
committerMarcel Hollerbach <marcel-hollerbach@t-online.de>2016-09-07 11:05:11 +0200
commit1da2bbcd9c8504925b4b585753d4d7061ba073c6 (patch)
tree2f4101ac57b1e893796270e3b2ddfe88cbf5c836
parent5da62d9adf9c2ff6672ffbe6765e53a9937e0e24 (diff)
mixer: introduce Barrier checks
in this barrier checks the module checks that the user is explicit going over the value of 100%
-rw-r--r--src/modules/mixer/e_mod_main.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c
index fd3e8082f..bff3be4b8 100644
--- a/src/modules/mixer/e_mod_main.c
+++ b/src/modules/mixer/e_mod_main.c
@@ -6,6 +6,12 @@
6 6
7#define VOLUME_STEP 5 7#define VOLUME_STEP 5
8 8
9#define BARRIER_CHECK(old_val, new_val) \
10 (old_val > EMIX_VOLUME_BARRIER - 20) && \
11 (old_val <= EMIX_VOLUME_BARRIER) && \
12 (new_val > EMIX_VOLUME_BARRIER) && \
13 (new_val < EMIX_VOLUME_BARRIER + 20)
14
9int _e_emix_log_domain; 15int _e_emix_log_domain;
10static Eina_Bool init; 16static Eina_Bool init;
11 17
@@ -175,6 +181,10 @@ _volume_increase_cb(E_Object *obj EINA_UNUSED, const char *params EINA_UNUSED)
175 181
176 EINA_SAFETY_ON_NULL_RETURN(mixer_context->sink_default); 182 EINA_SAFETY_ON_NULL_RETURN(mixer_context->sink_default);
177 Emix_Sink *s = (Emix_Sink *)mixer_context->sink_default; 183 Emix_Sink *s = (Emix_Sink *)mixer_context->sink_default;
184
185 if (BARRIER_CHECK(s->volume.volumes[0], s->volume.volumes[0] + VOLUME_STEP))
186 return;
187
178 volume.channel_count = s->volume.channel_count; 188 volume.channel_count = s->volume.channel_count;
179 volume.volumes = calloc(s->volume.channel_count, sizeof(int)); 189 volume.volumes = calloc(s->volume.channel_count, sizeof(int));
180 for (i = 0; i < volume.channel_count; i++) 190 for (i = 0; i < volume.channel_count; i++)
@@ -360,12 +370,19 @@ _slider_changed_cb(void *data EINA_UNUSED, Evas_Object *obj,
360 int val; 370 int val;
361 Emix_Volume v; 371 Emix_Volume v;
362 unsigned int i; 372 unsigned int i;
373 int pval;
363 374
364 EINA_SAFETY_ON_NULL_RETURN(mixer_context->sink_default); 375 EINA_SAFETY_ON_NULL_RETURN(mixer_context->sink_default);
365 Emix_Sink *s = (Emix_Sink *)mixer_context->sink_default; 376 Emix_Sink *s = (Emix_Sink *)mixer_context->sink_default;
377
378 pval = s->volume.volumes[0];
379
366 val = (int)elm_slider_value_get(obj); 380 val = (int)elm_slider_value_get(obj);
367 v.volumes = calloc(s->volume.channel_count, sizeof(int)); 381 v.volumes = calloc(s->volume.channel_count, sizeof(int));
368 v.channel_count = s->volume.channel_count; 382 v.channel_count = s->volume.channel_count;
383 if (BARRIER_CHECK(pval, val))
384 val = 100;
385
369 for (i = 0; i < s->volume.channel_count; i++) v.volumes[i] = val; 386 for (i = 0; i < s->volume.channel_count; i++) v.volumes[i] = val;
370 emix_sink_volume_set(s, v); 387 emix_sink_volume_set(s, v);
371 elm_slider_value_set(obj, val); 388 elm_slider_value_set(obj, val);