pcm_plugin: fix delay

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>
This commit is contained in:
Pierre-Louis Bossart 2010-11-23 08:47:08 -06:00 committed by Jaroslav Kysela
parent a4f71b1940
commit aba87e5098

View 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); int err = snd_pcm_delay(plugin->gen.slave, &sd);
if (err < 0) if (err < 0)
return err; 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; *delayp = sd;
return 0; return 0;
} }