[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.19-235-g7793da3

Lennart Poettering gitmailer-noreply at 0pointer.de
Wed Nov 4 19:58:00 PST 2009


This is an automated email from the git hooks/post-receive script. It was
generated because of a push to the "PulseAudio Sound Server" repository.

The master branch has been updated
      from  53b046d5c9593d848270e85017c2999a61256e0e (commit)

- Log -----------------------------------------------------------------
7793da3 lirc,mmkvd: added module parameters volume_limit, volume_step
d2c5935 volume: add pa_cvolume_inc_clamp function
-----------------------------------------------------------------------

Summary of changes:
 src/map-file                     |    1 +
 src/modules/module-lirc.c        |   26 +++++++++++++++++++++-----
 src/modules/module-mmkbd-evdev.c |   26 +++++++++++++++++++++-----
 src/pulse/volume.c               |   10 +++++++---
 src/pulse/volume.h               |    4 ++++
 5 files changed, 54 insertions(+), 13 deletions(-)

-----------------------------------------------------------------------

commit d2c59354d554f136739be7bbcd326f1d254f778e
Author: Vladimir Kokarev <matrix47 at gmail.com>
Date:   Sat Sep 19 19:43:24 2009 +0400

    volume: add pa_cvolume_inc_clamp function
    
    added function to increase volume not exceeding specified limit
    simply changed PA_VOLUME_MAX to 'limit' in pa_cvolume_inc
    pa_cvolume_inc now calls pa_cvolume_inc_clamp with PA_VOLUME_MAX limit

diff --git a/src/map-file b/src/map-file
index 5011122..1fffaff 100644
--- a/src/map-file
+++ b/src/map-file
@@ -130,6 +130,7 @@ pa_cvolume_get_balance;
 pa_cvolume_get_fade;
 pa_cvolume_get_position;
 pa_cvolume_inc;
+pa_cvolume_inc_clamp;
 pa_cvolume_init;
 pa_cvolume_max;
 pa_cvolume_max_mask;
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 2d2bba2..59e9a18 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -885,7 +885,7 @@ pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvo
     return dest;
 }
 
-pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc) {
+pa_cvolume* pa_cvolume_inc_clamp(pa_cvolume *v, pa_volume_t inc, pa_volume_t limit) {
     pa_volume_t m;
 
     pa_assert(v);
@@ -895,14 +895,18 @@ pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc) {
 
     m = pa_cvolume_max(v);
 
-    if (m >= PA_VOLUME_MAX - inc)
-        m = PA_VOLUME_MAX;
+    if (m >= limit - inc)
+        m = limit;
     else
         m += inc;
 
     return pa_cvolume_scale(v, m);
 }
 
+pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc){
+    return pa_cvolume_inc_clamp(v, inc, PA_VOLUME_MAX);
+}
+
 pa_cvolume* pa_cvolume_dec(pa_cvolume *v, pa_volume_t dec) {
     pa_volume_t m;
 
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index c964020..ded4422 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -348,6 +348,10 @@ pa_volume_t pa_cvolume_get_position(pa_cvolume *cv, const pa_channel_map *map, p
  * and dest may point to the same structure. \since 0.9.16 */
 pa_cvolume* pa_cvolume_merge(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
 
+/** Increase the volume passed in by 'inc', but not exceeding 'limit'.
+ * The proportions between the channels are kept. \since 0.9.19 */
+pa_cvolume* pa_cvolume_inc_clamp(pa_cvolume *v, pa_volume_t inc, pa_volume_t limit);
+
 /** Increase the volume passed in by 'inc'. The proportions between
  * the channels are kept. \since 0.9.16 */
 pa_cvolume* pa_cvolume_inc(pa_cvolume *v, pa_volume_t inc);

commit 7793da371bbf70e23c0b45de1e188f5dd58f3324
Author: Vladimir Kokarev <matrix47 at gmail.com>
Date:   Thu Nov 5 04:55:21 2009 +0100

    lirc,mmkvd: added module parameters volume_limit, volume_step
    
    volume_limit sets maximum volume that can be set from the module
    default is PA_VOLUME_NORM*3/2 (150%)
    volume_step sets step in volume changing
    default is PA_VOLUME_NORM/20
    values are of raw pa_volume_t type

diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c
index d0e902f..e977862 100644
--- a/src/modules/module-lirc.c
+++ b/src/modules/module-lirc.c
@@ -45,12 +45,14 @@ PA_MODULE_AUTHOR("Lennart Poettering");
 PA_MODULE_DESCRIPTION("LIRC volume control");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(TRUE);
-PA_MODULE_USAGE("config=<config file> sink=<sink name> appname=<lirc application name>");
+PA_MODULE_USAGE("config=<config file> sink=<sink name> appname=<lirc application name> volume_limit=<volume limit> volume_step=<volume change step>");
 
 static const char* const valid_modargs[] = {
     "config",
     "sink",
     "appname",
+    "volume_limit",
+    "volume_step",
     NULL,
 };
 
@@ -61,10 +63,10 @@ struct userdata {
     char *sink_name;
     pa_module *module;
     float mute_toggle_save;
+    pa_volume_t volume_limit;
+    pa_volume_t volume_step;
 };
 
-#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;
@@ -125,12 +127,12 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
 
                     switch (volchange) {
                         case UP:
-                            pa_cvolume_inc(&cv, DELTA);
+                            pa_cvolume_inc_clamp(&cv, u->volume_step, u->volume_limit);
                             pa_sink_set_volume(s, &cv, TRUE, TRUE);
                             break;
 
                         case DOWN:
-                            pa_cvolume_dec(&cv, DELTA);
+                            pa_cvolume_dec(&cv, u->volume_step);
                             pa_sink_set_volume(s, &cv, TRUE, TRUE);
                             break;
 
@@ -170,6 +172,8 @@ fail:
 int pa__init(pa_module*m) {
     pa_modargs *ma = NULL;
     struct userdata *u;
+    pa_volume_t volume_limit = PA_VOLUME_NORM*3/2;
+    pa_volume_t volume_step = PA_VOLUME_NORM/20;
 
     pa_assert(m);
 
@@ -178,6 +182,16 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_modargs_get_value_u32(ma, "volume_limit", &volume_limit) < 0) {
+        pa_log("Failed to parse volume limit");
+        goto fail;
+    }
+
+    if (pa_modargs_get_value_u32(ma, "volume_step", &volume_step) < 0) {
+        pa_log("Failed to parse volume step");
+        goto fail;
+    }
+
     m->userdata = u = pa_xnew(struct userdata, 1);
     u->module = m;
     u->io = NULL;
@@ -185,6 +199,8 @@ int pa__init(pa_module*m) {
     u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
     u->lirc_fd = -1;
     u->mute_toggle_save = 0;
+    u->volume_limit = volume_limit;
+    u->volume_step = volume_step;
 
     if ((u->lirc_fd = lirc_init((char*) pa_modargs_get_value(ma, "appname", "pulseaudio"), 1)) < 0) {
         pa_log("lirc_init() failed.");
diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c
index 14a9dd3..193c1f4 100644
--- a/src/modules/module-mmkbd-evdev.c
+++ b/src/modules/module-mmkbd-evdev.c
@@ -48,13 +48,15 @@ PA_MODULE_AUTHOR("Lennart Poettering");
 PA_MODULE_DESCRIPTION("Multimedia keyboard support via Linux evdev");
 PA_MODULE_VERSION(PACKAGE_VERSION);
 PA_MODULE_LOAD_ONCE(FALSE);
-PA_MODULE_USAGE("device=<evdev device> sink=<sink name>");
+PA_MODULE_USAGE("device=<evdev device> sink=<sink name> volume_limit=<volume limit> volume_step=<volume change step>");
 
 #define DEFAULT_DEVICE "/dev/input/event0"
 
 static const char* const valid_modargs[] = {
     "device",
     "sink",
+    "volume_limit",
+    "volume_step",
     NULL,
 };
 
@@ -63,10 +65,10 @@ struct userdata {
     pa_io_event *io;
     char *sink_name;
     pa_module *module;
+    pa_volume_t volume_limit;
+    pa_volume_t volume_step;
 };
 
-#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;
 
@@ -120,12 +122,12 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
 
                     switch (volchange) {
                         case UP:
-                            pa_cvolume_inc(&cv, DELTA);
+                            pa_cvolume_inc_clamp(&cv, u->volume_step, u->volume_limit);
                             pa_sink_set_volume(s, &cv, TRUE, TRUE);
                             break;
 
                         case DOWN:
-                            pa_cvolume_dec(&cv, DELTA);
+                            pa_cvolume_dec(&cv, u->volume_step);
                             pa_sink_set_volume(s, &cv, TRUE, TRUE);
                             break;
 
@@ -160,6 +162,8 @@ int pa__init(pa_module*m) {
     struct input_id input_id;
     char name[256];
     uint8_t evtype_bitmask[EV_MAX/8 + 1];
+    pa_volume_t volume_limit = PA_VOLUME_NORM*3/2;
+    pa_volume_t volume_step = PA_VOLUME_NORM/20;
 
     pa_assert(m);
 
@@ -168,12 +172,24 @@ int pa__init(pa_module*m) {
         goto fail;
     }
 
+    if (pa_modargs_get_value_u32(ma, "volume_limit", &volume_limit) < 0) {
+        pa_log("Failed to parse volume limit");
+        goto fail;
+    }
+
+    if (pa_modargs_get_value_u32(ma, "volume_step", &volume_step) < 0) {
+        pa_log("Failed to parse volume step");
+        goto fail;
+    }
+
     m->userdata = u = pa_xnew(struct userdata, 1);
     u->module = m;
     u->io = NULL;
     u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
     u->fd = -1;
     u->fd_type = 0;
+    u->volume_limit = volume_limit;
+    u->volume_step = volume_step;
 
     if ((u->fd = pa_open_cloexec(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), O_RDONLY, 0)) < 0) {
         pa_log("Failed to open evdev device: %s", pa_cstrerror(errno));

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list