Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4a1cdd7

Browse files
committed
Document the new features of this module
1 parent b0d1b06 commit 4a1cdd7

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

Doc/lib/libsunaudio.tex

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2222
object. This object can then be used to do I/O on. The \var{mode} parameter
2323
is one of \code{'r'} for record-only access, \code{'w'} for play-only
2424
access, \code{'rw'} for both and \code{'control'} for access to the
2525
control device. Since only one process is allowed to have the recorder
2626
or player open at the same time it is a good idea to open the device
2727
only 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

3439
The audio device objects are returned by \function{open()} define the
3540
following 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}{}
3945
This method explicitly closes the device. It is useful in situations
4046
where deleting the object does not immediately close it since there
4147
are 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}{}
4556
This method waits until all pending output is processed and then returns.
4657
Calling this method is often not necessary: destroying the object will
@@ -106,6 +117,16 @@ \subsection{Audio Device Objects}
106117
as used in the \C{} include file \code{<sun/audioio.h>}, with the
107118
leading 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

Comments
 (0)