Debian Codegraph @

3rdparty/iaxclient/lib/portaudio/docs/pa_impl_startstop.html

raw symbols SCIP
1 <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="GENERATOR" content="Mozilla/4.75 [en]C-gatewaynet (Win98; U) [Netscape]">
6 <meta name="Author" content="Phil Burk">
7 <meta name="Description" content="Internal docs. How a stream is started or stopped.">
8 <meta name="KeyWords" content="audio, tutorial, library, portable, open-source, DirectSound,sound, music, JSyn, synthesis,">
9 <title>PortAudio Implementation - Start/Stop</title>
10 </head>
11 <body>
12 &nbsp;
13 <center><table COLS=1 WIDTH="100%" BGCOLOR="#FADA7A" >
14 <tr>
15 <td>
16 <center>
17 <h1>
18 PortAudio Implementation</h1></center>
19 </td>
20 </tr>
21 </table></center>
22
23 <h2>
24 Starting and Stopping Streams</h2>
25 PortAudio is generally executed in two "threads". The foreground thread
26 is the application thread. The background "thread" may be implemented as
27 an actual thread, an interrupt handler, or a callback from a timer thread.
28 <p>There are three ways that PortAudio can stop a stream. In each case
29 we look at the sequence of events and the messages sent between the two
30 threads. The following variables are contained in the internalPortAudioStream.
31 <blockquote><tt>int&nbsp;&nbsp; past_IsActive;&nbsp;&nbsp;&nbsp;&nbsp;
32 /* Background is still playing. */</tt>
33 <br><tt>int&nbsp;&nbsp; past_StopSoon;&nbsp;&nbsp;&nbsp;&nbsp; /* Stop
34 when last buffer done. */</tt>
35 <br><tt>int&nbsp;&nbsp; past_StopNow;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /*
36 Stop IMMEDIATELY. */</tt></blockquote>
37
38 <h3>
39 Pa_AbortStream()</h3>
40 This function causes the background thread to terminate as soon as possible
41 and audio I/O to stop abruptly.
42 <br>&nbsp;
43 <table BORDER COLS=2 WIDTH="60%" >
44 <tr>
45 <td><b>Foreground Thread</b></td>
46
47 <td><b>Background Thread</b></td>
48 </tr>
49
50 <tr>
51 <td>sets <tt>StopNow</tt></td>
52
53 <td></td>
54 </tr>
55
56 <tr>
57 <td></td>
58
59 <td>sees <tt>StopNow</tt>,&nbsp;</td>
60 </tr>
61
62 <tr>
63 <td></td>
64
65 <td>clears IsActive, stops thread</td>
66 </tr>
67
68 <tr>
69 <td>waits for thread to exit</td>
70
71 <td></td>
72 </tr>
73
74 <tr>
75 <td>turns off audio I/O</td>
76
77 <td></td>
78 </tr>
79 </table>
80
81 <h3>
82 Pa_StopStream()</h3>
83 This function stops the user callback function from being called and then
84 waits for all audio data written to the output buffer to be played. In
85 a system with very low latency, you may not hear any difference between
86 <br>&nbsp;
87 <table BORDER COLS=2 WIDTH="60%" >
88 <tr>
89 <td><b>Foreground Thread</b></td>
90
91 <td><b>Background Thread</b></td>
92 </tr>
93
94 <tr>
95 <td>sets StopSoon</td>
96
97 <td></td>
98 </tr>
99
100 <tr>
101 <td></td>
102
103 <td>stops calling user callback</td>
104 </tr>
105
106 <tr>
107 <td></td>
108
109 <td>continues until output buffer empty</td>
110 </tr>
111
112 <tr>
113 <td></td>
114
115 <td>clears IsActive, stops thread</td>
116 </tr>
117
118 <tr>
119 <td>waits for thread to exit</td>
120
121 <td></td>
122 </tr>
123
124 <tr>
125 <td>turns off audio I/O</td>
126
127 <td></td>
128 </tr>
129 </table>
130
131 <h3>
132 User callback returns one.</h3>
133 If the user callback returns one then the user callback function will no
134 longer be called. Audio output will continue until all audio data written
135 to the output buffer has been played. Then the audio I/O is stopped, the
136 background thread terminates, and the stream becomes inactive.
137 <br>&nbsp;
138 <table BORDER COLS=2 WIDTH="60%" >
139 <tr>
140 <td><b>Foreground Thread</b></td>
141
142 <td><b>Background Thread</b></td>
143 </tr>
144
145 <tr>
146 <td></td>
147
148 <td>callback returns 1</td>
149 </tr>
150
151 <tr>
152 <td></td>
153
154 <td>sets StopSoon</td>
155 </tr>
156
157 <tr>
158 <td></td>
159
160 <td>stops calling user callback</td>
161 </tr>
162
163 <tr>
164 <td></td>
165
166 <td>continues until output buffer empty</td>
167 </tr>
168
169 <tr>
170 <td></td>
171
172 <td>clears IsActive, stops thread</td>
173 </tr>
174
175 <tr>
176 <td>waits for thread to exit</td>
177
178 <td></td>
179 </tr>
180
181 <tr>
182 <td>turns off audio I/O</td>
183
184 <td></td>
185 </tr>
186 </table>
187
188 <br>&nbsp;
189 </body>
190 </html>