[MPlayer-cvslog] CVS: main/libao2 ao_dsound.c,1.12,1.13

Joey Parrish CVS syncmail at mplayerhq.hu
Fri Nov 11 04:07:03 CET 2005


CVS change done by Joey Parrish CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv30330/libao2

Modified Files:
	ao_dsound.c 
Log Message:
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.


Index: ao_dsound.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_dsound.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- ao_dsound.c	15 Mar 2005 16:29:18 -0000	1.12
+++ ao_dsound.c	11 Nov 2005 03:07:01 -0000	1.13
@@ -27,6 +27,7 @@
 #include <windows.h>
 #define DIRECTSOUND_VERSION 0x0600
 #include <dsound.h>
+#include <math.h>
 
 #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;




More information about the MPlayer-cvslog mailing list