Allow ioplugins to override snd_pcm_delay()
PATCH 1/1 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.
Index: src/pcm/pcm_ioplug.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_ioplug.c,v retrieving revision 1.10
pcm/pcm_ioplug.c +12 -3
@@ -106,8 +106,15 @@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 ; }
@@ -872,7 +879,9 @@ 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 ; }
Index: include/pcm_ioplug.h
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/include/pcm_ioplug.h,v retrieving revision 1.5
pcm_ioplug.h +5 -1
@@ -65,7 +65,7 @@*/ #define SND_PCM_IOPLUG_VERSION_MAJOR 1/**< Protocol major version */ #define SND_PCM_IOPLUG_VERSION_MINOR 0/**< Protocol minor version */ -#define SND_PCM_IOPLUG_VERSION_TINY 0/**< Protocol tiny version */ +#define SND_PCM_IOPLUG_VERSION_TINY 1/**< Protocol tiny version */ /** * IO-plugin protocol version */
@@ -184,6 +184,10 @@* dump; optional */ void (*dump)(snd_pcm_ioplug_t *io,snd_output_t *out); +/** +* get the delay for the running PCM; optional +*/ +int (*delay)(snd_pcm_ioplug_t *io,snd_pcm_sframes_t *delayp); };
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
Takashi Iwai
AppliedAt Fri, 26 May 2006 16:01:16 +0200,
Quoted 9 lines · Pierre Ossman
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 <[email protected]>
Thanks, applied to HG repo with minor space fixes.
Takashi