]> git.alsa-project.org Git - alsa-lib.git/commitdiff
pcm_plugin: fix delay
authorPierre-Louis Bossart <pierre-louis.bossart@intel.com>
Tue, 23 Nov 2010 14:47:08 +0000 (08:47 -0600)
committerJaroslav Kysela <perex@perex.cz>
Tue, 23 Nov 2010 14:59:12 +0000 (15:59 +0100)
PulseAudio ALSA modules report errors after calling
snd_pcm_avail_delay(), with a delay lower than the number of samples
available.

Correct delay using Jaroslav's recommendation:
"the result should be 'delay(slave) + mmap_capture_avail(pcm)"

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@intel.com>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
src/pcm/pcm_plugin.c

index 19d0deef59aac36b798c7303e83d88f4bb80f615..d88e11782ac4147edd1643456d577f805b131cfd 100644 (file)
@@ -144,6 +144,12 @@ static int snd_pcm_plugin_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
        int err = snd_pcm_delay(plugin->gen.slave, &sd);
        if (err < 0)
                return err;
+        if (pcm->stream == SND_PCM_STREAM_CAPTURE &&
+           pcm->access != SND_PCM_ACCESS_RW_INTERLEAVED &&
+           pcm->access != SND_PCM_ACCESS_RW_NONINTERLEAVED) {
+                sd += snd_pcm_mmap_capture_avail(pcm);
+        }        
+
        *delayp = sd;
        return 0;
 }