diff options
author | Simon Wilson <ksattic@gmail.com> | 2015-09-15 11:36:00 -0700 |
---|---|---|
committer | Simon Wilson <ksattic@gmail.com> | 2015-09-15 11:36:00 -0700 |
commit | 33fe27c809e0fa67e14db9fec37c5f2ef849aecb (patch) | |
tree | ce6d4ce00eaaf40ce2277c0b2df1b6e8dce8150e | |
parent | 8d6f1f3ed27c74b1d927889b5f7cfc6d76af1f2c (diff) | |
parent | 4cddf19dfcf65e6fb1277a3230fd0fe509ec7e81 (diff) |
Merge pull request #48 from vinodkoul/wait_delay
Wait delay
-rw-r--r-- | include/tinyalsa/asoundlib.h | 6 | ||||
-rw-r--r-- | pcm.c | 18 |
2 files changed, 23 insertions, 1 deletions
diff --git a/include/tinyalsa/asoundlib.h b/include/tinyalsa/asoundlib.h index 584cfe1..8fb7c95 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. @@ -205,6 +208,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 */ @@ -170,6 +170,8 @@ struct pcm { struct snd_pcm_sync_ptr *sync_ptr; void *mmap_buffer; unsigned int noirq_frames_per_msec; + long pcm_delay; + unsigned int subdevice; }; unsigned int pcm_get_buffer_size(struct pcm *pcm) @@ -182,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; @@ -653,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, @@ -918,7 +926,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 */ @@ -1046,3 +1054,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; +} |