From 544c3c0015fc10b18fc094d79fd9c48ed783e420 Mon Sep 17 00:00:00 2001 From: ratchov Date: Tue, 23 Jul 2024 08:36:51 +0000 Subject: [PATCH] libsndio: Don't use poll(2) for output on the control device. The AUDIO_MIXER_WRITE ioctl always succeeds without blocking, so no need to use poll(2) for output. The audio(4) control device driver doesn't implement the corresponding struct filterops anyway. Fixes delayed level settings. --- lib/libsndio/sioctl_sun.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/libsndio/sioctl_sun.c b/lib/libsndio/sioctl_sun.c index 64129ac2a43..886c8207efa 100644 --- a/lib/libsndio/sioctl_sun.c +++ b/lib/libsndio/sioctl_sun.c @@ -472,9 +472,18 @@ sioctl_sun_pollfd(struct sioctl_hdl *addr, struct pollfd *pfd, int events) { struct sioctl_sun_hdl *hdl = (struct sioctl_sun_hdl *)addr; + hdl->events = events; + + /* + * The audio(4) driver doesn't support POLLOUT, so if it is + * requested, don't set the struct pollfd. The AUDIO_MIXER_WRITE + * ioctl never blocks, so just return POLLOUT in sioctl_sun_revents(). + */ + if (events & POLLOUT) + return 0; + pfd->fd = hdl->fd; pfd->events = POLLIN; - hdl->events = events; return 1; } @@ -485,6 +494,9 @@ sioctl_sun_revents(struct sioctl_hdl *arg, struct pollfd *pfd) struct volume *vol; int idx, n; + if (hdl->events & POLLOUT) + return POLLOUT; + if (pfd->revents & POLLIN) { while (1) { n = read(hdl->fd, &idx, sizeof(int)); @@ -514,5 +526,5 @@ sioctl_sun_revents(struct sioctl_hdl *arg, struct pollfd *pfd) return POLLHUP; } } - return hdl->events & POLLOUT; + return 0; } -- 2.20.1