diff options
-rw-r--r-- | src/pulse/volume.c | 12 | ||||
-rw-r--r-- | src/pulse/volume.h | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/pulse/volume.c b/src/pulse/volume.c index 625eb19a..f0d45275 100644 --- a/src/pulse/volume.c +++ b/src/pulse/volume.c @@ -74,6 +74,18 @@ pa_volume_t pa_cvolume_avg(const pa_cvolume *a) { return (pa_volume_t) sum; } +pa_volume_t pa_cvolume_max(const pa_cvolume *a) { + pa_volume_t m = 0; + int i; + pa_assert(a); + + for (i = 0; i < a->channels; i++) + if (a->values[i] > m) + m = a->values[i]; + + return m; +} + pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) { return pa_sw_volume_from_linear(pa_sw_volume_to_linear(a)* pa_sw_volume_to_linear(b)); } diff --git a/src/pulse/volume.h b/src/pulse/volume.h index 4fdbf658..a356f749 100644 --- a/src/pulse/volume.h +++ b/src/pulse/volume.h @@ -134,6 +134,9 @@ char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c); /** Return the average volume of all channels */ pa_volume_t pa_cvolume_avg(const pa_cvolume *a) PA_GCC_PURE; +/** Return the maximum volume of all channels. \since 0.9.12 */ +pa_volume_t pa_cvolume_max(const pa_cvolume *a) PA_GCC_PURE; + /** Return TRUE when the passed cvolume structure is valid, FALSE otherwise */ int pa_cvolume_valid(const pa_cvolume *v) PA_GCC_PURE; |