Mercurial > sdl-ios-xcode
annotate docs/html/audio.html @ 773:da0a2ad35bf4
Date: Sun, 4 Jan 2004 23:48:19 +0100
From: Max Horn
Subject: Re: Again Audio CD patch
Am 04.01.2004 um 22:38 schrieb Sam Lantinga:
>
> Okay, I fixed the buffering problems by simply using a 4 second buffer
> instead of a 1 second buffer. However, using your code I can't play an
> entire CD - the playback stops after the first song.
>
Found the problem: FSReadFork returns eofErr when the file is finished.
However, we check its return value for errors, and if anything but
noErr occurs, the reader thread aborts its current iteration. That is
bad, because it aborts before it can ever set the flag which tells that
the file is over (also, any remaining data which FSRead did return is
lost - so you'd not hear about to 4 seconds from the end of the file.
Furthermore, the computed data size was 8 bytes to high (I forgot to
account for the fact that the size of an (A)IFF chunk always contains
the chunk header & size fields, too). This is enough to make it work.
However, the end condition is rather fragile, so I tuned some other
things to be pessimistic (check for <= 0 instead of == 0, when eofErr
is encountered enforce mReadFilePosition == mFileLength). You never
know...
The attached patch fixes the issue for me.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 05 Jan 2004 00:57:51 +0000 |
parents | 55f1f1b3e27d |
children | 355632dca928 |
rev | line source |
---|---|
0 | 1 <HTML |
2 ><HEAD | |
3 ><TITLE | |
4 >Audio</TITLE | |
5 ><META | |
6 NAME="GENERATOR" | |
55
55f1f1b3e27d
Added new docs for SDL 1.2.1
Sam Lantinga <slouken@lokigames.com>
parents:
0
diff
changeset
|
7 CONTENT="Modular DocBook HTML Stylesheet Version 1.64 |
0 | 8 "><LINK |
9 REL="HOME" | |
10 TITLE="SDL Library Documentation" | |
11 HREF="index.html"><LINK | |
12 REL="UP" | |
13 TITLE="SDL Reference" | |
14 HREF="reference.html"><LINK | |
15 REL="PREVIOUS" | |
16 TITLE="SDL_JoystickClose" | |
17 HREF="sdljoystickclose.html"><LINK | |
18 REL="NEXT" | |
19 TITLE="SDL_AudioSpec" | |
20 HREF="sdlaudiospec.html"><META | |
21 NAME="KEYWORD" | |
22 CONTENT="audio"><META | |
23 NAME="KEYWORD" | |
24 CONTENT="function"></HEAD | |
25 ><BODY | |
26 CLASS="CHAPTER" | |
27 BGCOLOR="#FFF8DC" | |
28 TEXT="#000000" | |
29 LINK="#0000ee" | |
30 VLINK="#551a8b" | |
31 ALINK="#ff0000" | |
32 ><DIV | |
33 CLASS="NAVHEADER" | |
34 ><TABLE | |
35 WIDTH="100%" | |
36 BORDER="0" | |
37 CELLPADDING="0" | |
38 CELLSPACING="0" | |
39 ><TR | |
40 ><TH | |
41 COLSPAN="3" | |
42 ALIGN="center" | |
43 >SDL Library Documentation</TH | |
44 ></TR | |
45 ><TR | |
46 ><TD | |
47 WIDTH="10%" | |
48 ALIGN="left" | |
49 VALIGN="bottom" | |
50 ><A | |
51 HREF="sdljoystickclose.html" | |
52 >Prev</A | |
53 ></TD | |
54 ><TD | |
55 WIDTH="80%" | |
56 ALIGN="center" | |
57 VALIGN="bottom" | |
58 ></TD | |
59 ><TD | |
60 WIDTH="10%" | |
61 ALIGN="right" | |
62 VALIGN="bottom" | |
63 ><A | |
64 HREF="sdlaudiospec.html" | |
65 >Next</A | |
66 ></TD | |
67 ></TR | |
68 ></TABLE | |
69 ><HR | |
70 ALIGN="LEFT" | |
71 WIDTH="100%"></DIV | |
72 ><DIV | |
73 CLASS="CHAPTER" | |
74 ><H1 | |
75 ><A | |
76 NAME="AUDIO" | |
77 >Chapter 10. Audio</A | |
78 ></H1 | |
79 ><DIV | |
80 CLASS="TOC" | |
81 ><DL | |
82 ><DT | |
83 ><B | |
84 >Table of Contents</B | |
85 ></DT | |
86 ><DT | |
87 ><A | |
88 HREF="sdlaudiospec.html" | |
89 >SDL_AudioSpec</A | |
90 > — Audio Specification Structure</DT | |
91 ><DT | |
92 ><A | |
93 HREF="sdlopenaudio.html" | |
94 >SDL_OpenAudio</A | |
95 > — Opens the audio device with the desired parameters.</DT | |
96 ><DT | |
97 ><A | |
98 HREF="sdlpauseaudio.html" | |
99 >SDL_PauseAudio</A | |
100 > — Pauses and unpauses the audio callback processing</DT | |
101 ><DT | |
102 ><A | |
103 HREF="sdlgetaudiostatus.html" | |
104 >SDL_GetAudioStatus</A | |
105 > — Get the current audio state</DT | |
106 ><DT | |
107 ><A | |
108 HREF="sdlloadwav.html" | |
109 >SDL_LoadWAV</A | |
110 > — Load a WAVE file</DT | |
111 ><DT | |
112 ><A | |
113 HREF="sdlfreewav.html" | |
114 >SDL_FreeWAV</A | |
115 > — Frees previously opened WAV data</DT | |
116 ><DT | |
117 ><A | |
118 HREF="sdlaudiocvt.html" | |
119 >SDL_AudioCVT</A | |
120 > — Audio Conversion Structure</DT | |
121 ><DT | |
122 ><A | |
123 HREF="sdlbuildaudiocvt.html" | |
124 >SDL_BuildAudioCVT</A | |
125 > — Initializes a SDL_AudioCVT structure for conversion</DT | |
126 ><DT | |
127 ><A | |
128 HREF="sdlconvertaudio.html" | |
129 >SDL_ConvertAudio</A | |
130 > — Convert audio data to a desired audio format.</DT | |
131 ><DT | |
132 ><A | |
133 HREF="sdlmixaudio.html" | |
134 >SDL_MixAudio</A | |
135 > — Mix audio data</DT | |
136 ><DT | |
137 ><A | |
138 HREF="sdllockaudio.html" | |
139 >SDL_LockAudio</A | |
140 > — Lock out the callback function</DT | |
141 ><DT | |
142 ><A | |
143 HREF="sdlunlockaudio.html" | |
144 >SDL_UnlockAudio</A | |
145 > — Unlock the callback function</DT | |
146 ><DT | |
147 ><A | |
148 HREF="sdlcloseaudio.html" | |
149 >SDL_CloseAudio</A | |
150 > — Shuts down audio processing and closes the audio device.</DT | |
151 ></DL | |
152 ></DIV | |
153 ><P | |
154 >Sound on the computer is translated from waves that you hear into a series of | |
155 values, or samples, each representing the amplitude of the wave. When these | |
156 samples are sent in a stream to a sound card, an approximation of the original | |
157 wave can be recreated. The more bits used to represent the amplitude, and the | |
158 greater frequency these samples are gathered, the closer the approximated | |
159 sound is to the original, and the better the quality of sound.</P | |
160 ><P | |
161 >This library supports both 8 and 16 bit signed and unsigned sound samples, | |
162 at frequencies ranging from 11025 Hz to 44100 Hz, depending on the | |
163 underlying hardware. If the hardware doesn't support the desired audio | |
164 format or frequency, it can be emulated if desired (See | |
165 <A | |
166 HREF="sdlopenaudio.html" | |
167 ><TT | |
168 CLASS="FUNCTION" | |
169 >SDL_OpenAudio()</TT | |
170 ></A | |
171 >)</P | |
172 ><P | |
173 >A commonly supported audio format is 16 bits per sample at 22050 Hz.</P | |
174 ></DIV | |
175 ><DIV | |
176 CLASS="NAVFOOTER" | |
177 ><HR | |
178 ALIGN="LEFT" | |
179 WIDTH="100%"><TABLE | |
180 WIDTH="100%" | |
181 BORDER="0" | |
182 CELLPADDING="0" | |
183 CELLSPACING="0" | |
184 ><TR | |
185 ><TD | |
186 WIDTH="33%" | |
187 ALIGN="left" | |
188 VALIGN="top" | |
189 ><A | |
190 HREF="sdljoystickclose.html" | |
191 >Prev</A | |
192 ></TD | |
193 ><TD | |
194 WIDTH="34%" | |
195 ALIGN="center" | |
196 VALIGN="top" | |
197 ><A | |
198 HREF="index.html" | |
199 >Home</A | |
200 ></TD | |
201 ><TD | |
202 WIDTH="33%" | |
203 ALIGN="right" | |
204 VALIGN="top" | |
205 ><A | |
206 HREF="sdlaudiospec.html" | |
207 >Next</A | |
208 ></TD | |
209 ></TR | |
210 ><TR | |
211 ><TD | |
212 WIDTH="33%" | |
213 ALIGN="left" | |
214 VALIGN="top" | |
215 >SDL_JoystickClose</TD | |
216 ><TD | |
217 WIDTH="34%" | |
218 ALIGN="center" | |
219 VALIGN="top" | |
220 ><A | |
221 HREF="reference.html" | |
222 >Up</A | |
223 ></TD | |
224 ><TD | |
225 WIDTH="33%" | |
226 ALIGN="right" | |
227 VALIGN="top" | |
228 >SDL_AudioSpec</TD | |
229 ></TR | |
230 ></TABLE | |
231 ></DIV | |
232 ></BODY | |
233 ></HTML | |
234 > |