comparison src/audio/mint/SDL_mintaudio_mcsn.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
91 /* Uninstall interrupt */ 91 /* Uninstall interrupt */
92 Jdisint(MFP_DMASOUND); 92 Jdisint(MFP_DMASOUND);
93 } 93 }
94 94
95 /* Wait if currently playing sound */ 95 /* Wait if currently playing sound */
96 while (SDL_MintAudio_mutex != 0) {} 96 while (SDL_MintAudio_mutex != 0) {
97 }
97 98
98 /* Clear buffers */ 99 /* Clear buffers */
99 if (SDL_MintAudio_audiobuf[0]) { 100 if (SDL_MintAudio_audiobuf[0]) {
100 Mfree(SDL_MintAudio_audiobuf[0]); 101 Mfree(SDL_MintAudio_audiobuf[0]);
101 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; 102 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL;
117 118
118 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", 119 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ",
119 SDL_AUDIO_BITSIZE(this->spec.format))); 120 SDL_AUDIO_BITSIZE(this->spec.format)));
120 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); 121 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
121 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); 122 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
122 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); 123 DEBUG_PRINT(("big endian=%d, ",
124 SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
123 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); 125 DEBUG_PRINT(("channels=%d, ", this->spec.channels));
124 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); 126 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
125 127
126 if (this->spec.channels > 2) { 128 if (this->spec.channels > 2) {
127 this->spec.channels = 2; /* no more than stereo! */ 129 this->spec.channels = 2; /* no more than stereo! */
128 } 130 }
129 131
130 /* Check formats available */ 132 /* Check formats available */
131 MINTAUDIO_freqcount = 0; 133 MINTAUDIO_freqcount = 0;
132 switch (cookie_mcsn->play) { 134 switch (cookie_mcsn->play) {
133 case MCSN_ST: 135 case MCSN_ST:
134 this->spec.channels = 1; 136 this->spec.channels = 1;
135 this->spec.format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */ 137 this->spec.format = AUDIO_S8; /* FIXME: is it signed or unsigned ? */
136 SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1); 138 SDL_MintAudio_AddFrequency(this, 12500, 0, 0, -1);
137 break; 139 break;
138 case MCSN_TT: /* Also STE, Mega STE */ 140 case MCSN_TT: /* Also STE, Mega STE */
139 this->spec.format = AUDIO_S8; 141 this->spec.format = AUDIO_S8;
140 masterclock = MASTERCLOCK_STE; 142 masterclock = MASTERCLOCK_STE;
168 (MASTERPREDIV_FALCON * 170 (MASTERPREDIV_FALCON *
169 (1 << i)), CLKEXT, 171 (1 << i)), CLKEXT,
170 (1 << i) - 1, -1); 172 (1 << i) - 1, -1);
171 } 173 }
172 } 174 }
173 this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */ 175 this->spec.format |= SDL_AUDIO_MASK_SIGNED; /* Audio is always signed */
174 if ((SDL_AUDIO_BITSIZE(this->spec.format)) == 16) { 176 if ((SDL_AUDIO_BITSIZE(this->spec.format)) == 16) {
175 this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */ 177 this->spec.format |= SDL_AUDIO_MASK_ENDIAN; /* Audio is always big endian */
176 this->spec.channels = 2; /* 16 bits always stereo */ 178 this->spec.channels = 2; /* 16 bits always stereo */
177 } 179 }
178 break; 180 break;
179 } 181 }
180 182
181 #if 1 183 #if 1
192 194
193 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", 195 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ",
194 SDL_AUDIO_BITSIZE(this->spec.format))); 196 SDL_AUDIO_BITSIZE(this->spec.format)));
195 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); 197 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format)));
196 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); 198 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format)));
197 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); 199 DEBUG_PRINT(("big endian=%d, ",
200 SDL_AUDIO_ISBIGENDIAN(this->spec.format)));
198 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); 201 DEBUG_PRINT(("channels=%d, ", this->spec.channels));
199 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); 202 DEBUG_PRINT(("freq=%d\n", this->spec.freq));
200 203
201 return 0; 204 return 0;
202 } 205 }
286 return 0; 289 return 0;
287 } 290 }
288 291
289 /* Initialize all variables that we clean on shutdown */ 292 /* Initialize all variables that we clean on shutdown */
290 this->hidden = (struct SDL_PrivateAudioData *) 293 this->hidden = (struct SDL_PrivateAudioData *)
291 SDL_malloc((sizeof *this->hidden)); 294 SDL_malloc((sizeof *this->hidden));
292 if (this->hidden == NULL) { 295 if (this->hidden == NULL) {
293 SDL_OutOfMemory(); 296 SDL_OutOfMemory();
294 return 0; 297 return 0;
295 } 298 }
296 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); 299 SDL_memset(this->hidden, 0, (sizeof *this->hidden));
298 SDL_CalculateAudioSpec(&this->spec); 301 SDL_CalculateAudioSpec(&this->spec);
299 302
300 /* Allocate memory for audio buffers in DMA-able RAM */ 303 /* Allocate memory for audio buffers in DMA-able RAM */
301 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); 304 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size));
302 305
303 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); 306 SDL_MintAudio_audiobuf[0] =
307 Atari_SysMalloc(this->spec.size * 2, MX_STRAM);
304 if (SDL_MintAudio_audiobuf[0] == NULL) { 308 if (SDL_MintAudio_audiobuf[0] == NULL) {
305 SDL_free(this->hidden); 309 SDL_free(this->hidden);
306 this->hidden = NULL; 310 this->hidden = NULL;
307 SDL_OutOfMemory(); 311 SDL_OutOfMemory();
308 return 0; 312 return 0;
309 } 313 }
310 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; 314 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size;
311 SDL_MintAudio_numbuf = 0; 315 SDL_MintAudio_numbuf = 0;
312 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); 316 SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence,
317 this->spec.size * 2);
313 SDL_MintAudio_audiosize = this->spec.size; 318 SDL_MintAudio_audiosize = this->spec.size;
314 SDL_MintAudio_mutex = 0; 319 SDL_MintAudio_mutex = 0;
315 320
316 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", 321 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n",
317 SDL_MintAudio_audiobuf[0])); 322 SDL_MintAudio_audiobuf[0]));
321 SDL_MintAudio_CheckFpu(); 326 SDL_MintAudio_CheckFpu();
322 327
323 /* Setup audio hardware */ 328 /* Setup audio hardware */
324 MINTMCSN_InitAudio(this); 329 MINTMCSN_InitAudio(this);
325 330
326 return 1; /* good to go. */ 331 return 1; /* good to go. */
327 } 332 }
328 333
329 static int 334 static int
330 MINTMCSN_Init(SDL_AudioDriverImpl *impl) 335 MINTMCSN_Init(SDL_AudioDriverImpl * impl)
331 { 336 {
332 unsigned long dummy = 0; 337 unsigned long dummy = 0;
333 338
334 SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND); 339 SDL_MintAudio_mint_present = (Getcookie(C_MiNT, &dummy) == C_FOUND);
335 340