[Bug 753304] pulsesink: volume does not appear to be linear; violates playbin contract

GStreamer (GNOME Bugzilla) bugzilla at gnome.org
Thu Aug 6 21:17:52 PDT 2015


https://bugzilla.gnome.org/show_bug.cgi?id=753304

--- Comment #6 from Dustin Spicuzza <dustin at virtualroadside.com> ---
Ok, so looking at pulsesink.c, we see that gst_pulsesink_set_volume calls
gst_pulse_cvolume_from_linear, which calls pa_sw_volume_from_linear to convert
a [0, 1.0] to pulse's [0, 0x10000]. 

Opening up pulse's source, in src/pulse/volume.c we see the following code for
pa_sw_volume_from_linear:

return (pa_volume_t) PA_CLAMP_VOLUME((uint64_t) lround(cbrt(v) *
PA_VOLUME_NORM));

So, it's doing a cube root on the volume. I can run that through python:

for i in range(1,10):
    print (i/10.0) ** (1/3.0)

0.464158883361
0.584803547643
0.669432950082
0.736806299728
0.793700525984
0.843432665302
0.887904001743
0.928317766723
0.965489384606

Looks like we've found our culprit! So the docs for that says:

/** Convert a linear factor to a volume.  0.0 and less is muted while
 * 1.0 is PA_VOLUME_NORM.  This is only valid for software volumes! */

My guess is that the value that playbin is representing as a linear range
(volume) is *not* the same as a "linear factor" in pulse's terminology... but
then looking around at what to set the volume to, there doesn't seem to be a
function to set it to x*PA_VOLUME_NORM, though that would seem to be the
desired behavior.

Ok, so they have more docs
(http://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/Developer/Clients/WritingVolumeControlUIs/),
and there's this:

"The actual mapping of the gradient of pa_volume_t in relation to the linear
volume is hidden inside of PA. It's chosen in a way that makes a volume of
32768 actually feel "half as loud" as a volume of 65536. (Or at least we try to
map it like this.) The actual algorithm is not considered part of the ABI. I
take the freedom to change it any time. You should not assume that the mapping
between linear/decibel volumes on one hand and pa_volume_t volumes on the other
will always stay the same in future versions. "

The problem of course is that setting my system's volume to 50% when my slider
says 0.1, seems a bit off.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.


More information about the gstreamer-bugs mailing list