[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.12-131-gda4ad5e

Lennart Poettering gitmailer-noreply at 0pointer.de
Fri Oct 3 16:41:02 PDT 2008


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  87c8132ce3f58eb65e742f085b364850c40fbf6a (commit)

- Log -----------------------------------------------------------------
da4ad5e... implement pa_sw_volume_divide() and pa_sw_cvolume_divide()
-----------------------------------------------------------------------

Summary of changes:
 src/pulse/volume.c |   30 +++++++++++++++++++++++++-----
 src/pulse/volume.h |   17 +++++++++++++++--
 2 files changed, 40 insertions(+), 7 deletions(-)

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

commit da4ad5ed01c02f6390c0e4e741734184707f655e
Author: Lennart Poettering <lennart at poettering.net>
Date:   Sat Oct 4 01:40:41 2008 +0200

    implement pa_sw_volume_divide() and pa_sw_cvolume_divide()

diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index 0412819..99a85f4 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -104,6 +104,15 @@ 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));
 }
 
+pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) {
+    double v = pa_sw_volume_to_linear(b);
+
+    if (v <= 0)
+        return 0;
+
+    return pa_sw_volume_from_linear(pa_sw_volume_to_linear(a) / v);
+}
+
 #define USER_DECIBEL_RANGE 60
 
 pa_volume_t pa_sw_volume_from_dB(double dB) {
@@ -220,12 +229,23 @@ pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const
     pa_assert(a);
     pa_assert(b);
 
-    for (i = 0; i < a->channels && i < b->channels && i < PA_CHANNELS_MAX; i++) {
+    for (i = 0; i < a->channels && i < b->channels && i < PA_CHANNELS_MAX; i++)
+        dest->values[i] = pa_sw_volume_multiply(a->values[i], b->values[i]);
 
-        dest->values[i] = pa_sw_volume_multiply(
-            i < a->channels ? a->values[i] : PA_VOLUME_NORM,
-            i < b->channels ? b->values[i] : PA_VOLUME_NORM);
-    }
+    dest->channels = (uint8_t) i;
+
+    return dest;
+}
+
+pa_cvolume *pa_sw_cvolume_divide(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b) {
+    unsigned i;
+
+    pa_assert(dest);
+    pa_assert(a);
+    pa_assert(b);
+
+    for (i = 0; i < a->channels && i < b->channels && i < PA_CHANNELS_MAX; i++)
+        dest->values[i] = pa_sw_volume_divide(a->values[i], b->values[i]);
 
     dest->channels = (uint8_t) i;
 
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index bfd8ca5..75051af 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -168,12 +168,25 @@ int pa_cvolume_channels_equal_to(const pa_cvolume *a, pa_volume_t v) PA_GCC_PURE
 /** Return 1 if the specified volume has all channels on normal level */
 #define pa_cvolume_is_norm(a) pa_cvolume_channels_equal_to((a), PA_VOLUME_NORM)
 
-/** Multiply two volumes specifications, return the result. This uses PA_VOLUME_NORM as neutral element of multiplication. This is only valid for software volumes! */
+/** Multiply two volume specifications, return the result. This uses
+ * PA_VOLUME_NORM as neutral element of multiplication. This is only
+ * valid for software volumes! */
 pa_volume_t pa_sw_volume_multiply(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
 
-/** Multiply to per-channel volumes and return the result in *dest. This is only valid for software volumes! */
+/** Multiply two per-channel volumes and return the result in
+ * *dest. This is only valid for software volumes! */
 pa_cvolume *pa_sw_cvolume_multiply(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
 
+/** Divide two volume specifications, return the result. This uses
+ * PA_VOLUME_NORM as neutral element of division. This is only valid
+ * for software volumes! If a division by zero is tried the result
+ * will be 0. \since 0.9.13 */
+pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
+
+/** Multiply to per-channel volumes and return the result in
+ * *dest. This is only valid for software volumes! \since 0.9.13 */
+pa_cvolume *pa_sw_cvolume_divide(pa_cvolume *dest, const pa_cvolume *a, const pa_cvolume *b);
+
 /** Convert a decibel value to a volume. This is only valid for software volumes! */
 pa_volume_t pa_sw_volume_from_dB(double f) PA_GCC_CONST;
 

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list