aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyalsa/asoundlib.h3
-rw-r--r--pcm.c9
2 files changed, 12 insertions, 0 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index a85e810..eb3e4c4 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -205,6 +205,9 @@ int pcm_stop(struct pcm *pcm);
int pcm_wait(struct pcm *pcm, int timeout);
+/* Get the pcm delay */
+long pcm_get_delay(struct pcm *pcm);
+
/*
* MIXER API
*/
diff --git a/pcm.c b/pcm.c
index 5381a89..90c9dad 100644
--- a/pcm.c
+++ b/pcm.c
@@ -170,6 +170,7 @@ struct pcm {
struct snd_pcm_sync_ptr *sync_ptr;
void *mmap_buffer;
unsigned int noirq_frames_per_msec;
+ long pcm_delay;
};
unsigned int pcm_get_buffer_size(struct pcm *pcm)
@@ -1046,3 +1047,11 @@ int pcm_mmap_read(struct pcm *pcm, void *data, unsigned int count)
return pcm_mmap_transfer(pcm, data, count);
}
+
+long pcm_get_delay(struct pcm *pcm)
+{
+ if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DELAY, &pcm->pcm_delay) < 0)
+ return -1;
+
+ return pcm->pcm_delay;
+}