aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHardik T Shah <hardik.t.shah@intel.com>2014-04-10 18:03:52 +0530
committerVinod Koul <vinod.koul@intel.com>2014-08-12 14:01:38 +0530
commit9ecb93fb6b4474bee5e700e65663af15088c97c2 (patch)
tree95d0a565ba5beb1c566d78b618792d1f2d084814
parent84889d0fa6e61451328a0077946105158ea86a25 (diff)
Tinyalsa: add pcm_delay()
ALSA supports reporting of pcm_delay, make that availble to the users of tinyalsa too Change-Id: Ic460f5c55137d263fdf7b142503d3bd52c4b7ebd Signed-off-by: Hardik T Shah <hardik.t.shah@intel.com> Signed-off-by: Apelete Seketeli <apeletex.seketeli@intel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-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;
+}