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

ALSA: remove a few useless variables

Overwriting *fmt is safe nowadays.
parent 345a3e31
...@@ -318,10 +318,9 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -318,10 +318,9 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
return VLC_ENOMEM; return VLC_ENOMEM;
snd_pcm_format_t pcm_format; /* ALSA sample format */ snd_pcm_format_t pcm_format; /* ALSA sample format */
vlc_fourcc_t fourcc = fmt->i_format;
bool spdif = false; bool spdif = false;
switch (fourcc) switch (fmt->i_format)
{ {
case VLC_CODEC_F64B: case VLC_CODEC_F64B:
pcm_format = SND_PCM_FORMAT_FLOAT64_BE; pcm_format = SND_PCM_FORMAT_FLOAT64_BE;
...@@ -376,18 +375,18 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -376,18 +375,18 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
spdif = var_InheritBool (aout, "spdif"); spdif = var_InheritBool (aout, "spdif");
if (spdif) if (spdif)
{ {
fourcc = VLC_CODEC_SPDIFL; fmt->i_format = VLC_CODEC_SPDIFL;
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
} }
else else
if (HAVE_FPU) if (HAVE_FPU)
{ {
fourcc = VLC_CODEC_FL32; fmt->i_format = VLC_CODEC_FL32;
pcm_format = SND_PCM_FORMAT_FLOAT; pcm_format = SND_PCM_FORMAT_FLOAT;
} }
else else
{ {
fourcc = VLC_CODEC_S16N; fmt->i_format = VLC_CODEC_S16N;
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
} }
} }
...@@ -473,19 +472,19 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -473,19 +472,19 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
else else
if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_FLOAT) == 0) if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_FLOAT) == 0)
{ {
fourcc = VLC_CODEC_FL32; fmt->i_format = VLC_CODEC_FL32;
pcm_format = SND_PCM_FORMAT_FLOAT; pcm_format = SND_PCM_FORMAT_FLOAT;
} }
else else
if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_S32) == 0) if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_S32) == 0)
{ {
fourcc = VLC_CODEC_S32N; fmt->i_format = VLC_CODEC_S32N;
pcm_format = SND_PCM_FORMAT_S32; pcm_format = SND_PCM_FORMAT_S32;
} }
else else
if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_S16) == 0) if (snd_pcm_hw_params_test_format (pcm, hw, SND_PCM_FORMAT_S16) == 0)
{ {
fourcc = VLC_CODEC_S16N; fmt->i_format = VLC_CODEC_S16N;
pcm_format = SND_PCM_FORMAT_S16; pcm_format = SND_PCM_FORMAT_S16;
} }
else else
...@@ -526,15 +525,13 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -526,15 +525,13 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
} }
/* Set sample rate */ /* Set sample rate */
unsigned rate = fmt->i_rate; val = snd_pcm_hw_params_set_rate_near (pcm, hw, &fmt->i_rate, NULL);
val = snd_pcm_hw_params_set_rate_near (pcm, hw, &rate, NULL);
if (val) if (val)
{ {
msg_Err (aout, "cannot set sample rate: %s", snd_strerror (val)); msg_Err (aout, "cannot set sample rate: %s", snd_strerror (val));
goto error; goto error;
} }
if (fmt->i_rate != rate) sys->rate = fmt->i_rate;
msg_Dbg (aout, "resampling from %d Hz to %d Hz", fmt->i_rate, rate);
/* Set buffer size */ /* Set buffer size */
param = AOUT_MAX_ADVANCE_TIME; param = AOUT_MAX_ADVANCE_TIME;
...@@ -610,9 +607,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt) ...@@ -610,9 +607,6 @@ static int Start (audio_output_t *aout, audio_sample_format_t *restrict fmt)
} }
/* Setup audio_output_t */ /* Setup audio_output_t */
fmt->i_format = fourcc;
fmt->i_rate = rate;
sys->rate = rate;
if (spdif) if (spdif)
{ {
fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE; fmt->i_bytes_per_frame = AOUT_SPDIF_SIZE;
......
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