summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-10-20 23:59:34 -0200
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-10-20 23:59:34 -0200
commitd25435a066491ce2dd4d740313af3b4db817e450 (patch)
tree57b833d03a1baa21a635ec6cb17ccce879c8944f
parent94970e9e41529f5e0c78d108b7c319946e31e610 (diff)
module: Add volume meter option
-rw-r--r--src/lib/backends/pulseaudio/pulse.c7
-rw-r--r--src/module/e_mod_config.c32
-rw-r--r--src/module/e_mod_config.h5
-rw-r--r--src/module/e_mod_main.c15
4 files changed, 48 insertions, 11 deletions
diff --git a/src/lib/backends/pulseaudio/pulse.c b/src/lib/backends/pulseaudio/pulse.c
index 50b7e8f..248d978 100644
--- a/src/lib/backends/pulseaudio/pulse.c
+++ b/src/lib/backends/pulseaudio/pulse.c
@@ -430,8 +430,11 @@ _sink_input_cb(pa_context *c EINA_UNUSED, const pa_sink_input_info *info,
430 input->icon = eina_stringshare_add(_icon_from_properties(info->proplist)); 430 input->icon = eina_stringshare_add(_icon_from_properties(info->proplist));
431 ctx->inputs = eina_list_append(ctx->inputs, input); 431 ctx->inputs = eina_list_append(ctx->inputs, input);
432 432
433 if (pa_context_get_server_protocol_version(ctx->context) >= 13) 433 if (pa_context_get_server_protocol_version(ctx->context) >= 13 &&
434 _create_sink_monitor(input); 434 ctx->meter_cb)
435 {
436 _create_sink_monitor(input);
437 }
435 438
436 if (ctx->sink_input_cb) 439 if (ctx->sink_input_cb)
437 ctx->sink_input_cb((Emix_Sink_Input *)input, EMIX_EVENT_ADDED); 440 ctx->sink_input_cb((Emix_Sink_Input *)input, EMIX_EVENT_ADDED);
diff --git a/src/module/e_mod_config.c b/src/module/e_mod_config.c
index ac27b04..f723e89 100644
--- a/src/module/e_mod_config.c
+++ b/src/module/e_mod_config.c
@@ -1,15 +1,18 @@
1#include "e_mod_config.h"
2#include <emix.h>
3#include "e.h" 1#include "e.h"
2#include "e_mod_config.h"
4#include "e_mod_main.h" 3#include "e_mod_main.h"
5 4
5#include <emix.h>
6
6typedef struct _Emix_Config 7typedef struct _Emix_Config
7{ 8{
8 const char *backend; 9 const char *backend;
9 int notify; 10 int notify;
10 int mute; 11 int mute;
12 int meter;
11 13
12 emix_config_backend_changed cb; 14 emix_config_backend_changed cb;
15 emix_config_meter_changed meter_cb;
13 const void *userdata; 16 const void *userdata;
14} Emix_Config; 17} Emix_Config;
15 18
@@ -30,6 +33,7 @@ _emix_config_dd_new(void)
30 E_CONFIG_VAL(result, Emix_Config, backend, STR); 33 E_CONFIG_VAL(result, Emix_Config, backend, STR);
31 E_CONFIG_VAL(result, Emix_Config, notify, INT); 34 E_CONFIG_VAL(result, Emix_Config, notify, INT);
32 E_CONFIG_VAL(result, Emix_Config, mute, INT); 35 E_CONFIG_VAL(result, Emix_Config, mute, INT);
36 E_CONFIG_VAL(result, Emix_Config, meter, INT);
33 37
34 return result; 38 return result;
35} 39}
@@ -59,6 +63,12 @@ emix_config_desklock_mute_get(void)
59 return _config->mute; 63 return _config->mute;
60} 64}
61 65
66Eina_Bool
67emix_config_meter_get(void)
68{
69 return _config->meter;
70}
71
62static void 72static void
63_config_set(Emix_Config *config) 73_config_set(Emix_Config *config)
64{ 74{
@@ -67,13 +77,16 @@ _config_set(Emix_Config *config)
67 77
68 _config->notify = config->notify; 78 _config->notify = config->notify;
69 _config->mute = config->mute; 79 _config->mute = config->mute;
80 _config->meter = config->meter;
70 81
71 DBG("SAVING CONFIG %s %d %d", _config->backend, config->notify, config->mute); 82 DBG("SAVING CONFIG %s %d %d %d", _config->backend, config->notify,
83 config->mute, config->meter);
72 e_config_domain_save("module.emix", cd, config); 84 e_config_domain_save("module.emix", cd, config);
73} 85}
74 86
75void 87void
76emix_config_init(emix_config_backend_changed cb, const void *userdata) 88emix_config_init(emix_config_backend_changed cb,
89 emix_config_meter_changed meter_cb, const void *userdata)
77{ 90{
78 const Eina_List *l; 91 const Eina_List *l;
79 92
@@ -89,6 +102,7 @@ emix_config_init(emix_config_backend_changed cb, const void *userdata)
89 } 102 }
90 103
91 _config->cb = cb; 104 _config->cb = cb;
105 _config->meter_cb = meter_cb;
92 _config->userdata = userdata; 106 _config->userdata = userdata;
93 DBG("Config loaded, backend to use: %s", _config->backend); 107 DBG("Config loaded, backend to use: %s", _config->backend);
94} 108}
@@ -112,6 +126,7 @@ _create_data(E_Config_Dialog *cfg EINA_UNUSED)
112 d->config.backend = eina_stringshare_add(_config->backend); 126 d->config.backend = eina_stringshare_add(_config->backend);
113 d->config.notify = _config->notify; 127 d->config.notify = _config->notify;
114 d->config.mute = _config->mute; 128 d->config.mute = _config->mute;
129 d->config.meter = _config->meter;
115 130
116 return d; 131 return d;
117} 132}
@@ -140,6 +155,9 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas,
140 l = e_widget_check_add(evas, "Mute on lock", &cfdata->config.mute); 155 l = e_widget_check_add(evas, "Mute on lock", &cfdata->config.mute);
141 e_widget_list_object_append(o, l, 0, 0, 0); 156 e_widget_list_object_append(o, l, 0, 0, 0);
142 157
158 l = e_widget_check_add(evas, "Enable volume meter", &cfdata->config.meter);
159 e_widget_list_object_append(o, l, 0, 0, 0);
160
143 l = e_widget_label_add(evas, "Backend to use:"); 161 l = e_widget_label_add(evas, "Backend to use:");
144 e_widget_list_object_append(o, l, 0, 0, 0); 162 e_widget_list_object_append(o, l, 0, 0, 0);
145 163
@@ -162,7 +180,7 @@ _basic_create_widgets(E_Config_Dialog *cfd EINA_UNUSED, Evas *evas,
162 180
163static int 181static int
164_basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED, 182_basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
165 E_Config_Dialog_Data *cfdata) 183 E_Config_Dialog_Data *cfdata)
166{ 184{
167 char *new_backend = eina_list_nth( 185 char *new_backend = eina_list_nth(
168 emix_backends_available(), 186 emix_backends_available(),
@@ -172,7 +190,9 @@ _basic_apply_data(E_Config_Dialog *cfd EINA_UNUSED,
172 190
173 _config_set(&cfdata->config); 191 _config_set(&cfdata->config);
174 if (_config->cb) 192 if (_config->cb)
175 _config->cb(new_backend, (void *)_config->userdata); 193 _config->cb(new_backend, (void *)_config->userdata);
194 if (_config->meter_cb)
195 _config->meter_cb(!!_config->meter, (void *)_config->userdata);
176 return 1; 196 return 1;
177} 197}
178 198
diff --git a/src/module/e_mod_config.h b/src/module/e_mod_config.h
index f3ba786..09ee461 100644
--- a/src/module/e_mod_config.h
+++ b/src/module/e_mod_config.h
@@ -4,12 +4,15 @@
4#include <e.h> 4#include <e.h>
5 5
6typedef void (*emix_config_backend_changed)(const char *backend, void *data); 6typedef void (*emix_config_backend_changed)(const char *backend, void *data);
7typedef void (*emix_config_meter_changed)(Eina_Bool enable, void *data);
7 8
8void emix_config_init(emix_config_backend_changed cb, const void *userdata); 9void emix_config_init(emix_config_backend_changed cb,
10 emix_config_meter_changed meter_cb, const void *userdata);
9void emix_config_shutdown(void); 11void emix_config_shutdown(void);
10const char *emix_config_backend_get(void); 12const char *emix_config_backend_get(void);
11void emix_config_backend_set(const char *backend); 13void emix_config_backend_set(const char *backend);
12Eina_Bool emix_config_desklock_mute_get(void); 14Eina_Bool emix_config_desklock_mute_get(void);
15Eina_Bool emix_config_meter_get(void);
13Eina_Bool emix_config_notify_get(void); 16Eina_Bool emix_config_notify_get(void);
14E_Config_Dialog* emix_config_popup_new(E_Comp *comp, const char*p); 17E_Config_Dialog* emix_config_popup_new(E_Comp *comp, const char*p);
15 18
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index dad0883..cae84f0 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -767,6 +767,15 @@ _volume_meter_cb(Emix_Sink *sink, double value, void *data EINA_UNUSED)
767 } 767 }
768} 768}
769 769
770void
771_volume_meter_changed(Eina_Bool enable, void *data EINA_UNUSED)
772{
773 if (enable)
774 emix_volume_meter_callback_set(_volume_meter_cb, NULL);
775 else
776 emix_volume_meter_callback_set(NULL, NULL);
777}
778
770EAPI void * 779EAPI void *
771e_modapi_init(E_Module *m) 780e_modapi_init(E_Module *m)
772{ 781{
@@ -778,7 +787,7 @@ e_modapi_init(E_Module *m)
778 _e_emix_log_domain = eina_log_domain_register("emix_module", EINA_COLOR_RED); 787 _e_emix_log_domain = eina_log_domain_register("emix_module", EINA_COLOR_RED);
779 788
780 EINA_SAFETY_ON_FALSE_RETURN_VAL(emix_init(), NULL); 789 EINA_SAFETY_ON_FALSE_RETURN_VAL(emix_init(), NULL);
781 emix_config_init(_backend_changed, NULL); 790 emix_config_init(_backend_changed, _volume_meter_changed, NULL);
782 791
783 backend = emix_config_backend_get(); 792 backend = emix_config_backend_get();
784 if (!backend) 793 if (!backend)
@@ -805,7 +814,8 @@ e_modapi_init(E_Module *m)
805 if (backend_loaded == EINA_FALSE) 814 if (backend_loaded == EINA_FALSE)
806 goto err; 815 goto err;
807 816
808 emix_volume_meter_callback_set(_volume_meter_cb, NULL); 817 if (emix_config_meter_get())
818 emix_volume_meter_callback_set(_volume_meter_cb, NULL);
809 819
810 if (!mixer_context) 820 if (!mixer_context)
811 { 821 {
@@ -880,3 +890,4 @@ e_modapi_save(E_Module *m EINA_UNUSED)
880{ 890{
881 return 1; 891 return 1;
882} 892}
893