[vlc-devel] [PATCH] Use soft gain by default to achieve 200% with directsound

Denis Charmet typx at dinauz.org
Tue Aug 13 22:52:23 CEST 2013


Since directsound doesn't support amplification, we use a default *2 soft gain and map DSBVOLUME_MAX to 200%.
---
 modules/audio_output/directx.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index 2f47c47..04dc919 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -331,11 +331,8 @@ static int VolumeSet( audio_output_t *p_aout, float volume )
     aout_sys_t *sys = p_aout->sys;
     int ret = 0;
 
-    /* Convert UI volume to linear factor (cube) */
-    float vol = volume * volume * volume;
-
-    /* millibels from linear amplification */
-    LONG mb = lroundf(2000.f * log10f(vol));
+    /* millibels from linear amplification map 200% on DSBVOLUME_MAX */
+    LONG mb = lroundf( 5000.f * log10f( volume / 2.f ));
 
     /* Clamp to allowed DirectSound range */
     static_assert( DSBVOLUME_MIN < DSBVOLUME_MAX, "DSBVOLUME_* confused" );
@@ -504,6 +501,7 @@ static int CreateDSBuffer( audio_output_t *p_aout, int i_format,
             waveformat.Format.wBitsPerSample;
         waveformat.Format.wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
         waveformat.SubFormat = _KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
+        aout_GainRequest(p_aout, 8.f);
         break;
 
     case VLC_CODEC_S16N:
@@ -512,6 +510,7 @@ static int CreateDSBuffer( audio_output_t *p_aout, int i_format,
             waveformat.Format.wBitsPerSample;
         waveformat.Format.wFormatTag = WAVE_FORMAT_PCM;
         waveformat.SubFormat = _KSDATAFORMAT_SUBTYPE_PCM;
+        aout_GainRequest(p_aout, 8.f);
         break;
     }
 
-- 
1.7.10.4




More information about the vlc-devel mailing list