summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-08-19 03:37:42 +0200
committerLennart Poettering <lennart@poettering.net>2009-08-19 03:37:42 +0200
commit7af3833b7110c08d3717edb6018350d390e9d492 (patch)
treef9fa94e7dde2722e50515dfd0b9372b77fb10f1a /src/modules
parent2f54798b1afdbe684dd1e5ba6d39a807c6afc8d8 (diff)
lirc: replace manual code by pa_cvolume_{inc|dec}()
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/module-lirc.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c
index fdfdc797..d0e902f6 100644
--- a/src/modules/module-lirc.c
+++ b/src/modules/module-lirc.c
@@ -63,6 +63,8 @@ struct userdata {
float mute_toggle_save;
};
+#define DELTA (PA_VOLUME_NORM/20)
+
static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event_flags_t events, void*userdata) {
struct userdata *u = userdata;
char *name = NULL, *code = NULL;
@@ -119,31 +121,16 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
if (!(s = pa_namereg_get(u->module->core, u->sink_name, PA_NAMEREG_SINK)))
pa_log("Failed to get sink '%s'", u->sink_name);
else {
- int i;
pa_cvolume cv = *pa_sink_get_volume(s, FALSE);
-#define DELTA (PA_VOLUME_NORM/20)
-
switch (volchange) {
case UP:
- for (i = 0; i < cv.channels; i++) {
- if (cv.values[i] < PA_VOLUME_MAX - DELTA)
- cv.values[i] += DELTA;
- else
- cv.values[i] = PA_VOLUME_MAX;
- }
-
+ pa_cvolume_inc(&cv, DELTA);
pa_sink_set_volume(s, &cv, TRUE, TRUE);
break;
case DOWN:
- for (i = 0; i < cv.channels; i++) {
- if (cv.values[i] > DELTA)
- cv.values[i] -= DELTA;
- else
- cv.values[i] = PA_VOLUME_MUTED;
- }
-
+ pa_cvolume_dec(&cv, DELTA);
pa_sink_set_volume(s, &cv, TRUE, TRUE);
break;
@@ -156,7 +143,6 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
break;
case MUTE_TOGGLE:
-
pa_sink_set_mute(s, !pa_sink_get_mute(s, FALSE), TRUE);
break;