home *** CD-ROM | disk | FTP | other *** search
- 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
- From: cook@bebop.esd.sgi.com (Doug Cook)
- Newsgroups: comp.sys.sgi
- Subject: Re: X-events from audio buffer
- Message-ID: <pmpn300@zola.esd.sgi.com>
- Date: 11 Sep 92 02:41:09 GMT
- References: <32503@adm.brl.mil>
- Sender: news@zola.esd.sgi.com (Net News)
- Organization: Silicon Graphics, Inc. Mountain View, CA
- Lines: 39
-
- In article <32503@adm.brl.mil>, ross-c@dcs.leeds.ac.uk writes:
-
- > I want to generate an X-event that occurs whenever the audio buffer looks
- > like it's about to empty. E.g. I would like to write 880 samples (1/100th
- > of a second) and when only 220 are left, the X handler calls a routine of
- > mine which writes another 660 (not quite building up to 880 because some
- > time has passed....), control is then returned to XtAppMainLoop (or whatever
- > it is called) until the buffer empties out to 220 samples again.
- >
- > Could someone explain how to do this, or point me in the direction of the
- > correct man pages (I had a quick look but couldn't find anything), or ....
- >
- > Also, if anyone knows any good ways of handling audio from inside an X-windows
- > application .... all hints much appreciated (at the moment I have one X-process
- > and one audio process connected by pipes).
-
- If you're using the standard X model of "wait for an event, then
- process it," adding audio is fairly straightforward. You can get the
- file descriptor associated with the audio port (ALgetfd), and select on
- this to determine when an audio buffer needs "servicing." Check the man
- page for ALsetfillpoint to see how you can adjust the audio system's
- notion of "about to empty." If you need to multiplex audio and X within
- a single process, then use both the X server connection file descriptor
- and the audio file descriptor in your select call. When the select
- returns, figure out which FD is ready, and either process an X event,
- or fill your audio buffer some more. Make sure that none of the X calls
- you make will block so long that you can't get back to your audio
- buffer.
-
- This model will change slightly if you're using Motif. I assume that
- there's some way to hand Motif a file descriptor of interest and have
- it come back to you when that descriptor is ready. I'm not a Motif
- expert, so I'm sorry I can't tell you how to do this. (Other toolkits
- I've used have very straightforward methods for doing this, though;
- I doubt it's particularly difficult).
-
- Anyway, I hope this works for you. Good luck.
-
- -Doug
-