NetBSD Problem Report #11179
Received: (qmail 15741 invoked from network); 9 Oct 2000 19:33:52 -0000
Message-Id: <200010091933.VAA18950@tick.zdv.Uni-Mainz.DE>
Date: Mon, 9 Oct 2000 21:33:50 +0200 (MEST)
From: weiss@uni-mainz.de
Reply-To: weiss@uni-mainz.de
To: gnats-bugs@gnats.netbsd.org
Subject: select / poll does not work for full duplex audio
X-Send-Pr-Version: 3.95
>Number: 11179
>Category: kern
>Synopsis: select / poll does not work for full duplex audio
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: gson
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Oct 09 19:34:00 +0000 2000
>Closed-Date: Sun Jun 02 02:11:24 +0000 2002
>Last-Modified: Sun Jun 02 02:11:24 +0000 2002
>Originator: Juergen Weiss
>Release: 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:
State-Changed-From-To: open->closed
State-Changed-By: gson
State-Changed-When: Sat Jun 1 19:02:52 PDT 2002
State-Changed-Why:
Committed a slightly different fix which retains the capability to
poll for the synthetic silence returned when reading from a half
duplex device in play mode, and commented the code.
Responsible-Changed-From-To: kern-bug-people->gson
Responsible-Changed-By: gson
Responsible-Changed-When: Sat Jun 1 19:02:52 PDT 2002
Responsible-Changed-Why:
I'll submit a pullup request.
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.