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
This commit is contained in:
Lennart Poettering 2008-04-23 18:12:46 +00:00
parent ed0af46e69
commit 3f57d3aab2

View file

@ -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;
}