Add pcm_get_poll_fd
Similar to ALSA snd_pcm_get_poll_fd, this will allow a user to wait for
a sound device to have data in a poll(2) call. The hotword thread will
use this to wait for a message on its socket or for audio data to become
ready.
Change-Id: I61375a73d7a842b00362fc707c12f99aa18e0bdf
Signed-off-by: Dylan Reid <dgreid@chromium.org>
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h
index 30cf0da..97ee4f3 100644
--- a/include/tinyalsa/asoundlib.h
+++ b/include/tinyalsa/asoundlib.h
@@ -248,6 +248,7 @@
/* Interrupt driven API */
int pcm_wait(struct pcm *pcm, int timeout);
+int pcm_get_poll_fd(struct pcm *pcm);
/* Change avail_min after the stream has been opened with no need to stop the stream.
* Only accepted if opened with PCM_MMAP and PCM_NOIRQ flags
diff --git a/pcm.c b/pcm.c
index ed7567b..488ea0c 100644
--- a/pcm.c
+++ b/pcm.c
@@ -1180,6 +1180,11 @@
return 1;
}
+int pcm_get_poll_fd(struct pcm *pcm)
+{
+ return pcm->fd;
+}
+
int pcm_mmap_transfer(struct pcm *pcm, const void *buffer, unsigned int bytes)
{
int err = 0, frames, avail;