[vlc-commits] ALSA: do not overwrite output format until success is assured
Rémi Denis-Courmont
git at videolan.org
Mon Jul 25 19:06:12 CEST 2011
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 25 19:59:26 2011 +0300| [63b3578001a89218f6b26af4790135823a63193c] | committer: 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).
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=63b3578001a89218f6b26af4790135823a63193c
---
modules/audio_output/alsa.c | 16 ++++++++--------
1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/modules/audio_output/alsa.c b/modules/audio_output/alsa.c
index b2e0c22..01d439c 100644
--- a/modules/audio_output/alsa.c
+++ b/modules/audio_output/alsa.c
@@ -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;
More information about the vlc-commits
mailing list