home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / sgi / 13508 < prev    next >
Encoding:
Internet Message Format  |  1992-09-10  |  2.5 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!cbnewsc!cbfsb!att-out!rutgers!sgigate!odin!sgihub!zola!bebop!cook
  2. From: cook@bebop.esd.sgi.com (Doug Cook)
  3. Newsgroups: comp.sys.sgi
  4. Subject: Re: X-events from audio buffer
  5. Message-ID: <pmpn300@zola.esd.sgi.com>
  6. Date: 11 Sep 92 02:41:09 GMT
  7. References: <32503@adm.brl.mil>
  8. Sender: news@zola.esd.sgi.com (Net News)
  9. Organization: Silicon Graphics, Inc.  Mountain View, CA
  10. Lines: 39
  11.  
  12. In article <32503@adm.brl.mil>, ross-c@dcs.leeds.ac.uk writes:
  13.  
  14. > I want to generate an X-event that occurs whenever the audio buffer looks
  15. > like it's about to empty. E.g. I would like to write 880 samples (1/100th
  16. > of a second) and when only 220 are left, the X handler calls a routine of
  17. > mine which writes another 660 (not quite building up to 880 because some
  18. > time has passed....), control is then returned to XtAppMainLoop (or whatever
  19. > it is called) until the buffer empties out to 220 samples again.
  20. > Could someone explain how to do this, or point me in the direction of the
  21. > correct man pages (I had a quick look but couldn't find anything), or ....
  22. > Also, if anyone knows any good ways of handling audio from inside an X-windows
  23. > application .... all hints much appreciated (at the moment I have one X-process
  24. > and one audio process connected by pipes).
  25.  
  26. If you're using the standard X model of "wait for an event, then
  27. process it," adding audio is fairly straightforward. You can get the
  28. file descriptor associated with the audio port (ALgetfd), and select on
  29. this to determine when an audio buffer needs "servicing." Check the man
  30. page for ALsetfillpoint to see how you can adjust the audio system's
  31. notion of "about to empty." If you need to multiplex audio and X within
  32. a single process, then use both the X server connection file descriptor
  33. and the audio file descriptor in your select call. When the select
  34. returns, figure out which FD is ready, and either process an X event,
  35. or fill your audio buffer some more. Make sure that none of the X calls
  36. you make will block so long that you can't get back to your audio
  37. buffer.
  38.  
  39. This model will change slightly if you're using Motif. I assume that
  40. there's some way to hand Motif a file descriptor of interest and have
  41. it come back to you when that descriptor is ready. I'm not a Motif 
  42. expert, so I'm sorry I can't tell you how to do this. (Other toolkits
  43. I've used have very straightforward methods for doing this, though;
  44. I doubt it's particularly difficult).
  45.  
  46. Anyway, I hope this works for you. Good luck.
  47.  
  48.     -Doug
  49.