]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: multi: return correct hwptr and avail from snd_pcm_multi_status()
authorYutao Yuan <infmagic2047reg@outlook.com>
Wed, 4 May 2022 03:01:34 +0000 (11:01 +0800)
committerJaroslav Kysela <perex@perex.cz>
Wed, 4 May 2022 13:44:04 +0000 (15:44 +0200)
Ensure the logic of snd_pcm_multi_status() is consistent with
snd_pcm_multi_avail_update().

Fixes: https://github.com/alsa-project/alsa-lib/pull/224
Fixes: https://github.com/alsa-project/alsa-lib/issues/217
Signed-off-by: Yutao Yuan <infmagic2047reg@outlook.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_multi.c

index 7fb212765a1e364e22e58a86366c70a63d5d2ce5..bec6d06fa4db535137d6dae348838079dcc91ea5 100644 (file)
@@ -388,11 +388,21 @@ static int snd_pcm_multi_sw_params(snd_pcm_t *pcm, snd_pcm_sw_params_t *params)
        return 0;
 }
 
+static snd_pcm_sframes_t snd_pcm_multi_avail_update(snd_pcm_t *pcm);
 static int snd_pcm_multi_status(snd_pcm_t *pcm, snd_pcm_status_t *status)
 {
        snd_pcm_multi_t *multi = pcm->private_data;
        snd_pcm_t *slave = multi->slaves[multi->master_slave].pcm;
-       return snd_pcm_status(slave, status);
+
+       int err = snd_pcm_status(slave, status);
+       if (err < 0)
+               return err;
+       snd_pcm_sframes_t avail = snd_pcm_multi_avail_update(pcm);
+       if (avail < 0)
+               return avail;
+       status->hw_ptr = *pcm->hw.ptr;
+       status->avail = avail;
+       return 0;
 }
 
 static snd_pcm_state_t snd_pcm_multi_state(snd_pcm_t *pcm)