+
+
+/*
+ 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] = strdup( 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 = VLC_TRUE;
+
+ return VLC_SUCCESS;
+}
+
+/*
+ convert devicename to device ID for output
+ if device not found return WAVE_MAPPER, so let
+ windows decide which prefered 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
+ );
+ if(!stricmp(sz_dev_name,psz_device_name))
+ return i;
+ }
+ }
+
+ return WAVE_MAPPER;
+}