summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2006-05-26 17:08:18 +0200
committerTakashi Iwai <tiwai@suse.de>2006-05-26 17:08:18 +0200
commit3fd93699904eaec36b2708c359cc1b7633594f9b (patch)
tree816510023c092d6433a33ac0c1215e73319ff4d4
parent1d80c5b901baf7e1b7998dfa518532fbd64e4283 (diff)
downloadalsa-lib-3fd93699904eaec36b2708c359cc1b7633594f9b.tar.gz
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>
-rw-r--r--include/pcm_ioplug.h6
-rw-r--r--src/pcm/pcm_ioplug.c15
2 files changed, 17 insertions, 4 deletions
diff --git a/include/pcm_ioplug.h b/include/pcm_ioplug.h
index 58f97be6..f8a23f69 100644
--- a/include/pcm_ioplug.h
+++ b/include/pcm_ioplug.h
@@ -65,7 +65,7 @@ typedef struct snd_pcm_ioplug_callback snd_pcm_ioplug_callback_t;
*/
#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 @@ struct snd_pcm_ioplug_callback {
* 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);
};
diff --git a/src/pcm/pcm_ioplug.c b/src/pcm/pcm_ioplug.c
index ed8c5080..dbef48e0 100644
--- a/src/pcm/pcm_ioplug.c
+++ b/src/pcm/pcm_ioplug.c
@@ -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;
}