Allow ioplugins to override snd_pcm_delay()

Some io plug-ins might want to adjust the reported delay value and not
strictly follow the current buffer usage (that's why we have two calls
after all).

Allow them to specify a delay() callback and use the previous behaviour
if they don't.

Signed-off-by: Pierre Ossman <ossman@cendio.se>
This commit is contained in:
Pierre Ossman 2006-05-26 17:08:18 +02:00 committed by Takashi Iwai
parent 1d80c5b901
commit 3fd9369990
2 changed files with 17 additions and 4 deletions

View file

@ -111,8 +111,15 @@ static int snd_pcm_ioplug_hwsync(snd_pcm_t *pcm)
static int snd_pcm_ioplug_delay(snd_pcm_t *pcm, snd_pcm_sframes_t *delayp)
{
snd_pcm_ioplug_hw_ptr_update(pcm);
*delayp = snd_pcm_mmap_hw_avail(pcm);
ioplug_priv_t *io = pcm->private_data;
if (io->data->version >= 0x010001 &&
io->data->callback->delay)
return io->data->callback->delay(io->data, delayp);
else {
snd_pcm_ioplug_hw_ptr_update(pcm);
*delayp = snd_pcm_mmap_hw_avail(pcm);
}
return 0;
}
@ -877,7 +884,9 @@ int snd_pcm_ioplug_create(snd_pcm_ioplug_t *ioplug, const char *name,
ioplug->callback->stop &&
ioplug->callback->pointer);
if (ioplug->version != SND_PCM_IOPLUG_VERSION) {
/* We support 1.0.0 to current */
if (ioplug->version < 0x010000 ||
ioplug->version > SND_PCM_IOPLUG_VERSION) {
SNDERR("ioplug: Plugin version mismatch\n");
return -ENXIO;
}