More generic support for poll descriptors

This commit is contained in:
Abramo Bagnara 2001-02-12 23:51:49 +00:00
parent a86efa083c
commit 460660d4b4
25 changed files with 162 additions and 68 deletions

View file

@ -68,12 +68,22 @@ int snd_ctl_async(snd_ctl_t *ctl, int sig, pid_t pid)
return ctl->ops->async(ctl, sig, pid);
}
int snd_ctl_poll_descriptor(snd_ctl_t *ctl)
int _snd_ctl_poll_descriptor(snd_ctl_t *ctl)
{
assert(ctl);
return ctl->ops->poll_descriptor(ctl);
}
int snd_ctl_poll_descriptors(snd_ctl_t *ctl, struct pollfd *pfds, unsigned int space)
{
assert(ctl);
if (space >= 1) {
pfds->fd = ctl->ops->poll_descriptor(ctl);
pfds->events = POLLIN;
}
return 1;
}
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
{
assert(ctl && info);
@ -163,8 +173,8 @@ int snd_ctl_wait(snd_ctl_t *ctl, int timeout)
{
struct pollfd pfd;
int err;
pfd.fd = snd_ctl_poll_descriptor(ctl);
pfd.events = POLLIN;
err = snd_ctl_poll_descriptors(ctl, &pfd, 1);
assert(err == 1);
err = poll(&pfd, 1, timeout);
if (err < 0)
return -errno;

View file

@ -74,5 +74,6 @@ struct _snd_hctl {
};
int _snd_ctl_poll_descriptor(snd_ctl_t *ctl);
int snd_ctl_hw_open(snd_ctl_t **handle, const char *name, int card);
int snd_ctl_shm_open(snd_ctl_t **handlep, const char *name, const char *socket, const char *sname);

View file

@ -34,7 +34,6 @@
#include <netinet/in.h>
#include <netdb.h>
#include "aserver.h"
#include "control_local.h"
typedef struct {
int socket;

View file

@ -81,10 +81,10 @@ int snd_hctl_async(snd_hctl_t *hctl, int sig, pid_t pid)
return snd_ctl_async(hctl->ctl, sig, pid);
}
int snd_hctl_poll_descriptor(snd_hctl_t *hctl)
int snd_hctl_poll_descriptors(snd_hctl_t *hctl, struct pollfd *pfds, unsigned int space)
{
assert(hctl);
return snd_ctl_poll_descriptor(hctl->ctl);
return snd_ctl_poll_descriptors(hctl->ctl, pfds, space);
}
static int _snd_hctl_find_elem(snd_hctl_t *hctl, const snd_ctl_elem_id_t *id, int *dir)
@ -441,6 +441,18 @@ unsigned int snd_hctl_get_count(snd_hctl_t *hctl)
return hctl->count;
}
int snd_hctl_wait(snd_hctl_t *hctl, int timeout)
{
struct pollfd pfd;
int err;
err = snd_hctl_poll_descriptors(hctl, &pfd, 1);
assert(err == 1);
err = poll(&pfd, 1, timeout);
if (err < 0)
return -errno;
return 0;
}
int snd_hctl_handle_event(snd_hctl_t *hctl, snd_ctl_event_t *event)
{
snd_hctl_elem_t *elem;