diff options
author | wm4 <wm4@mplayer2.org> | 2012-03-12 01:46:25 +0100 |
---|---|---|
committer | wm4 <wm4@mplayer2.org> | 2012-03-17 21:06:30 +0100 |
commit | c48c0f453bde933170ec2fa32c8abca1bd650fc6 (patch) | |
tree | c8c99f43ab258520d73082e3e94d3c31f39e0d85 /libao2 | |
parent | 2f9b14916fc2b4f3e505f0512c16d3a6f0fa30fe (diff) | |
download | mpv-c48c0f453bde933170ec2fa32c8abca1bd650fc6.tar.bz2 mpv-c48c0f453bde933170ec2fa32c8abca1bd650fc6.tar.xz |
ao_dsound: fix volume controls
The recent changes in mixer.c require the AO to return a volume of
exactly 0 when audio has been muted. Rather than adding just another
special case to mixer.c, fix ao_dsound.c to return previously set
volumes exactly. Because DirectSound volume control is not connected
with the system mixer, which could change the volume without mplayer
knowing, reading the volume back from DirectSound is pointless.
Also, the code tried to calculate log10(0). Clip the volume to 1,
which results in -10000, DirectSound's definition of silence.
Diffstat (limited to 'libao2')
-rw-r--r-- | libao2/ao_dsound.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libao2/ao_dsound.c b/libao2/ao_dsound.c index d21e39df9e..f1fc0dd00a 100644 --- a/libao2/ao_dsound.c +++ b/libao2/ao_dsound.c @@ -124,6 +124,7 @@ static int min_free_space = 0; ///if the free space is below this val static int underrun_check = 0; ///0 or last reported free space (underrun detection) static int device_num = 0; ///wanted device number static GUID device; ///guid of the device +static int audio_volume; /***************************************************************************************/ @@ -394,16 +395,16 @@ static int control(int cmd, void *arg) switch (cmd) { case AOCONTROL_GET_VOLUME: { ao_control_vol_t* vol = (ao_control_vol_t*)arg; - IDirectSoundBuffer_GetVolume(hdsbuf, &volume); - vol->left = vol->right = pow(10.0, (float)(volume+10000) / 5000.0); - //printf("ao_dsound: volume: %f\n",vol->left); + vol->left = vol->right = audio_volume; return CONTROL_OK; } case AOCONTROL_SET_VOLUME: { ao_control_vol_t* vol = (ao_control_vol_t*)arg; - volume = (DWORD)(log10(vol->right) * 5000.0) - 10000; + volume = audio_volume = vol->right; + if (volume < 1) + volume = 1; + volume = (DWORD)(log10(volume) * 5000.0) - 10000; IDirectSoundBuffer_SetVolume(hdsbuf, volume); - //printf("ao_dsound: volume: %f\n",vol->left); return CONTROL_OK; } } @@ -424,6 +425,7 @@ static int init(int rate, int channels, int format, int flags) if (!InitDirectSound()) return 0; global_ao->no_persistent_volume = true; + audio_volume = 100; // ok, now create the buffers WAVEFORMATEXTENSIBLE wformat; |