+
+/*****************************************************************************
+ * CallBackConfigEnum: callback to add available devices to the preferences list
+ *****************************************************************************/
+static int CALLBACK CallBackConfigEnum( LPGUID p_guid, LPCSTR psz_desc,
+ LPCSTR psz_mod, LPVOID _p_item )
+{
+ VLC_UNUSED( psz_mod );
+ VLC_UNUSED( p_guid );
+
+ module_config_t *p_item = (module_config_t *) _p_item;
+
+ p_item->ppsz_list[p_item->i_list] = FromLocaleDup(psz_desc);
+ p_item->ppsz_list_text[p_item->i_list] = FromLocaleDup(psz_desc);
+ p_item->i_list = p_item->i_list +1;
+ return 1;
+}
+
+/*****************************************************************************
+ * ReloadDirectXDevices: store the list of devices in preferences
+ *****************************************************************************/
+static int ReloadDirectXDevices( 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;
+ for( i = 0; i < p_item->i_list; i++ )
+ {
+ free((char *)(p_item->ppsz_list[i]) );
+ free((char *)(p_item->ppsz_list_text[i]) );
+ }
+ }
+
+ HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACK, LPVOID);
+
+ HANDLE hdsound_dll = LoadLibrary("DSOUND.DLL");
+ if( hdsound_dll == NULL )
+ {
+ msg_Warn( p_this, "cannot open DSOUND.DLL" );
+ }
+
+ /* Get DirectSoundEnumerate */
+ OurDirectSoundEnumerate = (void *)
+ GetProcAddress( hdsound_dll,
+ "DirectSoundEnumerateA" );
+ int nb_devices = 0;
+ OurDirectSoundEnumerate(CallBackConfigNBEnum, &nb_devices);
+ msg_Dbg(p_this,"found %d devices", nb_devices);
+
+ p_item->ppsz_list = xrealloc( p_item->ppsz_list,
+ nb_devices * sizeof(char *) );
+ p_item->ppsz_list_text = xrealloc( p_item->ppsz_list_text,
+ nb_devices * sizeof(char *) );
+
+ p_item->i_list = 0;
+ OurDirectSoundEnumerate(CallBackConfigEnum, p_item);
+
+ FreeLibrary(hdsound_dll);
+
+ /* Signal change to the interface */
+ p_item->b_dirty = true;
+
+ return VLC_SUCCESS;
+}
+