[MPlayer-users] Fix volume restore for -ao pulse (patch inside)

Marcus Blumhagen marcus.blumhagen at web.de
Tue Oct 13 15:08:37 CEST 2009


Hi,

I noticed that mplayer -ao pulse always starts with volume set to 100%
(unless explicitly set by -volume). Even setting -volume -1 didn´t
restore the volume of the pulse stream:

  $ mplayer -ao pulse -volume -1 some-file.avi

Corresponding output of pulseaudio -vvvC looks like this:

  D: module-stream-restore.c: Not restoring volume for sink input sink-input-by-application-name:MPlayer, because already set.


The pulse module module-stream-restore stores the volume, when a
stream exits. So say I set the volume to 50% during playback and quit
mplayer the volume value of the mplayer pulse stream is saved and
should be restored when mplayer is restarted. But it does not work,
since mplayer explicitly sets the volume when starting a video. Even
when mplayer plays more than one files, the volume is set to 100% when
starting playback of a new file. That can be pretty annoying, if the
other file was played back at 5% volume. :)

But the cure seems pretty easy, see the patch below. Now it looks like
this:

  $ mplayer -ao pulse -volume -1 some-file.avi

pulseaudio -vvvC:

  I: module-stream-restore.c: Restoring volume for sink input sink-input-by-application-name:MPlayer.


I checked for some side effects but there seem to be no major ones.
One can still set the volume explicitly by -volume and even -volume -1
works now. The only thing I noticed is, that now module-restore says
it is restoring the volume even if one uses -volume >-1, but the
volume is set to the requested volume anyway. I think this has to do
with this:

ao_pulse.c, line 192:
  pa_cvolume_reset(&volume, ss.channels);

but I am not sure. Disabling it breaks -volume >-1.

-- 
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


Index: libao2/ao_pulse.c
===================================================================
--- libao2/ao_pulse.c   (revision 29771)
+++ libao2/ao_pulse.c   (working copy)
@@ -224,7 +224,7 @@
     pa_stream_set_write_callback(stream, stream_request_cb, NULL);
     pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL);
 
-    if (pa_stream_connect_playback(stream, sink, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, &volume, NULL) < 0)
+    if (pa_stream_connect_playback(stream, sink, NULL, PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE, NULL, NULL) < 0)
         goto unlock_and_fail;
 
     /* Wait until the stream is ready */


More information about the MPlayer-users mailing list