Commit 1fce1ba8 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

DirectSound: remove "audio-device" variable and simplify accordingly

parent be54e5fb
...@@ -67,8 +67,6 @@ struct aout_sys_t ...@@ -67,8 +67,6 @@ struct aout_sys_t
int i_bytes_per_sample; /* Size in bytes of one frame */ int i_bytes_per_sample; /* Size in bytes of one frame */
int i_rate; /* Sample rate */ int i_rate; /* Sample rate */
int i_speaker_setup; /* Speaker setup override */
uint8_t chans_to_reorder; /* do we need channel reordering */ uint8_t chans_to_reorder; /* do we need channel reordering */
uint8_t chan_table[AOUT_CHAN_MAX]; uint8_t chan_table[AOUT_CHAN_MAX];
uint32_t i_channel_mask; uint32_t i_channel_mask;
...@@ -91,7 +89,6 @@ static void Pause( audio_output_t *, bool, mtime_t ); ...@@ -91,7 +89,6 @@ static void Pause( audio_output_t *, bool, mtime_t );
static int TimeGet( audio_output_t *, mtime_t *); static int TimeGet( audio_output_t *, mtime_t *);
/* local functions */ /* local functions */
static void Probe( audio_output_t *, const audio_sample_format_t * );
static int InitDirectSound ( audio_output_t * ); static int InitDirectSound ( audio_output_t * );
static int CreateDSBuffer ( audio_output_t *, int, int, int, int, bool ); static int CreateDSBuffer ( audio_output_t *, int, int, int, int, bool );
static int CreateDSBufferPCM ( audio_output_t *, vlc_fourcc_t*, int, int, bool ); static int CreateDSBufferPCM ( audio_output_t *, vlc_fourcc_t*, int, int, bool );
...@@ -149,7 +146,6 @@ vlc_module_end () ...@@ -149,7 +146,6 @@ vlc_module_end ()
*****************************************************************************/ *****************************************************************************/
static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
{ {
vlc_value_t val;
char * psz_speaker; char * psz_speaker;
int i = 0; int i = 0;
...@@ -178,7 +174,6 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -178,7 +174,6 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
i = 0; i = 0;
} }
free( psz_speaker ); free( psz_speaker );
p_aout->sys->i_speaker_setup = i;
/* Initialise DirectSound */ /* Initialise DirectSound */
if( InitDirectSound( p_aout ) ) if( InitDirectSound( p_aout ) )
...@@ -187,174 +182,125 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -187,174 +182,125 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
goto error; goto error;
} }
if( var_Type( p_aout, "audio-device" ) == 0 ) if( i == 0 )
{
Probe( p_aout, fmt );
}
if( var_Get( p_aout, "audio-device", &val ) < 0 )
{ {
msg_Err( p_aout, "DirectSound Probe failed()" );
goto error;
}
/* Open the device */
if( val.i_int == AOUT_VAR_SPDIF )
{
fmt->i_format = VLC_CODEC_SPDIFL;
/* Calculate the frame size in bytes */
fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
fmt->i_frame_length = A52_FRAME_NB;
if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL,
fmt->i_physical_channels,
aout_FormatNbChannels( fmt ), fmt->i_rate, false )
!= VLC_SUCCESS )
{
msg_Err( p_aout, "cannot open directx audio device" );
goto error;
}
}
else
{
if( val.i_int == AOUT_VAR_5_1 )
fmt->i_physical_channels = AOUT_CHANS_5_0;
else if( val.i_int == AOUT_VAR_7_1 )
fmt->i_physical_channels = AOUT_CHANS_7_1;
else if( val.i_int == AOUT_VAR_3F2R )
fmt->i_physical_channels = AOUT_CHANS_5_0;
else if( val.i_int == AOUT_VAR_2F2R )
fmt->i_physical_channels = AOUT_CHANS_4_0;
else if( val.i_int == AOUT_VAR_MONO )
fmt->i_physical_channels = AOUT_CHAN_CENTER;
else
fmt->i_physical_channels = AOUT_CHANS_2_0;
aout_FormatPrepare( fmt );
if( CreateDSBufferPCM( p_aout, &fmt->i_format,
fmt->i_physical_channels, fmt->i_rate, false )
!= VLC_SUCCESS )
{
msg_Err( p_aout, "cannot open directx audio device" );
goto error;
}
}
p_aout->sys->i_write = 0;
/* Force volume update */
VolumeSet( p_aout, p_aout->sys->volume.volume );
MuteSet( p_aout, p_aout->sys->volume.mute );
/* then launch the notification thread */
p_aout->time_get = TimeGet;
p_aout->play = Play;
p_aout->pause = Pause;
p_aout->flush = Flush;
return VLC_SUCCESS;
error:
Stop( p_aout );
return VLC_EGENERIC;
}
/*****************************************************************************
* Probe: probe the audio device for available formats and channels
*****************************************************************************/
static void Probe( audio_output_t * p_aout, const audio_sample_format_t *fmt )
{
vlc_value_t val;
DWORD ui_speaker_config; DWORD ui_speaker_config;
var_Create( p_aout, "audio-device", VLC_VAR_INTEGER | VLC_VAR_HASCHOICE ); /* Check the speaker configuration to determine which channel config
* should be the default */
/* Check the speaker configuration to determine which channel config should if( FAILED( IDirectSound_GetSpeakerConfig( p_aout->sys->p_dsobject,
* be the default */ &ui_speaker_config ) ) )
if FAILED( IDirectSound_GetSpeakerConfig( p_aout->sys->p_dsobject,
&ui_speaker_config ) )
{ {
ui_speaker_config = DSSPEAKER_STEREO; ui_speaker_config = DSSPEAKER_STEREO;
msg_Dbg( p_aout, "GetSpeakerConfig failed" ); msg_Dbg( p_aout, "GetSpeakerConfig failed" );
} }
fmt->i_physical_channels = AOUT_CHANS_2_0;
const char *name = "Unknown";
switch( DSSPEAKER_CONFIG(ui_speaker_config) ) switch( DSSPEAKER_CONFIG(ui_speaker_config) )
{ {
case DSSPEAKER_7POINT1: case DSSPEAKER_7POINT1:
case DSSPEAKER_7POINT1_SURROUND: case DSSPEAKER_7POINT1_SURROUND:
msg_Dbg( p_aout, "Windows says your SpeakerConfig is 7.1" ); name = "7.1";
val.i_int = AOUT_VAR_7_1; fmt->i_physical_channels = AOUT_CHANS_7_1;
break; break;
case DSSPEAKER_5POINT1: case DSSPEAKER_5POINT1:
case DSSPEAKER_5POINT1_SURROUND: case DSSPEAKER_5POINT1_SURROUND:
msg_Dbg( p_aout, "Windows says your SpeakerConfig is 5.1" ); name = "5.1";
val.i_int = AOUT_VAR_5_1; fmt->i_physical_channels = AOUT_CHANS_5_1;
break; break;
case DSSPEAKER_QUAD: case DSSPEAKER_QUAD:
msg_Dbg( p_aout, "Windows says your SpeakerConfig is Quad" ); name = "Quad";
val.i_int = AOUT_VAR_2F2R; fmt->i_physical_channels = AOUT_CHANS_4_0;
break; break;
#if 0 /* Lots of people just get their settings wrong and complain that #if 0 /* Lots of people just get their settings wrong and complain that
* this is a problem with VLC so just don't ever set mono by default. */ * this is a problem with VLC so just don't ever set mono by default. */
case DSSPEAKER_MONO: case DSSPEAKER_MONO:
val.i_int = AOUT_VAR_MONO; name = "Mono";
fmt->i_physical_channels = AOUT_CHAN_CENTER;
break; break;
#endif #endif
case DSSPEAKER_SURROUND: case DSSPEAKER_SURROUND: /* XXX: stereo, really? -- Courmisch */
msg_Dbg( p_aout, "Windows says your SpeakerConfig is surround" ); name = "Surround";
break;
case DSSPEAKER_STEREO: case DSSPEAKER_STEREO:
msg_Dbg( p_aout, "Windows says your SpeakerConfig is stereo" ); name = "Stereo";
default:
/* If nothing else is found, choose stereo output */
val.i_int = AOUT_VAR_STEREO;
break; break;
} }
msg_Dbg( p_aout, "%s speaker config: %s", "Windows", name );
/* Check if we want to override speaker config */ }
switch( p_aout->sys->i_speaker_setup ) else
{ /* Overriden speaker configuration */
const char *name = "Non-existant";
switch( i )
{ {
case 0: /* Default value aka Windows default speaker setup */
break;
case 1: /* Mono */ case 1: /* Mono */
msg_Dbg( p_aout, "SpeakerConfig is forced to Mono" ); name = "Mono";
val.i_int = AOUT_VAR_MONO; fmt->i_physical_channels = AOUT_CHAN_CENTER;
break; break;
case 2: /* Stereo */ case 2: /* Stereo */
msg_Dbg( p_aout, "SpeakerConfig is forced to Stereo" ); name = "Stereo";
val.i_int = AOUT_VAR_STEREO; fmt->i_physical_channels = AOUT_CHANS_2_0;
break; break;
case 3: /* Quad */ case 3: /* Quad */
msg_Dbg( p_aout, "SpeakerConfig is forced to Quad" ); name = "Quad";
val.i_int = AOUT_VAR_2F2R; fmt->i_physical_channels = AOUT_CHANS_4_0;
break; break;
case 4: /* 5.1 */ case 4: /* 5.1 */
msg_Dbg( p_aout, "SpeakerConfig is forced to 5.1" ); name = "5.1";
val.i_int = AOUT_VAR_5_1; fmt->i_physical_channels = AOUT_CHANS_5_1;
break; break;
case 5: /* 7.1 */ case 5: /* 7.1 */
msg_Dbg( p_aout, "SpeakerConfig is forced to 7.1" ); name = "7.1";
val.i_int = AOUT_VAR_7_1; fmt->i_physical_channels = AOUT_CHANS_7_1;
break;
default:
msg_Dbg( p_aout, "SpeakerConfig is forced to non-existing value" );
break; break;
} }
msg_Dbg( p_aout, "%s speaker config: %s", "VLC", name );
}
var_Set( p_aout, "audio-device", val ); /* Open the device */
if ( AOUT_FMT_SPDIF( fmt )
/* Test for SPDIF support */ && var_InheritBool( p_aout, "spdif" )
if ( AOUT_FMT_SPDIF( fmt ) ) && CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL, fmt->i_physical_channels,
{
if( CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL,
fmt->i_physical_channels,
aout_FormatNbChannels( fmt ), fmt->i_rate, true ) aout_FormatNbChannels( fmt ), fmt->i_rate, true )
== VLC_SUCCESS ) == VLC_SUCCESS )
{ {
msg_Dbg( p_aout, "device supports A/52 over S/PDIF" ); msg_Dbg( p_aout, "using A/52 pass-through over S/PDIF" );
if( var_InheritBool( p_aout, "spdif" ) ) fmt->i_format = VLC_CODEC_SPDIFL;
var_Set( p_aout, "audio-device", val );
/* Calculate the frame size in bytes */
fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
fmt->i_frame_length = A52_FRAME_NB;
}
else
{
aout_FormatPrepare( fmt );
if( CreateDSBufferPCM( p_aout, &fmt->i_format,
fmt->i_physical_channels, fmt->i_rate, false )
!= VLC_SUCCESS )
{
msg_Err( p_aout, "cannot open directx audio device" );
goto error;
} }
} }
p_aout->sys->i_write = 0;
/* Force volume update */
VolumeSet( p_aout, p_aout->sys->volume.volume );
MuteSet( p_aout, p_aout->sys->volume.mute );
/* then launch the notification thread */
p_aout->time_get = TimeGet;
p_aout->play = Play;
p_aout->pause = Pause;
p_aout->flush = Flush;
return VLC_SUCCESS;
error:
Stop( p_aout );
return VLC_EGENERIC;
} }
/***************************************************************************** /*****************************************************************************
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment