]> git.alsa-project.org Git - alsa-lib.git/commitdiff
ctl: ext: Fail with error code if snd_ctl_ext_callback::read_event() callback is...
authorTimo Wischer <twischer@de.adit-jv.com>
Thu, 5 Oct 2017 14:25:23 +0000 (16:25 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 5 Oct 2017 14:42:09 +0000 (16:42 +0200)
The snd_ctl_ext_callback::read_event() callback is only optional
if no poll descriptor was given via
snd_ctl_ext_t::poll_fd
or
snd_ctl_ext_callback::snd_ctl_ext_poll_descriptors().

If a poll descriptor is given the
snd_ctl_ext_callback::read_event()
callback has also to be defined
because there is no minigful default behavior.

This callback will be called when ever the poll() on
the file descriptor indicates that there is an event pending.
Therefore returning a 0 which indicates that there is no event makes no
sense.

Signed-off-by: Timo Wischer <twischer@de.adit-jv.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
src/control/control_ext.c

index 56552fa1aa0ef0e6383abf4029b63944a841c2c4..d7de8e84f53f4a2d0a08746c9e18d144eb1d1640 100644 (file)
@@ -415,8 +415,12 @@ static int snd_ctl_ext_read(snd_ctl_t *handle, snd_ctl_event_t *event)
 {
        snd_ctl_ext_t *ext = handle->private_data;
 
-       memset(event, 0, sizeof(*event));
-       return ext->callback->read_event(ext, &event->data.elem.id, &event->data.elem.mask);
+       if (ext->callback->read_event) {
+               memset(event, 0, sizeof(*event));
+               return ext->callback->read_event(ext, &event->data.elem.id, &event->data.elem.mask);
+       }
+
+       return -EINVAL;
 }
 
 static int snd_ctl_ext_poll_descriptors_count(snd_ctl_t *handle)