Amarok + PulseAudio: volume control changes global volume
Colin Guthrie
gmane at colin.guthr.ie
Tue Jul 6 09:38:53 BST 2010
'Twas brillig, and Nikos Chantziaras at 05/07/10 21:16 did gyre and gimble:
> Here's when I decrease volume in Amarok:
>
> ------------
> D: protocol-native.c: Client amarok changes volume of sink input Audio
> Stream.
> D: alsa-sink.c: Requested volume: 0: 44% 1: 44%
> D: alsa-sink.c: Got hardware volume: 0: 44% 1: 44%
> D: alsa-sink.c: Calculated software volume: 0: 99% 1: 99%
> (accurate-enough=yes)
> I: module-stream-restore.c: Storing volume/mute/device for stream
> sink-input-by-media-role:music.
> ------------
Right I need to correct myself a little here. I tend to think in "sink"
volumes rather than alsa "master" volumes and as such I've given you a
bad explanation earlier when I said it should never go down, but the
above output made me realise what is going on and where my explanation
was incorrectly.
So while the "sink volume" is fixed and will not drop below the value
you set it. The h/w alsa volume will fluctuate quite happily depending
on what is playing.
I'd say the main problem here is that you are using a Kmix that does not
support PA natively, and thus you are being exposed to the inner working
of PA's mixer control logic because you are seeing the "master" volume
change. With a PA enabled Kmix you would not see the "master" (actually
the primary sink volume in that context) change.
So just to demonstrate without a PA enabled Kmix using pavucontrol:
Set the Sink volume (Output Devices tab) to 100%.
Fire up Amarok, play and something (you will see the Amarok stream under
the "Playback" tab too but it's not super important here).
If you reduce the volume in Amarok, the Amarok slider under "Playback"
tab should mirror the Amarok volume exactly. The sink volume slider on
the Output tab however should stick at 100% regardless of the Amarok volume.
If however you reduce the Sink volume on the Output tab to e.g. 80%,
then what *should* happen is that Amarok's volume should also reduce
(proportionally) to this new upper limit. You can then reduce the Amarok
volume further and the sink volume should just stick at 80%.
Only when you increase the Amarok volume to >80% will the Sink volume
slider start to move up.
The "sink volume" as described above is what should be shown in kmix as
the "master" volume, but as mentioned above you are being exposed to the
inner workings of the volume control logic.
So what is this logic? Well, the general premise is that h/w volume
control is favoured whenever possible. So when your sink volume is at,
say 80%, but your amarok stream is only at 60%, then what PA will do is
say, "hmmm, there is only one stream currently playing, so what I'll do
is just set the underlying h/w volume to 60% and then I don't need to do
any software volume fiddling". This will be faster, less CPU intensive
and maybe even better quality (tho the last point is likely not true and
even the former may not be true on all h/w due to ALSA softvol, but we
try our best).
Now if another stream comes along and start playing (e.g. a knotify
sound), if that sound has never played before then it will inherit the
volume of the sink, i.e. 80%. Now there are two streams playing: one at
60% and one at 80%, so PA's logic of setting the h/w volume to 60% no
longer works. It will therefore change the h/w volume to 80% and then
apply software scaling to only the amaork stream to bring it back down
to the 60% it wants. So amarok's stream has not changed volume in terms
of what you hear in your ears, the sink volume has also not changed, but
the underlying ALSA master volume *has* changed. Or course when the
knotify stream disappears again, then all this unravels again, and the
software attenuation on the amarok stream is removed and the h/w volume
is set back to 60% again and everything carries on.
So in short, yes, the master volume will jump around when:
1. There is only one stream playing and you adjust it's volumes
2. When streams of different volume are played simultaneously
3. When several streams are playing and you adjust the stream volume of
the loudest one.
4. When you adjust the sink volume directly.
And under normal circumstances you should be blissfully ignorant of this
underlying change because it doesn't really matter at all to you that
this happens. The only reason you really care is because you are exposed
to it via your non-PA enabled kmix.
So in short, what you are seeing is all expected behaviour in this
scenario. Get yourself a PA enabled kmix and drink the kool aid and
you'll never need to worry again :)
If you really don't like this, disable flat-volumes as previously mentioned.
Cheers
Col
--
Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/
Day Job:
Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
Mandriva Linux Contributor [http://www.mandriva.com/]
PulseAudio Hacker [http://www.pulseaudio.org/]
Trac Hacker [http://trac.edgewall.org/]
More information about the kde-multimedia
mailing list