From 3f57d3aab2ded1c730ac8625e8ca6242d4445954 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 23 Apr 2008 18:12:46 +0000 Subject: add new function pa_alsa_build_pollfd() to alsa-util to unify a bit more common code from the sink and the source git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/glitch-free@2303 fefdeb5f-60dc-0310-8127-8f9354f1896f --- src/modules/alsa-util.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/modules/alsa-util.c b/src/modules/alsa-util.c index 11367d95..0c4c020b 100644 --- a/src/modules/alsa-util.c +++ b/src/modules/alsa-util.c @@ -1093,3 +1093,27 @@ int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents) { return 0; } + +pa_rtpoll_item* pa_alsa_build_pollfd(snd_pcm_t *pcm, pa_rtpoll *rtpoll) { + int n, err; + struct pollfd *pollfd; + pa_rtpoll_item *item; + + pa_assert(pcm); + + if ((n = snd_pcm_poll_descriptors_count(pcm)) < 0) { + pa_log("snd_pcm_poll_descriptors_count() failed: %s", snd_strerror(n)); + return NULL; + } + + item = pa_rtpoll_item_new(rtpoll, PA_RTPOLL_NEVER, n); + pollfd = pa_rtpoll_item_get_pollfd(item, NULL); + + if ((err = snd_pcm_poll_descriptors(pcm, pollfd, n)) < 0) { + pa_log("snd_pcm_poll_descriptors() failed: %s", snd_strerror(err)); + pa_rtpoll_item_free(item); + return NULL; + } + + return item; +} -- cgit