]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: restore hw params on set latency failed
authorMartin Geier <martin.geier@streamunlimited.com>
Fri, 24 Jul 2015 07:30:57 +0000 (09:30 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 24 Jul 2015 16:19:37 +0000 (18:19 +0200)
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 <martin.geier@streamunlimited.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/pcm/pcm.c

index bae1d1653904f4c62665e4aed2292f586f083a62..f5fc728518d828433c6061a120c81ce4f2975d0c 100644 (file)
@@ -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);