mirror of
https://github.com/alsa-project/alsa-lib.git
synced 2025-10-29 05:40:25 -04:00
Fixed handle_events
This commit is contained in:
parent
8afd6e69af
commit
955b9fc335
4 changed files with 11 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue