]> git.sesse.net Git - vlc/commitdiff
* modules/audio_output/waveout.c: use hardware volume control.
authorGildas Bazin <gbazin@videolan.org>
Tue, 15 Mar 2005 13:38:28 +0000 (13:38 +0000)
committerGildas Bazin <gbazin@videolan.org>
Tue, 15 Mar 2005 13:38:28 +0000 (13:38 +0000)
modules/audio_output/waveout.c

index 278620f4bf852b61802c0b57f149252c6f1cc769..c1bf8a0c5c0a367166199e877f9e4a7b8dbba63b 100644 (file)
 #include <windows.h>
 #include <mmsystem.h>
 
-#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;
+}