+
+#undef waveout_warn
+}
+
+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 )
+{
+ DWORD i_waveout_vol;
+
+#ifdef UNDER_CE
+ waveOutGetVolume( 0, &i_waveout_vol );
+#else
+ waveOutGetVolume( p_aout->output.p_sys->h_waveout, &i_waveout_vol );
+#endif
+
+ i_waveout_vol &= 0xFFFF;
+ *pi_volume = p_aout->output.i_volume =
+ (i_waveout_vol * AOUT_VOLUME_MAX + 0xFFFF /*rounding*/) / 2 / 0xFFFF;
+ return 0;
+}
+
+static int VolumeSet( aout_instance_t * p_aout, audio_volume_t i_volume )
+{
+ unsigned long i_waveout_vol = i_volume * 0xFFFF * 2 / AOUT_VOLUME_MAX;
+ i_waveout_vol |= (i_waveout_vol << 16);
+
+#ifdef UNDER_CE
+ waveOutSetVolume( 0, i_waveout_vol );
+#else
+ waveOutSetVolume( p_aout->output.p_sys->h_waveout, i_waveout_vol );
+#endif
+
+ p_aout->output.i_volume = i_volume;
+ return 0;
+}
+
+
+/*
+ reload the configuration drop down list, of the Audio Devices
+*/
+static int ReloadWaveoutDevices( vlc_object_t *p_this, char const *psz_name,
+ vlc_value_t newval, vlc_value_t oldval, void *data )
+{
+ int i;
+
+ module_config_t *p_item = config_FindConfig( p_this, psz_name );
+ if( !p_item ) return VLC_SUCCESS;
+
+ /* Clear-up the current list */
+ if( p_item->i_list )
+ {
+ /* Keep the first entry */
+ for( i = 1; i < p_item->i_list; i++ )
+ {
+ free((char *)(p_item->ppsz_list[i]) );
+ free((char *)(p_item->ppsz_list_text[i]) );
+ }
+ /* TODO: Remove when no more needed */
+ p_item->ppsz_list[i] = NULL;
+ p_item->ppsz_list_text[i] = NULL;
+ }
+ p_item->i_list = 1;
+
+ int wave_devices = waveOutGetNumDevs();
+
+ p_item->ppsz_list =
+ (char **)realloc( p_item->ppsz_list,
+ (wave_devices+2) * sizeof(char *) );
+ p_item->ppsz_list_text =
+ (char **)realloc( p_item->ppsz_list_text,
+ (wave_devices+2) * sizeof(char *) );
+
+ WAVEOUTCAPS caps;
+ char sz_dev_name[MAXPNAMELEN+32];
+ int j=1;
+ for(int i=0; i<wave_devices; i++)
+ {
+ if(waveOutGetDevCaps(i, &caps, sizeof(WAVEOUTCAPS))
+ == MMSYSERR_NOERROR)
+ {
+ sprintf( sz_dev_name, psz_device_name_fmt, caps.szPname,
+ caps.wMid,
+ caps.wPid
+ );
+ p_item->ppsz_list[j] = FromLocaleDup( sz_dev_name );
+ p_item->ppsz_list_text[j] = FromLocaleDup( sz_dev_name );
+ p_item->i_list++;
+ j++;
+ }
+
+ }
+ p_item->ppsz_list[j] = NULL;
+ p_item->ppsz_list_text[j] = NULL;
+
+ /* Signal change to the interface */
+ p_item->b_dirty = true;
+
+ return VLC_SUCCESS;
+}
+
+/*
+ convert devicename to device ID for output
+ if device not found return WAVE_MAPPER, so let
+ windows decide which preferred audio device
+ should be used.
+*/
+static uint32_t findDeviceID(char *psz_device_name)
+{
+ if(!psz_device_name)
+ return WAVE_MAPPER;
+
+ uint32_t wave_devices = waveOutGetNumDevs();
+ WAVEOUTCAPS caps;
+ char sz_dev_name[MAXPNAMELEN+32];
+ for(uint32_t i=0; i<wave_devices; i++)
+ {
+ if(waveOutGetDevCaps(i, &caps, sizeof(WAVEOUTCAPS))
+ == MMSYSERR_NOERROR)
+ {
+ sprintf(sz_dev_name, psz_device_name_fmt, caps.szPname,
+ caps.wMid,
+ caps.wPid
+ );
+ char *psz_temp = FromLocaleDup(sz_dev_name);
+
+ if( !stricmp(psz_temp, psz_device_name) )
+ {
+ LocaleFree( psz_temp );
+ return i;
+ }
+ LocaleFree( psz_temp );
+ }
+ }
+
+ return WAVE_MAPPER;