diff options
author | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-31 04:11:45 +0200 |
---|---|---|
committer | Jari Vetoniemi <mailroxas@gmail.com> | 2018-10-31 04:11:45 +0200 |
commit | db107e04caeb9ccca17f552276028c67967d0ed7 (patch) | |
tree | c7a378ac89d36a853457cc13d660ca5480a15013 | |
parent | 4c27d6dd84cfc71c1345bb6f7590a7bd7e3dcfb2 (diff) |
implement snd_pcm_poll_* functions
-rw-r--r-- | libasound.c | 31 | ||||
-rw-r--r-- | stubs.h | 3 |
2 files changed, 26 insertions, 8 deletions
diff --git a/libasound.c b/libasound.c index 92398cf..5d66ef2 100644 --- a/libasound.c +++ b/libasound.c @@ -242,6 +242,31 @@ snd_pcm_nonblock(snd_pcm_t *pcm, int nonblock) return snd_pcm_hw_params(pcm, &pcm->hw_requested); } +int +snd_pcm_poll_descriptors_count(snd_pcm_t *pcm) +{ + return sio_nfds(pcm->hdl); +} + +int +snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space) +{ + if (space > (unsigned int)sio_nfds(pcm->hdl)) + return -1; + + return sio_pollfd(pcm->hdl, pfds, (pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN)); +} + +int +snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) +{ + if (!revents || nfds > (unsigned int)sio_nfds(pcm->hdl)) + return -1; + + *revents = sio_revents(pcm->hdl, pfds); + return 0; +} + snd_pcm_state_t snd_pcm_state(snd_pcm_t *pcm) { @@ -331,11 +356,7 @@ snd_pcm_avail_update(snd_pcm_t *pcm) int nfds = sio_nfds(pcm->hdl); assert((unsigned int)nfds < ARRAY_SIZE(pfd)); - // FIXME: should POLLIN / POLLOUT depending on stream - if (!sio_pollfd(pcm->hdl, pfd, POLLOUT)) { - WARNX1("sio_pollfd failed"); - goto fail; - } + nfds = sio_pollfd(pcm->hdl, pfd, (pcm->stream == SND_PCM_STREAM_PLAYBACK ? POLLOUT : POLLIN)); // FIXME: timeout should be period time errno = 0; @@ -487,9 +487,6 @@ int snd_pcm_open_lconf(snd_pcm_t **pcm, const char *name, snd_pcm_stream_t strea int snd_pcm_open_fallback(snd_pcm_t **pcm, snd_config_t *root, const char *name, const char *orig_name, snd_pcm_stream_t stream, int mode) { WARNX1("stub"); return 0; } snd_pcm_type_t snd_pcm_type(snd_pcm_t *pcm) { WARNX1("stub"); return 0; } snd_pcm_stream_t snd_pcm_stream(snd_pcm_t *pcm) { WARNX1("stub"); return 0; } -int snd_pcm_poll_descriptors_count(snd_pcm_t *pcm) { WARNX1("stub"); return 0; } -int snd_pcm_poll_descriptors(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int space) { WARNX1("stub"); return 0; } -int snd_pcm_poll_descriptors_revents(snd_pcm_t *pcm, struct pollfd *pfds, unsigned int nfds, unsigned short *revents) { WARNX1("stub"); return 0; } int snd_async_add_pcm_handler(snd_async_handler_t **handler, snd_pcm_t *pcm, snd_async_callback_t callback, void *private_data) { WARNX1("stub"); return 0; } snd_pcm_t *snd_async_handler_get_pcm(snd_async_handler_t *handler) { WARNX1("stub"); return NULL; } int snd_pcm_info(snd_pcm_t *pcm, snd_pcm_info_t *info) { WARNX1("stub"); return 0; } |