From 609de236a9e2bf64407fa447c32d2cc1262d1727 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 2 Nov 2015 23:58:27 +0100 Subject: ao_alsa: disable resampling first thing Again, this could have bad access, is unlikely, and has no bad consequences. It's noteworthy that vlc and the ALSA PCM example both do this first, even if they set the sample rate later. --- audio/out/ao_alsa.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'audio/out/ao_alsa.c') diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c index bae7def017..9f297bbade 100644 --- a/audio/out/ao_alsa.c +++ b/audio/out/ao_alsa.c @@ -479,6 +479,13 @@ static int init_device(struct ao *ao, bool second_try) err = snd_pcm_hw_params_any(p->alsa, alsa_hwparams); CHECK_ALSA_ERROR("Unable to get initial parameters"); + // Some ALSA drivers have broken delay reporting, so disable the ALSA + // resampling plugin by default. + if (!p->cfg_resample) { + err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0); + CHECK_ALSA_ERROR("Unable to disable resampling"); + } + snd_pcm_access_t access = af_fmt_is_planar(ao->format) ? SND_PCM_ACCESS_RW_NONINTERLEAVED : SND_PCM_ACCESS_RW_INTERLEAVED; @@ -537,13 +544,6 @@ static int init_device(struct ao *ao, bool second_try) goto alsa_error; } - // Some ALSA drivers have broken delay reporting, so disable the ALSA - // resampling plugin by default. - if (!p->cfg_resample) { - err = snd_pcm_hw_params_set_rate_resample(p->alsa, alsa_hwparams, 0); - CHECK_ALSA_ERROR("Unable to disable resampling"); - } - err = snd_pcm_hw_params_set_rate_near (p->alsa, alsa_hwparams, &ao->samplerate, NULL); CHECK_ALSA_ERROR("Unable to set samplerate-2"); -- cgit v1.2.3