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

ALSA: avoid broken libasound channels remapping (fix #5122)

parent 63b35780
...@@ -136,6 +136,8 @@ vlc_module_end () ...@@ -136,6 +136,8 @@ vlc_module_end ()
/* VLC will insert a resampling filter in any case, so it is best to turn off /* VLC will insert a resampling filter in any case, so it is best to turn off
* ALSA (plug) resampling. */ * ALSA (plug) resampling. */
static const int mode = SND_PCM_NO_AUTO_RESAMPLE static const int mode = SND_PCM_NO_AUTO_RESAMPLE
/* ALSA just discards extra channels. Not good. Disable it. */
| SND_PCM_NO_AUTO_CHANNELS
/* VLC is currently unable to leverage ALSA softvol. Disable it. */ /* VLC is currently unable to leverage ALSA softvol. Disable it. */
| SND_PCM_NO_SOFTVOL; | SND_PCM_NO_SOFTVOL;
...@@ -340,14 +342,14 @@ static int Open (vlc_object_t *obj) ...@@ -340,14 +342,14 @@ static int Open (vlc_object_t *obj)
snd_pcm_uframes_t i_buffer_size; snd_pcm_uframes_t i_buffer_size;
snd_pcm_uframes_t i_period_size; snd_pcm_uframes_t i_period_size;
int i_channels; unsigned channels;
if (spdif) if (spdif)
{ {
fourcc = VLC_CODEC_SPDIFL; fourcc = VLC_CODEC_SPDIFL;
i_buffer_size = ALSA_SPDIF_BUFFER_SIZE; i_buffer_size = ALSA_SPDIF_BUFFER_SIZE;
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
i_channels = 2; channels = 2;
p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE; p_aout->i_nb_samples = i_period_size = ALSA_SPDIF_PERIOD_SIZE;
p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE; p_aout->format.i_bytes_per_frame = AOUT_SPDIF_SIZE;
...@@ -358,7 +360,7 @@ static int Open (vlc_object_t *obj) ...@@ -358,7 +360,7 @@ static int Open (vlc_object_t *obj)
else else
{ {
i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE; i_buffer_size = ALSA_DEFAULT_BUFFER_SIZE;
i_channels = aout_FormatNbChannels( &p_aout->format ); channels = aout_FormatNbChannels( &p_aout->format );
p_aout->i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE; p_aout->i_nb_samples = i_period_size = ALSA_DEFAULT_PERIOD_SIZE;
...@@ -401,8 +403,13 @@ static int Open (vlc_object_t *obj) ...@@ -401,8 +403,13 @@ static int Open (vlc_object_t *obj)
} }
/* Set channels. */ /* Set channels. */
val = snd_pcm_hw_params_set_channels( p_sys->p_snd_pcm, p_hw, i_channels ); val = snd_pcm_hw_params_set_channels (p_sys->p_snd_pcm, p_hw, channels);
if( val < 0 ) if (val < 0 && channels > 2) /* Fallback to stereo */
{
val = snd_pcm_hw_params_set_channels (p_sys->p_snd_pcm, p_hw, 2);
channels = 2;
}
if (val < 0)
{ {
msg_Err( p_aout, "unable to set number of output channels (%s)", msg_Err( p_aout, "unable to set number of output channels (%s)",
snd_strerror( val ) ); snd_strerror( val ) );
...@@ -506,6 +513,8 @@ static int Open (vlc_object_t *obj) ...@@ -506,6 +513,8 @@ static int Open (vlc_object_t *obj)
p_aout->format.i_format = fourcc; p_aout->format.i_format = fourcc;
p_aout->format.i_rate = rate; p_aout->format.i_rate = rate;
if (channels == 2)
p_aout->format.i_physical_channels = AOUT_CHAN_LEFT|AOUT_CHAN_RIGHT;
Probe (obj); Probe (obj);
return 0; return 0;
......
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