PulseAudio volume behavior
#1
I am trying to understand the behavior of XBMC's volume controls when using the PulseAudio backend. I have recently been experimenting with PulseAudio on Fedora 20, whereas I previously ran XBMC on OpenELEC. There are two things that are strange:

(1) The volume is much louder when set to 100% (using XBMC's controls) than OpenELEC was (in both cases the same computer was connected to the same television using HDMI).

(2) Adjusting the volume does not seem linear. For example, I see with pacmd the following for each position of the slider:

(a) slider: 0%; pacmd: mute
(b) slider: approximately 25%; pacmd: 42771 / 65% / -11.12 dB
© slider: approximately 50%: pacmd: 52405 / 80% / -5.83 dB
(d) slider: approximately 75%: pacmd: 58501 / 89% / -2.96 dB
(e) slider: approximately 100%: pacmd: 65536 / 100% / 0.00 dB

Does anyone know why XBMC is behaving this way? I would like the volume slider to work in a linear fashion and the peak volume to be lower.
Reply
#2
Yes I know why it is that way - here is the code: https://github.com/xbmc/xbmc/blob/master...E.cpp#L649

Linear handling is in fact linear concerning a per centage scale. Problem here is that pulse uses a logarithm scale. You need to calculate a mapping from external to internal per centage and the other way raound :-)

I currently have no time to think that through properly. But you only need to change those two appearenaces in the code. Also make sure that you understand how the relationship between PA stream volume- internal xbmc volume - the callbacks - they sync (e,.g. someone changes xbmc's volume via pavucontrol) and the way back is related.

Edit: In fact if you read back the volume from the stream make sure, when you update the internal volume that this does _not_ retrigger a pa stream change - that's why I implemented it like it is now.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply
#3
Hi, me again.

add a local member into pa sink which is used for mapping the internal volume to a db logarithm value when communicating with the pa_stream. Also make sure to compute it the other way round, when reading the volume back from the sink - see how that is done currently.

That way you should be able to get the xbmc volume slider onto the proper value (without changing stream volume).

A PR is highly welcome.
First decide what functions / features you expect from a system. Then decide for the hardware. Don't waste your money on crap.
Reply

Logout Mark Read Team Forum Stats Members Help
PulseAudio volume behavior0