From 955b9fc335537ca2eee99badcd7a216024140c52 Mon Sep 17 00:00:00 2001 From: Abramo Bagnara Date: Sun, 11 Feb 2001 17:46:03 +0000 Subject: [PATCH] Fixed handle_events --- src/control/control_hw.c | 2 +- src/control/hcontrol.c | 7 +++++-- src/mixer/mixer.c | 5 ++++- src/mixer/mixer_local.h | 2 +- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/control/control_hw.c b/src/control/control_hw.c index 81af011a..09a9cdd0 100644 --- a/src/control/control_hw.c +++ b/src/control/control_hw.c @@ -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; ssize_t res = read(hw->fd, event, sizeof(*event)); if (res <= 0) - return res; + return -errno; assert(res == sizeof(*event)); return 1; } diff --git a/src/control/hcontrol.c b/src/control/hcontrol.c index 55748e2e..323feaf0 100644 --- a/src/control/hcontrol.c +++ b/src/control/hcontrol.c @@ -491,17 +491,20 @@ int snd_hctl_handle_events(snd_hctl_t *hctl) { snd_ctl_event_t event; int res; + unsigned int count = 0; assert(hctl); 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) return res; res = snd_hctl_handle_event(hctl, &event); if (res < 0) return res; + count++; } - return 0; + return count; } int snd_hctl_elem_info(snd_hctl_elem_t *elem, snd_ctl_elem_info_t *info) diff --git a/src/mixer/mixer.c b/src/mixer/mixer.c index c99ff686..ebd339ae 100644 --- a/src/mixer/mixer.c +++ b/src/mixer/mixer.c @@ -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, snd_mixer_elem_t *elem) { + mixer->events++; if (mixer->callback) return mixer->callback(mixer, event, elem); 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, snd_ctl_event_type_t event) { + elem->class->mixer->events++; if (elem->callback) return elem->callback(elem, event); return 0; @@ -379,6 +381,7 @@ int snd_mixer_handle_events(snd_mixer_t *mixer) { struct list_head *pos, *next; assert(mixer); + mixer->events = 0; list_for_each(pos, next, &mixer->slaves) { int err; snd_mixer_slave_t *s; @@ -387,6 +390,6 @@ int snd_mixer_handle_events(snd_mixer_t *mixer) if (err < 0) return err; } - return 0; + return mixer->events; } diff --git a/src/mixer/mixer_local.h b/src/mixer/mixer_local.h index f779476b..17eabd9f 100644 --- a/src/mixer/mixer_local.h +++ b/src/mixer/mixer_local.h @@ -65,8 +65,8 @@ struct _snd_mixer { struct list_head slaves; /* list of all slaves */ struct list_head classes; /* list of all elem classes */ struct list_head elems; /* list of all elems */ - unsigned int count; + unsigned int events; snd_mixer_callback_t callback; void *callback_private; }; -- 2.47.1