Mercurial > mplayer.hg
comparison libao2/ao_dsound.c @ 16972:6a1eaca0e6c1
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.
author | joey |
---|---|
date | Fri, 11 Nov 2005 03:07:01 +0000 |
parents | 2f4f347bd5e4 |
children | 99e20a22d5d0 |
comparison
equal
deleted
inserted
replaced
16971:9352446d4fa8 | 16972:6a1eaca0e6c1 |
---|---|
25 #include <stdio.h> | 25 #include <stdio.h> |
26 #include <stdlib.h> | 26 #include <stdlib.h> |
27 #include <windows.h> | 27 #include <windows.h> |
28 #define DIRECTSOUND_VERSION 0x0600 | 28 #define DIRECTSOUND_VERSION 0x0600 |
29 #include <dsound.h> | 29 #include <dsound.h> |
30 #include <math.h> | |
30 | 31 |
31 #include "config.h" | 32 #include "config.h" |
32 #include "libaf/af_format.h" | 33 #include "libaf/af_format.h" |
33 #include "audio_out.h" | 34 #include "audio_out.h" |
34 #include "audio_out_internal.h" | 35 #include "audio_out_internal.h" |
387 DWORD volume; | 388 DWORD volume; |
388 switch (cmd) { | 389 switch (cmd) { |
389 case AOCONTROL_GET_VOLUME: { | 390 case AOCONTROL_GET_VOLUME: { |
390 ao_control_vol_t* vol = (ao_control_vol_t*)arg; | 391 ao_control_vol_t* vol = (ao_control_vol_t*)arg; |
391 IDirectSoundBuffer_GetVolume(hdsbuf, &volume); | 392 IDirectSoundBuffer_GetVolume(hdsbuf, &volume); |
392 vol->left = vol->right = (float)(volume+10000) / 100.0; | 393 vol->left = vol->right = pow(10.0, (float)(volume+10000) / 5000.0); |
393 //printf("ao_dsound: volume: %f\n",vol->left); | 394 //printf("ao_dsound: volume: %f\n",vol->left); |
394 return CONTROL_OK; | 395 return CONTROL_OK; |
395 } | 396 } |
396 case AOCONTROL_SET_VOLUME: { | 397 case AOCONTROL_SET_VOLUME: { |
397 ao_control_vol_t* vol = (ao_control_vol_t*)arg; | 398 ao_control_vol_t* vol = (ao_control_vol_t*)arg; |
398 volume = (vol->right * 100.0)-10000; | 399 volume = (DWORD)(log10(vol->right) * 5000.0) - 10000; |
399 IDirectSoundBuffer_SetVolume(hdsbuf, volume); | 400 IDirectSoundBuffer_SetVolume(hdsbuf, volume); |
400 //printf("ao_dsound: volume: %f\n",vol->left); | 401 //printf("ao_dsound: volume: %f\n",vol->left); |
401 return CONTROL_OK; | 402 return CONTROL_OK; |
402 } | 403 } |
403 } | 404 } |