summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
authorArun Raghavan <arun.raghavan@collabora.co.uk>2010-10-09 15:38:43 +0530
committerArun Raghavan <arun.raghavan@collabora.co.uk>2010-10-15 01:10:00 +0530
commit49101fc540aec9a249e97a9f650be38f9f92f5ac (patch)
tree6b2049a66cb3f4c43adcb424468ff2deb852df84 /src/modules
parent1d2ef7923d28a74e08a4309b6fa3d36481d2df3b (diff)
volume: Clamp volume to PA_VOLUME_MAX
This ensures that we always clamp the volume to PA_VOLUME_MAX. While this currently has no effect, it will be required for making sure we don't exceed PA_VOLUME_MAX when its value changes in the future.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/module-lirc.c6
-rw-r--r--src/modules/module-match.c2
-rw-r--r--src/modules/module-mmkbd-evdev.c4
-rw-r--r--src/modules/module-waveout.c4
-rw-r--r--src/modules/oss/oss-util.c4
5 files changed, 10 insertions, 10 deletions
diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c
index e9778620..15f3442d 100644
--- a/src/modules/module-lirc.c
+++ b/src/modules/module-lirc.c
@@ -172,7 +172,7 @@ 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_limit = PA_CLAMP_VOLUME(PA_VOLUME_NORM*3/2);
pa_volume_t volume_step = PA_VOLUME_NORM/20;
pa_assert(m);
@@ -199,8 +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;
+ u->volume_limit = PA_CLAMP_VOLUME(volume_limit);
+ u->volume_step = PA_CLAMP_VOLUME(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-match.c b/src/modules/module-match.c
index b1693f18..d83c86c3 100644
--- a/src/modules/module-match.c
+++ b/src/modules/module-match.c
@@ -127,7 +127,7 @@ static int load_rules(struct userdata *u, const char *filename) {
*d = 0;
if (pa_atou(v, &k) >= 0) {
- volume = (pa_volume_t) k;
+ volume = (pa_volume_t) PA_CLAMP_VOLUME(k);
} else if (*v == '"') {
char *e;
diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c
index 193c1f40..4e89aed9 100644
--- a/src/modules/module-mmkbd-evdev.c
+++ b/src/modules/module-mmkbd-evdev.c
@@ -188,8 +188,8 @@ int pa__init(pa_module*m) {
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;
+ u->volume_limit = PA_CLAMP_VOLUME(volume_limit);
+ u->volume_step = PA_CLAMP_VOLUME(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));
diff --git a/src/modules/module-waveout.c b/src/modules/module-waveout.c
index d1b9f2ff..6fedceb2 100644
--- a/src/modules/module-waveout.c
+++ b/src/modules/module-waveout.c
@@ -359,8 +359,8 @@ static int sink_get_hw_volume_cb(pa_sink *s) {
if (waveOutGetVolume(u->hwo, &vol) != MMSYSERR_NOERROR)
return -1;
- left = (vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME;
- right = ((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME;
+ left = PA_CLAMP_VOLUME((vol & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
+ right = PA_CLAMP_VOLUME(((vol >> 16) & 0xFFFF) * PA_VOLUME_NORM / WAVEOUT_MAX_VOLUME);
/* Windows supports > 2 channels, except for volume control */
if (s->hw_volume.channels > 2)
diff --git a/src/modules/oss/oss-util.c b/src/modules/oss/oss-util.c
index b95023c3..966a6ca1 100644
--- a/src/modules/oss/oss-util.c
+++ b/src/modules/oss/oss-util.c
@@ -271,10 +271,10 @@ int pa_oss_get_volume(int fd, unsigned long mixer, const pa_sample_spec *ss, pa_
pa_cvolume_reset(volume, ss->channels);
- volume->values[0] = ((vol & 0xFF) * PA_VOLUME_NORM) / 100;
+ volume->values[0] = PA_CLAMP_VOLUME(((vol & 0xFF) * PA_VOLUME_NORM) / 100);
if (volume->channels >= 2)
- volume->values[1] = (((vol >> 8) & 0xFF) * PA_VOLUME_NORM) / 100;
+ volume->values[1] = PA_CLAMP_VOLUME((((vol >> 8) & 0xFF) * PA_VOLUME_NORM) / 100);
pa_log_debug("Read mixer settings: %s", pa_cvolume_snprint(cv, sizeof(cv), volume));
return 0;