From fcb8361dc32c8b55ce8a5385dae620a1e9d61177 Mon Sep 17 00:00:00 2001 From: Simon Wilson Date: Fri, 24 Jun 2011 11:08:10 -0700 Subject: Update tinyalsa for pcm_start/stop() support d6458e6 pcm: add pcm_start/stop() functions for streams Change-Id: Iba1dd4e6adc0be68008b44978d55231c584e92c4 --- include/tinyalsa/asoundlib.h | 4 ++++ pcm.c | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index bd0cdee..14511c9 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h @@ -97,6 +97,10 @@ unsigned int pcm_get_latency(struct pcm *pcm); int pcm_write(struct pcm *pcm, void *data, unsigned int count); int pcm_read(struct pcm *pcm, void *data, unsigned int count); +/* Start and stop a PCM channel that doesn't transfer data */ +int pcm_start(struct pcm *pcm); +int pcm_stop(struct pcm *pcm); + /* * MIXER API diff --git a/pcm.c b/pcm.c index adc0495..3ba51ba 100644 --- a/pcm.c +++ b/pcm.c @@ -350,3 +350,22 @@ int pcm_is_ready(struct pcm *pcm) { return pcm->fd >= 0; } + +int pcm_start(struct pcm *pcm) +{ + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_PREPARE) < 0) + return oops(pcm, errno, "cannot prepare channel"); + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_START) < 0) + return oops(pcm, errno, "cannot start channel"); + + return 0; +} + +int pcm_stop(struct pcm *pcm) +{ + if (ioctl(pcm->fd, SNDRV_PCM_IOCTL_DROP) < 0) + return oops(pcm, errno, "cannot stop channel"); + + return 0; +} + -- cgit v1.2.3-54-g00ecf