[pulseaudio-discuss] User volume vs. Application volume

Andrew Eikum aeikum at codeweavers.com
Thu May 24 07:28:34 PDT 2012


Hi folks,

I've been thinking about this issue for a while and I'd like to share
my thoughts and receive opinions back.

While developing a PulseAudio driver for Wine, I ran into the issue of
implementing the volume control interfaces. Microsoft's APIs allow the
application to make calls that set the stream volume. However, the
Windows 7 mixer /also/ allows the user to set stream volumes. These
two volumes are entirely independent of each other.

I think this makes complete sense. For example, you might have a music
player which implements a crossfade between tracks. The obvious way to
implement this to open two streams, and as the first stream reaches
its last 5 seconds, you fade its volume down and simultaneously start
and increase the volume for the second stream. The user can then set
the music player's volume at 50% relative to their chat program, and
everything works as expected.

Crossfading in this manner works fine in PulseAudio, but it conflicts
with the user's volume settings. When the music player starts setting
the volumes for the purposes of crossfading, it overrides the user's
settings, potentially deafening them[1].

This actually extends beyond volume control. Both of the music
player's streams will appear in pavucontrol, when they really
represent a single logical audio channel. I would expect some API to
combine those into a single user-facing stream, akin to Microsoft's
AudioSessions[2]. But this is a separate-but-related issue and can be
resolved later.

Perhaps this goes beyond the scope of PulseAudio, in that PA shouldn't
be used as an application mixer. If that's the case, PA's APIs don't
make it obvious enough, as we have actual applications that use the
volume APIs to implement mixing (see [1], [3], [4]). That said, I
think this is a reasonably small service to provide to applications.
There's already a long history of audio APIs providing
application-level mixing, and now we have the opportunity to provide
both application-level /and/ user-facing volume control.

I don't understand flat volumes, so I haven't accounted for them at
all in the preceding discussion.

I also haven't looked much at implementing this. We would need to
modify PulseAudio's volume APIs to make it clear whether the
application is trying to set the user volume (for mixer applications
like pavucontrol) or the application volume. PulseAudio's volume APIs
are already pretty humongous and confusing, so this might be tricky.

Do others agree with my analysis? Is this something that should be
included in PulseAudio? Any tips for how to design the APIs for this?

Andrew

[1]
http://pulseaudio.org/ticket/774
mplayer sets the stream volume to 100%

[2]
http://msdn.microsoft.com/en-us/library/windows/desktop/dd368246(v=vs.85).aspx
IAudioSessionControl interface

[3]
http://lists.freedesktop.org/archives/pulseaudio-discuss/2012-March/013128.html
References Decibel Audio Player as setting maximum volume upon launch.

[4]
http://repo.or.cz/w/wine/multimedia.git/blob/HEAD:/dlls/winepulse.drv/mmdevdrv.c#l2246
An unofficial PulseAudio driver for Wine which uses PA's volume APIs
to implement Windows 7's "application-side" volume controls mentioned
above.


More information about the pulseaudio-discuss mailing list