@@ -18,13 +18,18 @@ \section{\module{sunaudiodev} ---
1818\end {excdesc }
1919
2020\begin {funcdesc }{open}{mode}
21- This function opens the audio device and returns a sun audio device
21+ This function opens the audio device and returns a Sun audio device
2222object. This object can then be used to do I/O on. The \var {mode} parameter
2323is one of \code {'r'} for record-only access, \code {'w'} for play-only
2424access, \code {'rw'} for both and \code {'control'} for access to the
2525control device. Since only one process is allowed to have the recorder
2626or player open at the same time it is a good idea to open the device
2727only for the activity needed. See \manpage {audio}{7I} for details.
28+
29+ As per the manpage, this module first looks in the environment
30+ variable \code {AUDIODEV} for the base audio device filename. If not
31+ found, it falls back to \file {/dev/audio}. The control device is
32+ calculated by appending `` ctl'' to the base audio device.
2833\end {funcdesc }
2934
3035
@@ -33,14 +38,20 @@ \subsection{Audio Device Objects}
3338
3439The audio device objects are returned by \function {open()} define the
3540following methods (except \code {control} objects which only provide
36- \method {getinfo()}, \method {setinfo()} and \method {drain()}):
41+ \method {getinfo()}, \method {setinfo()}, \method {fileno()}, and
42+ \method {drain()}):
3743
3844\begin {methoddesc }[audio device]{close}{}
3945This method explicitly closes the device. It is useful in situations
4046where deleting the object does not immediately close it since there
4147are other references to it. A closed device should not be used again.
4248\end {methoddesc }
4349
50+ \begin {methoddesc }[audio device]{fileno}{}
51+ Returns the file descriptor associated with the device. This can be
52+ used to set up \code {SIGPOLL} notification, as described below.
53+ \end {methoddocs}
54+
4455\begin {methoddesc }[audio device]{drain}{}
4556This method waits until all pending output is processed and then returns.
4657Calling this method is often not necessary: destroying the object will
@@ -106,6 +117,16 @@ \subsection{Audio Device Objects}
106117as used in the \C {} include file \code {<sun/audioio.h>}, with the
107118leading string \samp {AUDIO_} stripped.
108119
109- Useability of the control device is limited at the moment, since there
110- is no way to use the `` wait for something to happen'' feature the
111- device provides.
120+ The audio device supports asynchronous notification of various events,
121+ through the SIGPOLL signal. Here's an example of how you might enable
122+ this in Python:
123+
124+ \begin {verbatim }
125+ def handle_sigpoll(signum, frame):
126+ print 'I got a SIGPOLL update'
127+ pp
128+ import fcntl, signal, STROPTS
129+
130+ signal.signal(signal.SIGPOLL, handle_sigpoll)
131+ fcntl.ioctl(audio_obj.fileno(), STROPTS.I_SETSIG, STROPTS.S_MSG)
132+ \end {verbatim }
0 commit comments