struct aout_sys_t
{
HINSTANCE hdsound_dll; /* handle of the opened dsound dll */
+
+ int i_device_id; /* user defined device */
+ LPGUID p_device_guid;
+
LPDIRECTSOUND p_dsobject; /* main Direct Sound object */
LPDIRECTSOUNDBUFFER p_dsbuffer; /* the sound buffer we use (direct sound
* takes care of mixing all the
/*****************************************************************************
* Module descriptor
*****************************************************************************/
+#define DEVICE_TEXT N_("Output device")
+#define DEVICE_LONGTEXT N_( \
+ "DirectX device number: 0 default device, 1..N device by number" \
+ "(Note that the default device appears as 0 AND another number)." )
+#define FLOAT_TEXT N_("Use float32 output")
+#define FLOAT_LONGTEXT N_( \
+ "The option allows you to enable or disable the high-quality float32 " \
+ "audio output mode (which is not well supported by some soundcards)." )
+
vlc_module_begin();
set_description( _("DirectX audio output") );
set_shortname( "DirectX" );
set_category( CAT_AUDIO );
set_subcategory( SUBCAT_AUDIO_AOUT );
add_shortcut( "directx" );
+ add_integer( "directx-audio-device", 0, NULL, DEVICE_TEXT,
+ DEVICE_LONGTEXT, VLC_TRUE );
+ add_bool( "directx-audio-float32", 1, 0, FLOAT_TEXT,
+ FLOAT_LONGTEXT, VLC_TRUE );
set_callbacks( OpenAudio, CloseAudio );
vlc_module_end();
p_aout->output.pf_play = Play;
aout_VolumeSoftInit( p_aout );
+ /* Retrieve config values */
+ var_Create( p_aout, "directx-audio-float32",
+ VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
+ var_Create( p_aout, "directx-audio-device",
+ VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
+ var_Get( p_aout, "directx-audio-device", &val );
+ p_aout->output.p_sys->i_device_id = val.i_int;
+ p_aout->output.p_sys->p_device_guid = 0;
+
/* Initialise DirectSound */
if( InitDirectSound( p_aout ) )
{
/* free DSOUND.DLL */
if( p_sys->hdsound_dll ) FreeLibrary( p_sys->hdsound_dll );
+ if( p_aout->output.p_sys->p_device_guid )
+ free( p_aout->output.p_sys->p_device_guid );
+
free( p_sys );
}
+/*****************************************************************************
+ * CallBackDirectSoundEnum: callback to enumerate available devices
+ *****************************************************************************/
+static int CALLBACK CallBackDirectSoundEnum( LPGUID p_guid, LPCSTR psz_desc,
+ LPCSTR psz_mod, LPVOID _p_aout )
+{
+ aout_instance_t *p_aout = (aout_instance_t *)_p_aout;
+
+ msg_Dbg( p_aout, "found device: %s", psz_desc );
+
+ if( p_aout->output.p_sys->i_device_id == 0 && p_guid )
+ {
+ p_aout->output.p_sys->p_device_guid = malloc( sizeof( GUID ) );
+ *p_aout->output.p_sys->p_device_guid = *p_guid;
+ msg_Dbg( p_aout, "using device: %s", psz_desc );
+ }
+
+ p_aout->output.p_sys->i_device_id--;
+ return 1;
+}
+
/*****************************************************************************
* InitDirectSound: handle all the gory details of DirectSound initialisation
*****************************************************************************/
static int InitDirectSound( aout_instance_t *p_aout )
{
HRESULT (WINAPI *OurDirectSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
+ HRESULT (WINAPI *OurDirectSoundEnumerate)(LPDSENUMCALLBACK, LPVOID);
p_aout->output.p_sys->hdsound_dll = LoadLibrary("DSOUND.DLL");
if( p_aout->output.p_sys->hdsound_dll == NULL )
goto error;
}
- OurDirectSoundCreate = (void *)GetProcAddress(
- p_aout->output.p_sys->hdsound_dll,
- "DirectSoundCreate" );
+ OurDirectSoundCreate = (void *)
+ GetProcAddress( p_aout->output.p_sys->hdsound_dll,
+ "DirectSoundCreate" );
if( OurDirectSoundCreate == NULL )
{
msg_Warn( p_aout, "GetProcAddress FAILED" );
goto error;
}
+ /* Get DirectSoundEnumerate */
+ OurDirectSoundEnumerate = (void *)
+ GetProcAddress( p_aout->output.p_sys->hdsound_dll,
+ "DirectSoundEnumerateA" );
+ if( OurDirectSoundEnumerate )
+ {
+ /* Attempt enumeration */
+ if( FAILED( OurDirectSoundEnumerate( CallBackDirectSoundEnum,
+ p_aout ) ) )
+ {
+ msg_Dbg( p_aout, "enumeration of DirectSound devices failed" );
+ }
+ }
+
/* Create the direct sound object */
- if FAILED( OurDirectSoundCreate( NULL, &p_aout->output.p_sys->p_dsobject,
+ if FAILED( OurDirectSoundCreate( p_aout->output.p_sys->p_device_guid,
+ &p_aout->output.p_sys->p_dsobject,
NULL ) )
{
msg_Warn( p_aout, "cannot create a direct sound device" );
int i_channels, int i_nb_channels, int i_rate,
vlc_bool_t b_probe )
{
+ vlc_value_t val;
+
+ var_Get( p_aout, "directx-audio-float32", &val );
+
/* Float32 audio samples are not supported for 5.1 output on the emu101k */
- if( i_nb_channels > 2 ||
+ if( !val.b_bool || i_nb_channels > 2 ||
CreateDSBuffer( p_aout, VLC_FOURCC('f','l','3','2'),
i_channels, i_nb_channels, i_rate,
FRAME_SIZE * 4 * i_nb_channels, b_probe )