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>
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;
}