aboutsummaryrefslogtreecommitdiff
path: root/src/pcm_hw.c
diff options
context:
space:
mode:
authorRohit kumar <rohitkr@codeaurora.org>2020-08-19 15:19:33 +0530
committerRohit kumar <rohitkr@codeaurora.org>2020-09-03 11:29:44 +0530
commitf29b8df6261e72d9a426d6d8c175a896931654e2 (patch)
tree41736e3bae1b2dd1f3ad6aa126b8889833ece97f /src/pcm_hw.c
parent1ef2d458f56d6583de5d35da6d8ca0dc8ec2a146 (diff)
tinyalsa: add plugin support for mmap/poll ops
Diffstat (limited to 'src/pcm_hw.c')
-rw-r--r--src/pcm_hw.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pcm_hw.c b/src/pcm_hw.c
index e25cdae..38b2e83 100644
--- a/src/pcm_hw.c
+++ b/src/pcm_hw.c
@@ -37,6 +37,7 @@
#include <poll.h>
#include <sys/ioctl.h>
+#include <sys/mman.h>
#include <linux/ioctl.h>
#include <sound/asound.h>
#include <tinyalsa/asoundlib.h>
@@ -77,6 +78,25 @@ static int pcm_hw_ioctl(void *data, unsigned int cmd, ...)
return ioctl(hw_data->fd, cmd, arg);
}
+static int pcm_hw_poll(void *data __attribute__((unused)),
+ struct pollfd *pfd, nfds_t nfds, int timeout)
+{
+ return poll(pfd, nfds, timeout);
+}
+
+static void *pcm_hw_mmap(void *data, void *addr, size_t length, int prot,
+ int flags, off_t offset)
+{
+ struct pcm_hw_data *hw_data = data;
+
+ return mmap(addr, length, prot, flags, hw_data->fd, offset);
+}
+
+static int pcm_hw_munmap(void *data __attribute__((unused)), void *addr, size_t length)
+{
+ return munmap(addr, length);
+}
+
static int pcm_hw_open(unsigned int card, unsigned int device,
unsigned int flags, void **data, struct snd_node *node)
{
@@ -115,5 +135,8 @@ const struct pcm_ops hw_ops = {
.open = pcm_hw_open,
.close = pcm_hw_close,
.ioctl = pcm_hw_ioctl,
+ .mmap = pcm_hw_mmap,
+ .munmap = pcm_hw_munmap,
+ .poll = pcm_hw_poll,
};