Subject: /dev/audio vs. fcntl() in 1.0
To: None <port-sparc@NetBSD.ORG>
From: Greg Earle <earle@isolar.Tujunga.CA.US>
List: port-sparc
Date: 06/29/1995 20:13:40
I've been fiddling with the "maplay" audio MPEG player this afternoon, and ran
into 2 oddities:
(1) It does the following:
if ((fd = open ("/dev/audio", O_WRONLY | O_NDELAY, 0)) < 0)
...
// turn NDELAY mode off:
int flags;
if ((flags = fcntl (fd, F_GETFL, 0)) < 0)
...
flags &= ~O_NDELAY;
if (fcntl (fd, F_SETFL, flags) < 0)
{
perror ("fcntl F_SETFL on /dev/audio failed");
exit (1);
}
...
The fcntl(fd, F_GETFL, 0) is returning "5". But the subsequent F_SETFL
fails. <fcntl.h> shows that "FNONBLOCK" (== O_NONBLOCK, as is O_NDELAY)
is in FCNTLFLAGS as an allowable settable bit for F_SETFL. So I wonder
why this is failing? Come to think of it, if I comment out the twiddling
of the "flags", it still fails. Hmmn ...
(2) If I don't this ioctl(), the program works but generates a lot of errors
because of the write()'s returning EAGAIN. I've ported other stuff like
the MBone IVS tool with a similar output mechanism yet I don't get the
same type of errors with IVS (or VAT, for that matter; I get the occasional
"audio write: Operation would block", but nowhere near the amount I get
with "maplay"). Hmmn again ...
I suspect the 2nd problem might be alleviated by the 1st, if I knew why the
fcntl() was failing. Any ideas? Any NetBSD/SPARC audiophiles around? :-)
- Greg