Fixed handle_events

This commit is contained in:
Abramo Bagnara 2001-02-11 17:46:03 +00:00
parent 8afd6e69af
commit 955b9fc335
4 changed files with 11 additions and 5 deletions

View file

@ -220,7 +220,7 @@ static int snd_ctl_hw_read(snd_ctl_t *handle, snd_ctl_event_t *event)
snd_ctl_hw_t *hw = handle->private_data; snd_ctl_hw_t *hw = handle->private_data;
ssize_t res = read(hw->fd, event, sizeof(*event)); ssize_t res = read(hw->fd, event, sizeof(*event));
if (res <= 0) if (res <= 0)
return res; return -errno;
assert(res == sizeof(*event)); assert(res == sizeof(*event));
return 1; return 1;
} }

View file

@ -491,17 +491,20 @@ int snd_hctl_handle_events(snd_hctl_t *hctl)
{ {
snd_ctl_event_t event; snd_ctl_event_t event;
int res; int res;
unsigned int count = 0;
assert(hctl); assert(hctl);
assert(hctl->ctl); assert(hctl->ctl);
while ((res = snd_ctl_read(hctl->ctl, &event)) != 0) { while ((res = snd_ctl_read(hctl->ctl, &event)) != 0 &&
res != -EAGAIN) {
if (res < 0) if (res < 0)
return res; return res;
res = snd_hctl_handle_event(hctl, &event); res = snd_hctl_handle_event(hctl, &event);
if (res < 0) if (res < 0)
return res; return res;
count++;
} }
return 0; return count;
} }
int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info) int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info)

View file

@ -200,6 +200,7 @@ int snd_mixer_detach(snd_mixer_t *mixer, const char *name)
int snd_mixer_throw_event(snd_mixer_t *mixer, snd_ctl_event_type_t event, int snd_mixer_throw_event(snd_mixer_t *mixer, snd_ctl_event_type_t event,
snd_mixer_elem_t *elem) snd_mixer_elem_t *elem)
{ {
mixer->events++;
if (mixer->callback) if (mixer->callback)
return mixer->callback(mixer, event, elem); return mixer->callback(mixer, event, elem);
return 0; return 0;
@ -208,6 +209,7 @@ int snd_mixer_throw_event(snd_mixer_t *mixer, snd_ctl_event_type_t event,
int snd_mixer_elem_throw_event(snd_mixer_elem_t *elem, int snd_mixer_elem_throw_event(snd_mixer_elem_t *elem,
snd_ctl_event_type_t event) snd_ctl_event_type_t event)
{ {
elem->class->mixer->events++;
if (elem->callback) if (elem->callback)
return elem->callback(elem, event); return elem->callback(elem, event);
return 0; return 0;
@ -379,6 +381,7 @@ int snd_mixer_handle_events(snd_mixer_t *mixer)
{ {
struct list_head *pos, *next; struct list_head *pos, *next;
assert(mixer); assert(mixer);
mixer->events = 0;
list_for_each(pos, next, &mixer->slaves) { list_for_each(pos, next, &mixer->slaves) {
int err; int err;
snd_mixer_slave_t *s; snd_mixer_slave_t *s;
@ -387,6 +390,6 @@ int snd_mixer_handle_events(snd_mixer_t *mixer)
if (err < 0) if (err < 0)
return err; return err;
} }
return 0; return mixer->events;
} }

View file

@ -65,8 +65,8 @@ struct _snd_mixer {
struct list_head slaves; /* list of all slaves */ struct list_head slaves; /* list of all slaves */
struct list_head classes; /* list of all elem classes */ struct list_head classes; /* list of all elem classes */
struct list_head elems; /* list of all elems */ struct list_head elems; /* list of all elems */
unsigned int count; unsigned int count;
unsigned int events;
snd_mixer_callback_t callback; snd_mixer_callback_t callback;
void *callback_private; void *callback_private;
}; };