home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sun / hardware / 4247 < prev    next >
Encoding:
Text File  |  1992-09-07  |  1.5 KB  |  50 lines

  1. Newsgroups: comp.sys.sun.hardware
  2. Path: sparky!uunet!stanford.edu!ames!news.hawaii.edu!galileo!denault
  3. From: denault@galileo.ifa.hawaii.edu (Tony Denault)
  4. Subject: Using /dev/audio in applications
  5. Message-ID: <1992Sep4.204344.22328@news.Hawaii.Edu>
  6. Sender: root@news.Hawaii.Edu (News Service)
  7. Nntp-Posting-Host: galileo.ifa.hawaii.edu
  8. Organization: Institute for Astronomy, Hawaii
  9. Date: Fri, 4 Sep 1992 20:43:44 GMT
  10. Lines: 38
  11.  
  12. Hello,
  13.  
  14. I wish to provide audio feed back (beeps and clicks) in an application
  15. I am writing via on the SPARC's speaker. Even something like this would
  16. be OK:
  17.  
  18. /*----------------------------------------------------------------------
  19. **  make_sound() - hack for doing simple sounds
  20. **----------------------------------------------------------------------
  21. */
  22. void make_sound( r )
  23. int r;
  24. {
  25.    int soundfd, i;
  26.    static char click[] = {"AAAAAAAAAAAAAAAAAAAAAAAAAA"};
  27.  
  28.    return;
  29.  
  30.    if( -1 == (soundfd = open("/dev/audio", O_WRONLY|O_NONBLOCK)) )
  31.       return;
  32.    for(i=0; i<r; i++)
  33.       write( soundfd, click, sizeof(click));
  34.    close( soundfd );
  35. }
  36.  
  37. BUT, the application will hang if some other process is using /dev/audio.
  38. I though the O_NONBLOCK would prevent this. 
  39.  
  40. Can anyone provide a simple solution. Or point out my error?
  41.  
  42. Thanks
  43.  
  44. Tony Denault
  45. --
  46. /------------------------------------------------------------------------\
  47. | Tony Denault, Institute for Astronomy,  | denault@uhifa.ifa.hawaii.edu |
  48. | 2680 Woodlawn Drive, Honolulu, HI 96789 |               (808) 956-8101 |
  49. \------------------------------------------------------------------------/
  50.