home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.sun.hardware
- Path: sparky!uunet!stanford.edu!ames!news.hawaii.edu!galileo!denault
- From: denault@galileo.ifa.hawaii.edu (Tony Denault)
- Subject: Using /dev/audio in applications
- Message-ID: <1992Sep4.204344.22328@news.Hawaii.Edu>
- Sender: root@news.Hawaii.Edu (News Service)
- Nntp-Posting-Host: galileo.ifa.hawaii.edu
- Organization: Institute for Astronomy, Hawaii
- Date: Fri, 4 Sep 1992 20:43:44 GMT
- Lines: 38
-
- Hello,
-
- I wish to provide audio feed back (beeps and clicks) in an application
- I am writing via on the SPARC's speaker. Even something like this would
- be OK:
-
- /*----------------------------------------------------------------------
- ** make_sound() - hack for doing simple sounds
- **----------------------------------------------------------------------
- */
- void make_sound( r )
- int r;
- {
- int soundfd, i;
- static char click[] = {"AAAAAAAAAAAAAAAAAAAAAAAAAA"};
-
- return;
-
- if( -1 == (soundfd = open("/dev/audio", O_WRONLY|O_NONBLOCK)) )
- return;
- for(i=0; i<r; i++)
- write( soundfd, click, sizeof(click));
- close( soundfd );
- }
-
- BUT, the application will hang if some other process is using /dev/audio.
- I though the O_NONBLOCK would prevent this.
-
- Can anyone provide a simple solution. Or point out my error?
-
- Thanks
-
- Tony Denault
- --
- /------------------------------------------------------------------------\
- | Tony Denault, Institute for Astronomy, | denault@uhifa.ifa.hawaii.edu |
- | 2680 Woodlawn Drive, Honolulu, HI 96789 | (808) 956-8101 |
- \------------------------------------------------------------------------/
-