From: Martin Geier Date: Fri, 24 Jul 2015 07:30:57 +0000 (+0200) Subject: pcm: restore hw params on set latency failed X-Git-Tag: v1.1.0~56 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=77b6be63876ee46a95320e77735d977edeedd44a;p=alsa-lib.git pcm: restore hw params on set latency failed When method snd_pcm_set_params sets sample rate to 22050 and latency to 50000 to davinci soc driver method snd_pcm_hw_params_set_buffer_time_near fails and variable params is already changed in the method so the next method snd_pcm_hw_params_set_period_time_near fails also. Signed-off-by: Martin Geier Signed-off-by: Takashi Iwai --- diff --git a/src/pcm/pcm.c b/src/pcm/pcm.c index bae1d165..f5fc7285 100644 --- a/src/pcm/pcm.c +++ b/src/pcm/pcm.c @@ -8004,7 +8004,7 @@ int snd_pcm_set_params(snd_pcm_t *pcm, int soft_resample, unsigned int latency) { - snd_pcm_hw_params_t *params; + snd_pcm_hw_params_t *params, params_saved; snd_pcm_sw_params_t *swparams; const char *s = snd_pcm_stream_name(snd_pcm_stream(pcm)); snd_pcm_uframes_t buffer_size, period_size; @@ -8057,9 +8057,11 @@ int snd_pcm_set_params(snd_pcm_t *pcm, return -EINVAL; } /* set the buffer time */ + params_saved = *params; err = INTERNAL(snd_pcm_hw_params_set_buffer_time_near)(pcm, params, &latency, NULL); if (err < 0) { /* error path -> set period size as first */ + *params = params_saved; /* set the period time */ period_time = latency / 4; err = INTERNAL(snd_pcm_hw_params_set_period_time_near)(pcm, params, &period_time, NULL);