[pulseaudio-commits] [SCM] PulseAudio Sound Server branch, master, updated. v0.9.15-121-ge2aba15

Lennart Poettering gitmailer-noreply at 0pointer.de
Thu May 21 16:31:43 PDT 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  e7bca90775222145224425980c1d44580a7a2c8d (commit)

- Log -----------------------------------------------------------------
e2aba15 core-util: fall back to sysconf(_SC_OPEN_MAX) to find maximum file descriptor
ce3fbb5 tests: show dB in volume-ui.py
000bdb8 volume: change pa_volume_t mapping to cubic
-----------------------------------------------------------------------

Summary of changes:
 src/pulse/volume.c        |   42 ++++++++++++++++++++++++++++++------------
 src/pulse/volume.h        |    6 +++---
 src/pulsecore/core-util.c |   10 ++++++----
 src/tests/volume-ui.py    |   29 ++++++++++++++++++++++++++---
 4 files changed, 65 insertions(+), 22 deletions(-)

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

commit 000bdb8d2545a3d6c09a7b154f09e6c4c045018d
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 22 01:30:54 2009 +0200

    volume: change pa_volume_t mapping to cubic

diff --git a/src/pulse/volume.c b/src/pulse/volume.c
index a9622e7..e48c777 100644
--- a/src/pulse/volume.c
+++ b/src/pulse/volume.c
@@ -120,20 +120,28 @@ pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) {
     return pa_sw_volume_from_linear(pa_sw_volume_to_linear(a) / v);
 }
 
-#define USER_DECIBEL_RANGE 90
+/* Amplitude, not power */
+static double linear_to_dB(double v) {
+    return 20.0 * log10(v);
+}
+
+static double dB_to_linear(double v) {
+    return pow(10.0, v / 20.0);
+}
 
 pa_volume_t pa_sw_volume_from_dB(double dB) {
-    if (isinf(dB) < 0 || dB <= -USER_DECIBEL_RANGE)
+    if (isinf(dB) < 0 || dB <= PA_DECIBEL_MININFTY)
         return PA_VOLUME_MUTED;
 
-    return (pa_volume_t) lrint(ceil((dB/USER_DECIBEL_RANGE+1.0)*PA_VOLUME_NORM));
+    return pa_sw_volume_from_linear(dB_to_linear(dB));
 }
 
 double pa_sw_volume_to_dB(pa_volume_t v) {
-    if (v == PA_VOLUME_MUTED)
+
+    if (v <= PA_VOLUME_MUTED)
         return PA_DECIBEL_MININFTY;
 
-    return ((double) v/PA_VOLUME_NORM-1)*USER_DECIBEL_RANGE;
+    return linear_to_dB(pa_sw_volume_to_linear(v));
 }
 
 pa_volume_t pa_sw_volume_from_linear(double v) {
@@ -141,18 +149,28 @@ pa_volume_t pa_sw_volume_from_linear(double v) {
     if (v <= 0.0)
         return PA_VOLUME_MUTED;
 
-    if (v > .999 && v < 1.001)
-        return PA_VOLUME_NORM;
+    /*
+     * We use a cubic mapping here, as suggested and discussed here:
+     *
+     * http://www.robotplanet.dk/audio/audio_gui_design/
+     * http://lists.linuxaudio.org/pipermail/linux-audio-dev/2009-May/thread.html#23151
+     */
 
-    return pa_sw_volume_from_dB(20.0*log10(v));
+    return (pa_volume_t) (cbrt(v) * PA_VOLUME_NORM);
 }
 
 double pa_sw_volume_to_linear(pa_volume_t v) {
+    double f;
 
-    if (v == PA_VOLUME_MUTED)
+    if (v <= PA_VOLUME_MUTED)
         return 0.0;
 
-    return pow(10.0, pa_sw_volume_to_dB(v)/20.0);
+    if (v == PA_VOLUME_NORM)
+        return 1.0;
+
+    f = ((double) v / PA_VOLUME_NORM);
+
+    return f*f*f;
 }
 
 char *pa_cvolume_snprint(char *s, size_t l, const pa_cvolume *c) {
@@ -225,7 +243,7 @@ char *pa_sw_cvolume_snprint_dB(char *s, size_t l, const pa_cvolume *c) {
         l -= pa_snprintf(e, l, "%s%u: %0.2f dB",
                          first ? "" : " ",
                          channel,
-                         isinf(f) < 0 || f <= -USER_DECIBEL_RANGE ? -INFINITY : f);
+                         isinf(f) < 0 || f <= PA_DECIBEL_MININFTY ? -INFINITY : f);
 
         e = strchr(e, 0);
         first = FALSE;
@@ -249,7 +267,7 @@ char *pa_sw_volume_snprint_dB(char *s, size_t l, pa_volume_t v) {
 
     f = pa_sw_volume_to_dB(v);
     pa_snprintf(s, l, "%0.2f dB",
-                isinf(f) < 0 || f <= -USER_DECIBEL_RANGE ?  -INFINITY : f);
+                isinf(f) < 0 || f <= PA_DECIBEL_MININFTY ?  -INFINITY : f);
 
     return s;
 }
diff --git a/src/pulse/volume.h b/src/pulse/volume.h
index ddedca7..b567778 100644
--- a/src/pulse/volume.h
+++ b/src/pulse/volume.h
@@ -212,10 +212,10 @@ pa_volume_t pa_sw_volume_divide(pa_volume_t a, pa_volume_t b) PA_GCC_CONST;
  * *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! */
+/** Convert a decibel value to a volume (amplitude, not power). This is only valid for software volumes! */
 pa_volume_t pa_sw_volume_from_dB(double f) PA_GCC_CONST;
 
-/** Convert a volume to a decibel value. This is only valid for software volumes! */
+/** Convert a volume to a decibel value (amplitude, not power). This is only valid for software volumes! */
 double pa_sw_volume_to_dB(pa_volume_t v) PA_GCC_CONST;
 
 /** Convert a linear factor to a volume. This is only valid for software volumes! */
@@ -227,7 +227,7 @@ double pa_sw_volume_to_linear(pa_volume_t v) PA_GCC_CONST;
 #ifdef INFINITY
 #define PA_DECIBEL_MININFTY ((double) -INFINITY)
 #else
-/** This value is used as minus infinity when using pa_volume_{to,from}_dB(). */
+/** This floor value is used as minus infinity when using pa_volume_{to,from}_dB(). */
 #define PA_DECIBEL_MININFTY ((double) -200.0)
 #endif
 

commit ce3fbb5268b68681b86e58eec8bd88c41bc393c9
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 22 01:31:26 2009 +0200

    tests: show dB in volume-ui.py

diff --git a/src/tests/volume-ui.py b/src/tests/volume-ui.py
index 6dc1c47..7909b80 100644
--- a/src/tests/volume-ui.py
+++ b/src/tests/volume-ui.py
@@ -111,6 +111,10 @@ class CVolume(Structure):
     _set_fade.restype = c_void_p
     _set_fade.argtypes = [c_void_p, c_void_p, c_float]
 
+    _to_dB = libpulse.pa_sw_volume_to_dB
+    _to_dB.restype = c_double
+    _to_dB.argytpes = [c_uint32]
+
     def snprint(this):
         s = create_string_buffer(320)
         r = this._snprint(s, len(s), byref(this))
@@ -138,6 +142,12 @@ class CVolume(Structure):
     def set_fade(this, cm, f):
         return this._set_fade(byref(this), byref(cm), f)
 
+    def to_dB(this, channel = None):
+        if channel is None:
+            return this._to_dB(this.max())
+
+        return this._to_dB(this.values[channel])
+
 cm = ChannelMap()
 
 if len(sys.argv) > 1:
@@ -149,7 +159,7 @@ v = CVolume()
 v.channels = cm.channels
 
 for i in range(cm.channels):
-    v.values[i] = 65536/2
+    v.values[i] = 65536
 
 title = cm.to_pretty_name()
 if title is None:
@@ -163,6 +173,7 @@ vbox = gtk.VBox(spacing=6)
 
 channel_labels = {}
 channel_scales = {}
+channel_dB_labels = {}
 
 def update_volume(update_channels = True, update_fade = True, update_balance = True, update_scale = True):
     if update_channels:
@@ -178,6 +189,11 @@ def update_volume(update_channels = True, update_fade = True, update_balance = T
     if update_fade:
         fade_scale.set_value(v.get_fade(cm))
 
+    for i in range(cm.channels):
+        channel_dB_labels[i].set_label("%0.2f dB" % v.to_dB(i))
+
+    value_dB_label.set_label("%0.2f dB" % v.to_dB())
+
 def fade_value_changed(fs):
     v.set_fade(cm, fade_scale.get_value())
     update_volume(update_fade = False)
@@ -200,19 +216,26 @@ for i in range(cm.channels):
     vbox.pack_start(channel_labels[i], expand=False, fill=True)
 
     channel_scales[i] = gtk.HScale()
-    channel_scales[i].set_range(0, 65536)
+    channel_scales[i].set_range(0, 65536*3/2)
     channel_scales[i].set_digits(0)
     channel_scales[i].set_value_pos(gtk.POS_RIGHT)
     vbox.pack_start(channel_scales[i], expand=False, fill=True)
 
+    channel_dB_labels[i] = gtk.Label("-xxx dB")
+    channel_dB_labels[i].set_alignment(1, 1)
+    vbox.pack_start(channel_dB_labels[i], expand=False, fill=True)
+
 value_label = gtk.Label("Value")
 value_label.set_alignment(0, .5)
 vbox.pack_start(value_label, expand=False, fill=True)
 value_scale = gtk.HScale()
-value_scale.set_range(0, 65536)
+value_scale.set_range(0, 65536*3/2)
 value_scale.set_value_pos(gtk.POS_RIGHT)
 value_scale.set_digits(0)
 vbox.pack_start(value_scale, expand=False, fill=True)
+value_dB_label = gtk.Label("-xxx dB")
+value_dB_label.set_alignment(1, 1)
+vbox.pack_start(value_dB_label, expand=False, fill=True)
 
 balance_label = gtk.Label("Balance")
 balance_label.set_alignment(0, .5)

commit e2aba1521a48a2be42e46e741b0eb7f8b67cae39
Author: Lennart Poettering <lennart at poettering.net>
Date:   Fri May 22 01:31:56 2009 +0200

    core-util: fall back to sysconf(_SC_OPEN_MAX) to find maximum file descriptor

diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 4658eb5..d4956fb 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -2235,7 +2235,7 @@ int pa_close_all(int except_fd, ...) {
 
 int pa_close_allv(const int except_fds[]) {
     struct rlimit rl;
-    int fd;
+    int maxfd, fd;
     int saved_errno;
 
 #ifdef __linux__
@@ -2302,10 +2302,12 @@ int pa_close_allv(const int except_fds[]) {
 
 #endif
 
-    if (getrlimit(RLIMIT_NOFILE, &rl) < 0)
-        return -1;
+    if (getrlimit(RLIMIT_NOFILE, &rl) >= 0)
+        maxfd = (int) rl.rlim_max;
+    else
+        maxfd = sysconf(_SC_OPEN_MAX);
 
-    for (fd = 3; fd < (int) rl.rlim_max; fd++) {
+    for (fd = 3; fd < maxfd; fd++) {
         int i;
         pa_bool_t found;
 

-- 
hooks/post-receive
PulseAudio Sound Server



More information about the pulseaudio-commits mailing list