home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!gatech!gatech!warlord!mhw
- From: mhw@warlord.UUCP (Michael H. Warfield)
- Newsgroups: comp.sys.sun.hardware
- Subject: Re: Using /dev/audio in applications
- Message-ID: <243@warlord.UUCP>
- Date: 9 Sep 92 21:04:26 GMT
- References: <1992Sep4.204344.22328@news.Hawaii.Edu>
- Organization: Thaumaturgy & Speculums Engineering
- Lines: 29
-
- In <1992Sep4.204344.22328@news.Hawaii.Edu> denault@galileo.ifa.hawaii.edu (Tony Denault) writes:
- > if( -1 == (soundfd = open("/dev/audio", O_WRONLY|O_NONBLOCK)) )
-
- >BUT, the application will hang if some other process is using /dev/audio.
- >I though the O_NONBLOCK would prevent this.
-
- I'm not real sure what O_NONBLOCK would do in this case but I use
- O_NDELAY and that works. The man pages on /dev/audio make no reference to
- O_NONBLOCK but do specify O_NDELAY for controling immediate return if the
- device is busy.
-
- According to the man pages on "open", O_NONBLOCK is supposed to be
- equivalent to O_NDELAY. If you look at /usr/include/sys/fcntlcom.h (included
- from /usr/include/sys/fcntl.h, which is included from /usr/include/fcntl.h)
- you will find that O_NDELAY is _FNDELAY and is non blocking I/O BSD 4.2 style.
- Same file says O_NONBLOCK is _FNONBLOCK and is non blocking I/O POSIX style.
- They are different bits in the option field. Obviously, to /dev/audio, they
- are not at all equivalent. I guess that means that the manual pages on
- "open" lied. Sigh.....
-
- I have used O_NONBLOCK for opening named pipes when I did not want
- a write to a pipe to block. In that case O_NDELAY affected the action when
- the pipe was opened (didn't wait for the other end to open) but O_NONBLOCK
- affected active writing when the pipe is full.
-
- Hope this helps...
-
- Mike Warfield
- mhw@warlord.uucp
-