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

DirectSound: do not clobber channels before trying pass-through

parent 800f1905
...@@ -182,14 +182,28 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -182,14 +182,28 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
goto error; goto error;
} }
if ( AOUT_FMT_SPDIF( fmt ) && var_InheritBool( p_aout, "spdif" )
&& CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL, fmt->i_physical_channels,
aout_FormatNbChannels( fmt ), fmt->i_rate, true )
== VLC_SUCCESS )
{
msg_Dbg( p_aout, "using A/52 pass-through over S/PDIF" );
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;
}
else
{
if( i == 0 ) if( i == 0 )
{ {
DWORD ui_speaker_config; DWORD ui_speaker_config;
int i_channels = 2; /* Default to stereo */ int i_channels = 2; /* Default to stereo */
int i_orig_channels = aout_FormatNbChannels( fmt ); int i_orig_channels = aout_FormatNbChannels( fmt );
/* Check the speaker configuration to determine which channel config /* Check the speaker configuration to determine which channel
* should be the default */ * config should be the default */
if( FAILED( IDirectSound_GetSpeakerConfig( p_aout->sys->p_dsobject, if( FAILED( IDirectSound_GetSpeakerConfig( p_aout->sys->p_dsobject,
&ui_speaker_config ) ) ) &ui_speaker_config ) ) )
{ {
...@@ -218,7 +232,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -218,7 +232,7 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
* 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:
name = "Mono"; name = "Mono";
fmt->i_physical_channels = AOUT_CHAN_CENTER; i_channels = 1;
break; break;
#endif #endif
case DSSPEAKER_SURROUND: case DSSPEAKER_SURROUND:
...@@ -231,10 +245,12 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -231,10 +245,12 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
break; break;
} }
i_channels = ( i_channels < i_orig_channels )? i_channels: i_orig_channels; if( i_channels >= i_orig_channels )
i_channels = i_orig_channels;
msg_Dbg( p_aout, "%s speaker config: %s and stream has %d channels, using %d channels", msg_Dbg( p_aout, "%s speaker config: %s and stream has "
"Windows", name, i_orig_channels, i_channels ); "%d channels, using %d channels", "Windows", name,
i_orig_channels, i_channels );
switch( i_channels ) switch( i_channels )
{ {
...@@ -284,21 +300,6 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt ) ...@@ -284,21 +300,6 @@ static int Start( audio_output_t *p_aout, audio_sample_format_t *restrict fmt )
} }
/* Open the device */ /* Open the device */
if ( AOUT_FMT_SPDIF( fmt )
&& var_InheritBool( p_aout, "spdif" )
&& CreateDSBuffer( p_aout, VLC_CODEC_SPDIFL, fmt->i_physical_channels,
aout_FormatNbChannels( fmt ), fmt->i_rate, true )
== VLC_SUCCESS )
{
msg_Dbg( p_aout, "using A/52 pass-through over S/PDIF" );
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;
}
else
{
aout_FormatPrepare( fmt ); aout_FormatPrepare( fmt );
if( CreateDSBufferPCM( p_aout, &fmt->i_format, if( CreateDSBufferPCM( p_aout, &fmt->i_format,
......
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