From: Gildas Bazin Date: Tue, 15 Mar 2005 13:38:28 +0000 (+0000) Subject: * modules/audio_output/waveout.c: use hardware volume control. X-Git-Tag: 0.8.2~796 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=eb47e072b2bd1ffa5506c099698525b0a64f92fb;p=vlc * modules/audio_output/waveout.c: use hardware volume control. --- diff --git a/modules/audio_output/waveout.c b/modules/audio_output/waveout.c index 278620f4bf..c1bf8a0c5c 100644 --- a/modules/audio_output/waveout.c +++ b/modules/audio_output/waveout.c @@ -34,11 +34,7 @@ #include #include -#ifdef UNDER_CE -# define FRAME_SIZE 4096 /* The size is in samples, not in bytes */ -#else -# define FRAME_SIZE 1024 /* The size is in samples, not in bytes */ -#endif +#define FRAME_SIZE 4096 /* The size is in samples, not in bytes */ #define FRAMES_NUM 8 /***************************************************************************** @@ -127,6 +123,10 @@ static int PlayWaveOut ( aout_instance_t *, HWAVEOUT, WAVEHDR *, static void CALLBACK WaveOutCallback ( HWAVEOUT, UINT, DWORD, DWORD, DWORD ); static void WaveOutThread( notification_thread_t * ); +static int VolumeInfos( aout_instance_t *, audio_volume_t * ); +static int VolumeGet( aout_instance_t *, audio_volume_t * ); +static int VolumeSet( aout_instance_t *, audio_volume_t ); + /***************************************************************************** * Module descriptor *****************************************************************************/ @@ -291,6 +291,10 @@ static int Open( vlc_object_t *p_this ) p_aout->output.output.i_bytes_per_frame; aout_VolumeSoftInit( p_aout ); + + p_aout->output.pf_volume_infos = VolumeInfos; + p_aout->output.pf_volume_get = VolumeGet; + p_aout->output.pf_volume_set = VolumeSet; } @@ -778,3 +782,32 @@ static void WaveOutThread( notification_thread_t *p_notif ) } } } + +static int VolumeInfos( aout_instance_t * p_aout, audio_volume_t * pi_soft ) +{ + *pi_soft = AOUT_VOLUME_MAX / 2; + return 0; +} + +static int VolumeGet( aout_instance_t * p_aout, audio_volume_t * pi_volume ) +{ + aout_sys_t *p_sys = p_aout->output.p_sys; + DWORD i_waveout_vol; + + waveOutGetVolume( p_sys->h_waveout, &i_waveout_vol ); + i_waveout_vol &= 0xFFFF; + *pi_volume = p_aout->output.i_volume = + i_waveout_vol * AOUT_VOLUME_MAX / 2 / 0xFFFF; + return 0; +} + +static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume ) +{ + aout_sys_t *p_sys = p_aout->output.p_sys; + unsigned long i_waveout_vol = i_volume * 0xFFFF * 2 / AOUT_VOLUME_MAX; + i_waveout_vol |= (i_waveout_vol << 16); + + waveOutSetVolume( p_sys->h_waveout, i_waveout_vol ); + p_aout->output.i_volume = i_volume; + return 0; +}