]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm: fix the snd_pcm_plugin_status() avail and delay fields
authorJaroslav Kysela <perex@perex.cz>
Fri, 9 Oct 2020 17:57:57 +0000 (19:57 +0200)
committerJaroslav Kysela <perex@perex.cz>
Fri, 9 Oct 2020 18:02:22 +0000 (20:02 +0200)
The avail and delay fields in the returned status structure does not
reflect the actual hw_ptr/appl_ptr. This change correct this.

TODO: Unfortunately, the delay might contain also information about
extra hardware / buffering delay which is hidden with this change.

Link: https://lore.kernel.org/alsa-devel/d9c1f37e-5c8d-f289-270e-c6cda7a56ce3@axis.com/
Reported-by: Jonas Holmberg <jonashg@axis.com>
Tested-by: Jonas Holmberg <jonashg@axis.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_plugin.c

index ea60eb98986ef85546e29c66c7e48b2fc952f567..5739cfc2eb072e1d6ea2d960d019e9a9894d50bc 100644 (file)
@@ -541,16 +541,20 @@ static snd_pcm_sframes_t snd_pcm_plugin_avail_update(snd_pcm_t *pcm)
 static int snd_pcm_plugin_status(snd_pcm_t *pcm, snd_pcm_status_t * status)
 {
        snd_pcm_plugin_t *plugin = pcm->private_data;
-       snd_pcm_sframes_t err;
+       snd_pcm_sframes_t err, avail;
 
        /* sync with the latest hw and appl ptrs */
-       snd_pcm_plugin_avail_update(pcm);
+       avail = snd_pcm_plugin_avail_update(pcm);
+       if (avail < 0)
+               return avail;
 
        err = snd_pcm_status(plugin->gen.slave, status);
        if (err < 0)
                return err;
        status->appl_ptr = *pcm->appl.ptr;
        status->hw_ptr = *pcm->hw.ptr;
+       status->avail = avail;
+       status->delay = snd_pcm_mmap_delay(pcm);
        return 0;
 }