comparison src/audio/mint/SDL_mintaudio_mcsn.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
223 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec) 223 Mint_CheckAudio(_THIS, SDL_AudioSpec * spec)
224 { 224 {
225 int i; 225 int i;
226 unsigned long masterclock, masterprediv; 226 unsigned long masterclock, masterprediv;
227 227
228 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", spec->format & 0x00ff)); 228 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
229 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); 229 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
230 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); 230 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
231 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
231 DEBUG_PRINT(("channels=%d, ", spec->channels)); 232 DEBUG_PRINT(("channels=%d, ", spec->channels));
232 DEBUG_PRINT(("freq=%d\n", spec->freq)); 233 DEBUG_PRINT(("freq=%d\n", spec->freq));
234
235 if (spec->channels > 2) {
236 spec->channels = 2; /* no more than stereo! */
237 }
233 238
234 /* Check formats available */ 239 /* Check formats available */
235 MINTAUDIO_freqcount = 0; 240 MINTAUDIO_freqcount = 0;
236 switch (cookie_mcsn->play) { 241 switch (cookie_mcsn->play) {
237 case MCSN_ST: 242 case MCSN_ST:
238 spec->channels = 1; 243 spec->channels = 1;
239 spec->format = 8; /* FIXME: is it signed or unsigned ? */ 244 spec->format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */
240 SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1); 245 SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
241 break; 246 break;
242 case MCSN_TT: /* Also STE, Mega STE */ 247 case MCSN_TT: /* Also STE, Mega STE */
243 spec->format = AUDIO_S8; 248 spec->format = AUDIO_S8;
244 masterclock = MASTERCLOCK_STE; 249 masterclock = MASTERCLOCK_STE;
272 (MASTERPREDIV_FALCON * 277 (MASTERPREDIV_FALCON *
273 (1 << i)), CLKEXT, 278 (1 << i)), CLKEXT,
274 (1 << i) - 1, -1); 279 (1 << i) - 1, -1);
275 } 280 }
276 } 281 }
277 spec->format |= 0x8000; /* Audio is always signed */ 282 spec->format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
278 if ((spec->format & 0x00ff) == 16) { 283 if ((SDL_AUDIO_BITSIZE(spec->format)) == 16) {
279 spec->format |= 0x1000; /* Audio is always big endian */ 284 spec->format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
280 spec->channels = 2; /* 16 bits always stereo */ 285 spec->channels = 2; /* 16 bits always stereo */
281 } 286 }
282 break; 287 break;
283 } 288 }
284 289
292 #endif 297 #endif
293 298
294 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq); 299 MINTAUDIO_numfreq = SDL_MintAudio_SearchFrequency(this, spec->freq);
295 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency; 300 spec->freq = MINTAUDIO_frequencies[MINTAUDIO_numfreq].frequency;
296 301
297 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", spec->format & 0x00ff)); 302 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", SDL_AUDIO_BITSIZE(spec->format)));
298 DEBUG_PRINT(("signed=%d, ", ((spec->format & 0x8000) != 0))); 303 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(spec->format)));
299 DEBUG_PRINT(("big endian=%d, ", ((spec->format & 0x1000) != 0))); 304 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(spec->format)));
305 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(spec->format)));
300 DEBUG_PRINT(("channels=%d, ", spec->channels)); 306 DEBUG_PRINT(("channels=%d, ", spec->channels));
301 DEBUG_PRINT(("freq=%d\n", spec->freq)); 307 DEBUG_PRINT(("freq=%d\n", spec->freq));
302 308
303 return 0; 309 return 0;
304 } 310 }
319 Settracks(0, 0); 325 Settracks(0, 0);
320 Setmontracks(0); 326 Setmontracks(0);
321 327
322 /* Select replay format */ 328 /* Select replay format */
323 channels_mode = STEREO16; 329 channels_mode = STEREO16;
324 switch (spec->format & 0xff) { 330 switch (SDL_AUDIO_BITSIZE(spec->format)) {
325 case 8: 331 case 8:
326 if (spec->channels == 2) { 332 if (spec->channels == 2) {
327 channels_mode = STEREO8; 333 channels_mode = STEREO8;
328 } else { 334 } else {
329 channels_mode = MONO8; 335 channels_mode = MONO8;