comparison src/audio/mint/SDL_mintaudio_xbios.c @ 2060:866052b01ee5

indent is evil
author Sam Lantinga <slouken@libsdl.org>
date Sat, 28 Oct 2006 16:48:03 +0000
parents 5f6550e5184f
children 29e07f91bc1f
comparison
equal deleted inserted replaced
2059:4685ccd33d0e 2060:866052b01ee5
88 /* Uninstall interrupt */ 88 /* Uninstall interrupt */
89 Jdisint(MFP_DMASOUND); 89 Jdisint(MFP_DMASOUND);
90 } 90 }
91 91
92 /* Wait if currently playing sound */ 92 /* Wait if currently playing sound */
93 while (SDL_MintAudio_mutex != 0) {} 93 while (SDL_MintAudio_mutex != 0) {
94 }
94 95
95 /* Clear buffers */ 96 /* Clear buffers */
96 if (SDL_MintAudio_audiobuf[0]) { 97 if (SDL_MintAudio_audiobuf[0]) {
97 Mfree(SDL_MintAudio_audiobuf[0]); 98 Mfree(SDL_MintAudio_audiobuf[0]);
98 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; 99 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
265 266
266 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", 267 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
267 SDL_AUDIO_BITSIZE(this->spec.format))); 268 SDL_AUDIO_BITSIZE(this->spec.format)));
268 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); 269 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
269 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); 270 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
270 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); 271 DEBUG_PRINT(("big endian=%d, ",
272 SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
271 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); 273 DEBUG_PRINT(("channels=%d, ", this->spec.channels));
272 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); 274 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
273 275
274 this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */ 276 this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
275 277
276 /* clamp out int32/float32 */ 278 /* clamp out int32/float32 */
277 if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) { 279 if (SDL_AUDIO_BITSIZE(this->spec.format) >= 16) {
278 this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */ 280 this->spec.format = AUDIO_S16MSB; /* Audio is always big endian */
279 this->spec.channels = 2; /* 16 bits always stereo */ 281 this->spec.channels = 2; /* 16 bits always stereo */
280 } else if (this->spec.channels > 2) { 282 } else if (this->spec.channels > 2) {
281 this->spec.channels = 2; /* no more than stereo! */ 283 this->spec.channels = 2; /* no more than stereo! */
282 } 284 }
283 285
284 MINTAUDIO_freqcount = 0; 286 MINTAUDIO_freqcount = 0;
285 287
286 /* Add external clocks if present */ 288 /* Add external clocks if present */
312 314
313 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", 315 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
314 SDL_AUDIO_BITSIZE(this->spec.format))); 316 SDL_AUDIO_BITSIZE(this->spec.format)));
315 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); 317 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
316 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); 318 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
317 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); 319 DEBUG_PRINT(("big endian=%d, ",
320 SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
318 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); 321 DEBUG_PRINT(("channels=%d, ", this->spec.channels));
319 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); 322 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
320 323
321 return 0; 324 return 0;
322 } 325 }
403 return 0; 406 return 0;
404 } 407 }
405 408
406 /* Initialize all variables that we clean on shutdown */ 409 /* Initialize all variables that we clean on shutdown */
407 this->hidden = (struct SDL_PrivateAudioData *) 410 this->hidden = (struct SDL_PrivateAudioData *)
408 SDL_malloc((sizeof *this->hidden)); 411 SDL_malloc((sizeof *this->hidden));
409 if (this->hidden == NULL) { 412 if (this->hidden == NULL) {
410 SDL_OutOfMemory(); 413 SDL_OutOfMemory();
411 return 0; 414 return 0;
412 } 415 }
413 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); 416 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
415 SDL_CalculateAudioSpec(&this->spec); 418 SDL_CalculateAudioSpec(&this->spec);
416 419
417 /* Allocate memory for audio buffers in DMA-able RAM */ 420 /* Allocate memory for audio buffers in DMA-able RAM */
418 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); 421 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
419 422
420 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); 423 SDL_MintAudio_audiobuf[0] =
424 Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
421 if (SDL_MintAudio_audiobuf[0] == NULL) { 425 if (SDL_MintAudio_audiobuf[0] == NULL) {
422 SDL_free(this->hidden); 426 SDL_free(this->hidden);
423 this->hidden = NULL; 427 this->hidden = NULL;
424 SDL_OutOfMemory(); 428 SDL_OutOfMemory();
425 return 0; 429 return 0;
426 } 430 }
427 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; 431 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
428 SDL_MintAudio_numbuf = 0; 432 SDL_MintAudio_numbuf = 0;
429 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); 433 SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
434 this->spec.size * 2);
430 SDL_MintAudio_audiosize = this->spec.size; 435 SDL_MintAudio_audiosize = this->spec.size;
431 SDL_MintAudio_mutex = 0; 436 SDL_MintAudio_mutex = 0;
432 437
433 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", 438 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
434 SDL_MintAudio_audiobuf[0])); 439 SDL_MintAudio_audiobuf[0]));
438 SDL_MintAudio_CheckFpu(); 443 SDL_MintAudio_CheckFpu();
439 444
440 /* Setup audio hardware */ 445 /* Setup audio hardware */
441 MINTXBIOS_InitAudio(this); 446 MINTXBIOS_InitAudio(this);
442 447
443 return 1; /* good to go. */ 448 return 1; /* good to go. */
444 } 449 }
445 450
446 static int 451 static int
447 MINTXBIOS_Init(SDL_AudioDriverImpl *impl) 452 MINTXBIOS_Init(SDL_AudioDriverImpl * impl)
448 { 453 {
449 unsigned long dummy = 0; 454 unsigned long dummy = 0;
450 /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */ 455 /*SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); */
451 SDL_MintAudio_mint_present = SDL_FALSE; 456 SDL_MintAudio_mint_present = SDL_FALSE;
452 457