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

ALSA: do not overwrite output format until success is assured

Otherwise the next probed plugin would get a potentially corrupted
input format. This bug may affect other audio output plugins and
similarly even some video outptu display plugins (not checked yet).
parent 2188759b
......@@ -391,8 +391,6 @@ static int Open (vlc_object_t *obj)
goto error;
}
p_aout->format.i_format = fourcc;
val = snd_pcm_hw_params_set_access( p_sys->p_snd_pcm, p_hw,
SND_PCM_ACCESS_RW_INTERLEAVED );
if( val < 0 )
......@@ -412,9 +410,8 @@ static int Open (vlc_object_t *obj)
}
/* Set rate. */
unsigned old_rate = p_aout->format.i_rate;
val = snd_pcm_hw_params_set_rate_near (p_sys->p_snd_pcm, p_hw,
&p_aout->format.i_rate,
unsigned rate = p_aout->format.i_rate;
val = snd_pcm_hw_params_set_rate_near (p_sys->p_snd_pcm, p_hw, &rate,
NULL);
if (val < 0)
{
......@@ -422,9 +419,9 @@ static int Open (vlc_object_t *obj)
snd_strerror (val));
goto error;
}
if (p_aout->format.i_rate != old_rate)
msg_Warn (p_aout, "resampling from %d Hz to %d Hz", old_rate,
p_aout->format.i_rate);
if (p_aout->format.i_rate != rate)
msg_Warn (p_aout, "resampling from %d Hz to %d Hz",
p_aout->format.i_rate, rate);
/* Set period size. */
val = snd_pcm_hw_params_set_period_size_near( p_sys->p_snd_pcm, p_hw,
......@@ -507,6 +504,9 @@ static int Open (vlc_object_t *obj)
goto error;
}
p_aout->format.i_format = fourcc;
p_aout->format.i_rate = rate;
Probe (obj);
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