Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_stfa.c @ 2005:45af7d69f8eb
MiNT audio driver cleanups for clamping types and channels to supported
values. int32 support now available in one instance.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 01 Sep 2006 06:32:54 +0000 |
parents | c121d94672cb |
children | d48ead2d2ba5 |
comparison
equal
deleted
inserted
replaced
2004:c27292a690b7 | 2005:45af7d69f8eb |
---|---|
204 static int | 204 static int |
205 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) | 205 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) |
206 { | 206 { |
207 int i; | 207 int i; |
208 | 208 |
209 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); | 209 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format))); |
210 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); | 210 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); |
211 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); | 211 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format))); |
212 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format))); | |
212 DEBUG_PRINT(("channels=%d, ", spec->channels)); | 213 DEBUG_PRINT(("channels=%d, ", spec->channels)); |
213 DEBUG_PRINT(("freq=%d\n", spec->freq)); | 214 DEBUG_PRINT(("freq=%d\n", spec->freq)); |
215 | |
216 if (SDL_AUDIO_BITSIZE(spec->format) > 16) { | |
217 spec->format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ | |
218 } | |
219 | |
220 if (spec->channels > 2) { | |
221 spec->channels = 2; /* no more than stereo! */ | |
222 } | |
214 | 223 |
215 /* Check formats available */ | 224 /* Check formats available */ |
216 MINTAUDIO_freqcount = 0; | 225 MINTAUDIO_freqcount = 0; |
217 for (i = 0; i < 16; i++) { | 226 for (i = 0; i < 16; i++) { |
218 SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1); | 227 SDL_MintAudio_AddFrequency(this, freqs[i], 0, i, -1); |
228 #endif | 237 #endif |
229 | 238 |
230 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); | 239 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); |
231 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; | 240 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; |
232 | 241 |
233 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); | 242 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format))); |
234 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); | 243 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format))); |
235 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); | 244 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format))); |
245 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format))); | |
236 DEBUG_PRINT(("channels=%d, ", spec->channels)); | 246 DEBUG_PRINT(("channels=%d, ", spec->channels)); |
237 DEBUG_PRINT(("freq=%d\n", spec->freq)); | 247 DEBUG_PRINT(("freq=%d\n", spec->freq)); |
238 | 248 |
239 return 0; | 249 return 0; |
240 } | 250 } |
253 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; | 263 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; |
254 | 264 |
255 /* Select replay format */ | 265 /* Select replay format */ |
256 cookie_stfa->sound_control = | 266 cookie_stfa->sound_control = |
257 MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; | 267 MINTAUDIO_frequencies[MINTAUDIO_numfreq].predivisor; |
258 if ((spec->format & 0xff) == 8) { | 268 if (SDL_AUDIO_BITSIZE(spec->format) == 8) { |
259 cookie_stfa->sound_control |= STFA_FORMAT_8BIT; | 269 cookie_stfa->sound_control |= STFA_FORMAT_8BIT; |
260 } else { | 270 } else { |
261 cookie_stfa->sound_control |= STFA_FORMAT_16BIT; | 271 cookie_stfa->sound_control |= STFA_FORMAT_16BIT; |
262 } | 272 } |
263 if (spec->channels == 2) { | 273 if (spec->channels == 2) { |
264 cookie_stfa->sound_control |= STFA_FORMAT_STEREO; | 274 cookie_stfa->sound_control |= STFA_FORMAT_STEREO; |
265 } else { | 275 } else { |
266 cookie_stfa->sound_control |= STFA_FORMAT_MONO; | 276 cookie_stfa->sound_control |= STFA_FORMAT_MONO; |
267 } | 277 } |
268 if ((spec->format & 0x8000) != 0) { | 278 if (SDL_AUDIO_ISSIGNED(spec->format) != 0) { |
269 cookie_stfa->sound_control |= STFA_FORMAT_SIGNED; | 279 cookie_stfa->sound_control |= STFA_FORMAT_SIGNED; |
270 } else { | 280 } else { |
271 cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED; | 281 cookie_stfa->sound_control |= STFA_FORMAT_UNSIGNED; |
272 } | 282 } |
273 if ((spec->format & 0x1000) != 0) { | 283 if (SDL_AUDIO_ISBIGENDIAN(spec->format) != 0) { |
274 cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN; | 284 cookie_stfa->sound_control |= STFA_FORMAT_BIGENDIAN; |
275 } else { | 285 } else { |
276 cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN; | 286 cookie_stfa->sound_control |= STFA_FORMAT_LITENDIAN; |
277 } | 287 } |
278 | 288 |