[vlc-devel] [PATCH] Use waveOutSetVolume to set volume instead of pure software gain

Rémi Denis-Courmont remi at remlab.net
Wed Jan 16 13:11:20 CET 2013

On Wed, 16 Jan 2013 01:11:15 +0100, Denis Charmet <typx at dinauz.org> wrote:
> Le mercredi 16 janvier 2013 à 12:47:16, Denis Charmet a écrit :
>> ---
>>  modules/audio_output/waveout.c |  128
>>  +++++++++++++++++++++++++++++++++++++---
>>  1 file changed, 120 insertions(+), 8 deletions(-)
> Now while this takes the previous comments... it raises a new potential
> problem. Since I got rid of volume.h, I had to choose between saving or
> not the volume.
> MSDN tells me that all the modifications I do on the volume are for this
> only instance so if I change the volume on one instance of a vlc using a
> waveout device it won't affect another instance of a vlc using the same
> waveout device. Tested on both of my Windows 7 computers.
> It doesn't affect the master audio.

What is the scope of an "instance"?

If I understand MSDN correctly, if the application provide a audio session
GUID, then the "instance" (or rather the session) can be persistent and
shared across multiple processes. If the GUID is not specified, then the
instance is probably not persistent. It is not clear to me.

> Yet when we change the sound of vlc using this functions the windows
> audio mixer cursor of this vlc instance will be affected by this

This behaviour is documented in MSDN. Namely, DirectSound and WaveOut
volume is reflected in the underlying Windows audio session.

> But so is the pulse one on my computer.


> Right now Waveout API doesn't let me nicely repercute changes in the
> windows audio mixer on the VLC interface without calling
> waveOutGetVolume.

There are no event interfaces for DirectSound and WaveOut. MSDN specifies
two ways to get the volume set by the mixer:
- poll waveOutGetVolume(), or
- use the Windows Audio Session interfaces.

While playing, you could get reasonably fast response time by polling
waveOutGetVolume() from the Play() callback. During pause or stop, either a
polling timer or WASAPI is required.

> And while writing this mail I realized that I forgot to reinitialize
> b_soft in Stop. It is fixed locally which allow volume changes after
> Stop or before Start.

Rémi Denis-Courmont
Sent from my collocated server

More information about the vlc-devel mailing list