From 84889d0fa6e61451328a0077946105158ea86a25 Mon Sep 17 00:00:00 2001 From: Apelete Seketeli Date: Fri, 14 Feb 2014 14:34:32 +0100 Subject: Tinyalsa: allow pcm_wait to wait on POLLIN events Tinyalsa pcm_wait() function does not wait on POLLIN events, preventing it to be used when recording audio data. This allows pcm_wait to wait on POLLIN events. Change-Id: I2e4bd0f4f57415add37213f8785a3602897f2c8a Signed-off-by: Apelete Seketeli Signed-off-by: Vinod Koul --- pcm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pcm.c b/pcm.c index 1a5d84b..5381a89 100644 --- a/pcm.c +++ b/pcm.c @@ -918,7 +918,7 @@ int pcm_wait(struct pcm *pcm, int timeout) int err; pfd.fd = pcm->fd; - pfd.events = POLLOUT | POLLERR | POLLNVAL; + pfd.events = POLLIN | POLLOUT | POLLERR | POLLNVAL; do { /* let's wait for avail or timeout */ -- cgit v1.2.3 From 9ecb93fb6b4474bee5e700e65663af15088c97c2 Mon Sep 17 00:00:00 2001 From: Hardik T Shah Date: Thu, 10 Apr 2014 18:03:52 +0530 Subject: 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 Signed-off-by: Apelete Seketeli Signed-off-by: Vinod Koul --- include/tinyalsa/asoundlib.h | 3 +++ pcm.c | 9 +++++++++ 2 files changed, 12 insertions(+) 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; +} -- cgit v1.2.3 From 4cddf19dfcf65e6fb1277a3230fd0fe509ec7e81 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Wed, 2 Apr 2014 15:12:54 +0200 Subject: tinyalsa: add pcm_get_subdevice() The users of tinyalsa had no way of knowing on which subdevice a stream had been created. A new API, "unsigned int pcm_get_subdevice(struct *pcm)" returns it. This information is filled during the pcm_open() Change-Id: Ie866e10e06ce6691ede09e2ca46a24441723ea8b Signed-off-by: David Wagner Signed-off-by: Vinod Koul --- include/tinyalsa/asoundlib.h | 3 +++ pcm.c | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index eb3e4c4..045c8b5 100644 --- a/include/tinyalsa/asoundlib.h +++ b/include/tinyalsa/asoundlib.h @@ -179,6 +179,9 @@ unsigned int pcm_bytes_to_frames(struct pcm *pcm, unsigned int bytes); int pcm_get_htimestamp(struct pcm *pcm, unsigned int *avail, struct timespec *tstamp); +/* Returns the subdevice on which the pcm has been opened */ +unsigned int pcm_get_subdevice(struct pcm *pcm); + /* Write data to the fifo. * Will start playback on the first write or on a write that * occurs after a fifo underrun. diff --git a/pcm.c b/pcm.c index 90c9dad..d58d6a3 100644 --- a/pcm.c +++ b/pcm.c @@ -171,6 +171,7 @@ struct pcm { void *mmap_buffer; unsigned int noirq_frames_per_msec; long pcm_delay; + unsigned int subdevice; }; unsigned int pcm_get_buffer_size(struct pcm *pcm) @@ -183,6 +184,11 @@ const char* pcm_get_error(struct pcm *pcm) return pcm->error; } +unsigned int pcm_get_subdevice(struct pcm *pcm) +{ + return pcm->subdevice; +} + static int oops(struct pcm *pcm, int e, const char *fmt, ...) { va_list ap; @@ -654,6 +660,7 @@ struct pcm *pcm_open(unsigned int card, unsigned int device, oops(pcm, errno, "cannot get info"); goto fail_close; } + pcm->subdevice = info.subdevice; param_init(¶ms); param_set_mask(¶ms, SNDRV_PCM_HW_PARAM_FORMAT, -- cgit v1.2.3