+
+
+/*
+ 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 )
+{
+ VLC_UNUSED( newval ); VLC_UNUSED( oldval ); VLC_UNUSED( data );
+
+ 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 )
+ {
+ int i;
+
+ /* 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 = xrealloc( p_item->ppsz_list,
+ (wave_devices+2) * sizeof(char *) );
+ p_item->ppsz_list_text = xrealloc( 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;
+}