[vlc-commits] directsound: use software gain only when amplifying
Pierre Ynard
git at videolan.org
Sun Sep 22 10:08:56 CEST 2013
vlc/vlc-2.1 | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sun Sep 22 10:06:09 2013 +0200| [b550d447dde2e8c9025f92f3e98c5cacade7daf6] | committer: Pierre Ynard
directsound: use software gain only when amplifying
This way we get the features of both worlds: from 0% to 100% you
get quick volume change with no saturation, and you can still get
amplification over 100%.
Fixes #9371
(cherry picked from commit 9b2c48deeb04fa8c3005900bd8f285b50e20539d)
Signed-off-by: Pierre Ynard <linkfanel at yahoo.fr>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.1.git/?a=commit;h=b550d447dde2e8c9025f92f3e98c5cacade7daf6
---
modules/audio_output/directx.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/modules/audio_output/directx.c b/modules/audio_output/directx.c
index 55b54f5..8582942 100644
--- a/modules/audio_output/directx.c
+++ b/modules/audio_output/directx.c
@@ -356,8 +356,13 @@ static int VolumeSet( audio_output_t *p_aout, float volume )
aout_sys_t *sys = p_aout->sys;
int ret = 0;
- /* millibels from linear amplification map 200% on DSBVOLUME_MAX */
- LONG mb = lroundf( 6000.f * log10f( volume / 2.f ));
+ /* Directsound doesn't support amplification, so we use software
+ gain if we need it and only for this */
+ float gain = volume > 1.f ? volume * volume * volume : 1.f;
+ aout_GainRequest( p_aout, gain );
+
+ /* millibels from linear amplification */
+ LONG mb = lroundf( 6000.f * log10f( __MIN( volume, 1.f ) ));
/* Clamp to allowed DirectSound range */
static_assert( DSBVOLUME_MIN < DSBVOLUME_MAX, "DSBVOLUME_* confused" );
@@ -527,7 +532,6 @@ 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:
@@ -536,7 +540,6 @@ 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;
}
More information about the vlc-commits
mailing list