summaryrefslogtreecommitdiffstats
path: root/src/pulse/volume.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2009-01-27 00:47:07 +0100
committerLennart Poettering <lennart@poettering.net>2009-01-27 00:47:07 +0100
commit4e31e00b63117f36df6b8ed4850e7ad6264e3da7 (patch)
tree5c92e42cbcb414bc57d3325a0152e9f520c3ea11 /src/pulse/volume.c
parente52c5ea68a9c3bf6e7c4b30cb6c2d4706f214cd3 (diff)
implement pa_cvolume_scale()
Diffstat (limited to 'src/pulse/volume.c')
-rw-r--r--src/pulse/volume.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 10a44daf..2c977845 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -500,3 +500,22 @@ pa_cvolume* pa_cvolume_set_balance(const pa_channel_map *map, pa_cvolume *v, flo
return v;
}
+
+pa_cvolume* pa_cvolume_scale(pa_cvolume *v, pa_volume_t max) {
+ unsigned c;
+ pa_volume_t t = 0;
+
+ pa_assert(c);
+
+ for (c = 0; c < v->channels; c++)
+ if (v->values[c] > t)
+ t = v->values[c];
+
+ if (t <= 0)
+ return pa_cvolume_set(v, v->channels, max);
+
+ for (c = 0; c < v->channels; c++)
+ v->values[c] = (pa_volume_t) (((uint64_t) v->values[c] * (uint64_t) max) / (uint64_t) t);
+
+ return v;
+}