[MPlayer-dev-eng] [PATCH] Make volume restore with pulseaudio work

Marcus Blumhagen marcus.blumhagen at web.de
Sat Oct 17 18:46:10 CEST 2009

Dear MPlayer developers,

first off, please be gentle, because I have only limited experience in
programming but I consider the attached patch to be trivial enough. ;)

It fixes the way mplayer initializes a pulseaudio stream to make use
of the pulseaudio module module-stream-restore. This module "restores
the volume/mute/device state of streams", to quote from its

The unpatched mplayer version always sets the initial volume of the
stream to 100% when playback of a file starts. This overrules

The patched version sets the volume of the stream to NULL, which
pulseaudio interprets as default volume. If the module-stream-restore
is loaded in the pulseaudio daemon, it will restore the last volume of
the mplayer stream. If it is not loaded then the stream volume will be
set to default according to the documentation in pulse/stream.h.

My testing so far has revealed no breakage, admitted my testing
abilities are limited. Here is what I have checked so far:

On playback start the volume is properly restored provided
module-stream-restore is loaded, if it is not loaded, the volume will
be 100%. The volume is properly represented in the OSD, even if I
changed the stream volume outside of mplayer, i.e. using pavucontrol.
Volume control inside mplayer also works flawlessly. Also setting the
initial volume of mplayer using -volume works and results in the
specified value rather then the restored volume.

Actually this patch was already applied for the upcoming Mandriva
release by Colin Guthrie. He also did some code reviewing and found
that there will be "no race between starting the stream and reading
the volume before we get the info callback".

I already posted this before on the mplayer-users mailing list but it
got ignored, sorry for not reading the bug report section properly
before. There is also a short thread on the pulseaudio-discuss mailing
list. I hope I have not forgotten anything in this message but you
might want to have a look for reference:



Marcus Blumhagen

"Any intelligent fool can make things bigger, more complex, and more
violent. It takes a touch of genius -- and a lot of courage -- to move
in the opposite direction."
                                                      -- Albert Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: [PATCH]ao_pulse_volume_restore_fix.diff
Type: text/x-diff
Size: 698 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20091017/453c4233/attachment.diff>

More information about the MPlayer-dev-eng mailing list