Subject: kern/11179: select / poll does not work for full duplex audio
To: None <gnats-bugs@gnats.netbsd.org>
From: None <weiss@uni-mainz.de>
List: netbsd-bugs
Date: 10/09/2000 12:34:09
>Number: 11179
>Category: kern
>Synopsis: select / poll does not work for full duplex audio
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 09 12:34:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator: Juergen Weiss
>Release: NetBSD 1.4.2
>Organization:
Uni Mainz
>Environment:
All platforms, NetBSD 1.4.2 to current
>Description:
Logic of select / poll is broken for full duplex audio operation
(seems not to be reasonable for half duplex operation either)
POLLIN for read operation should only depend on available
bytes for input, not on buffer space for output.
POLLOUT should only depend on buffer space for output. With
full duplex operation AUMODE_PLAY and AUMODE_RECORD are
both set, and result of poll/select is nonsense.
>How-To-Repeat:
use full duplex audio tool, which depends on poll/select
(rat-4 for example)
>Fix:
diff -rc usr/src/sys/dev/audio.c /usr/src/sys/dev/audio.c
*** usr/src/sys/dev/audio.c Tue Jun 22 16:18:41 1999
--- /usr/src/sys/dev/audio.c Thu Jul 27 20:15:48 2000
***************
*** 1584,1596 ****
DPRINTF(("audio_poll: events=0x%x mode=%d\n", events, sc->sc_mode));
if (events & (POLLIN | POLLRDNORM))
! if ((sc->sc_mode & AUMODE_PLAY) ?
! sc->sc_pr.stamp > sc->sc_wstamp :
sc->sc_rr.used > sc->sc_rr.usedlow)
revents |= events & (POLLIN | POLLRDNORM);
if (events & (POLLOUT | POLLWRNORM))
! if (sc->sc_mode & AUMODE_RECORD ||
sc->sc_pr.used <= sc->sc_pr.usedlow)
revents |= events & (POLLOUT | POLLWRNORM);
--- 1584,1596 ----
DPRINTF(("audio_poll: events=0x%x mode=%d\n", events, sc->sc_mode));
if (events & (POLLIN | POLLRDNORM))
! if (sc->sc_rr.used > sc->sc_rr.usedlow)
revents |= events & (POLLIN | POLLRDNORM);
if (events & (POLLOUT | POLLWRNORM))
! if (sc->sc_pr.used <= sc->sc_pr.usedlow)
revents |= events & (POLLOUT | POLLWRNORM);
Is it necessary to check, that AUMODE_RECORD is set for
POLLIN and AUMODE_PLAY for POLLOUT?
>Release-Note:
>Audit-Trail:
>Unformatted: