# HG changeset patch # User joey # Date 1131678421 0 # Node ID 6a1eaca0e6c1e72360ff3be6169045e71f606cfb # Parent 9352446d4fa89edfe6220226c29892121e381b91 DirectSound's GetVolume and SetVolume use 100ths of decibels and range from -10,000 to 0. MPlayer uses a linear intensity value between 0.0 and 100.0. This patch converts the values properly rather than simply linearly mapping the range. diff -r 9352446d4fa8 -r 6a1eaca0e6c1 libao2/ao_dsound.c --- a/libao2/ao_dsound.c Fri Nov 11 02:47:21 2005 +0000 +++ b/libao2/ao_dsound.c Fri Nov 11 03:07:01 2005 +0000 @@ -27,6 +27,7 @@ #include #define DIRECTSOUND_VERSION 0x0600 #include +#include #include "config.h" #include "libaf/af_format.h" @@ -389,13 +390,13 @@ case AOCONTROL_GET_VOLUME: { ao_control_vol_t* vol = (ao_control_vol_t*)arg; IDirectSoundBuffer_GetVolume(hdsbuf, &volume); - vol->left = vol->right = (float)(volume+10000) / 100.0; + vol->left = vol->right = pow(10.0, (float)(volume+10000) / 5000.0); //printf("ao_dsound: volume: %f\n",vol->left); return CONTROL_OK; } case AOCONTROL_SET_VOLUME: { ao_control_vol_t* vol = (ao_control_vol_t*)arg; - volume = (vol->right * 100.0)-10000; + volume = (DWORD)(log10(vol->right) * 5000.0) - 10000; IDirectSoundBuffer_SetVolume(hdsbuf, volume); //printf("ao_dsound: volume: %f\n",vol->left); return CONTROL_OK;