Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_gsxb.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 |
---|---|
92 if (NSetinterrupt(2, SI_NONE, MINTGSXB_GsxbNullInterrupt) < 0) { | 92 if (NSetinterrupt(2, SI_NONE, MINTGSXB_GsxbNullInterrupt) < 0) { |
93 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); | 93 DEBUG_PRINT((DEBUG_NAME "NSetinterrupt() failed in close\n")); |
94 } | 94 } |
95 | 95 |
96 /* Wait if currently playing sound */ | 96 /* Wait if currently playing sound */ |
97 while (SDL_MintAudio_mutex != 0) {} | 97 while (SDL_MintAudio_mutex != 0) { |
98 } | |
98 | 99 |
99 /* Clear buffers */ | 100 /* Clear buffers */ |
100 if (SDL_MintAudio_audiobuf[0]) { | 101 if (SDL_MintAudio_audiobuf[0]) { |
101 Mfree(SDL_MintAudio_audiobuf[0]); | 102 Mfree(SDL_MintAudio_audiobuf[0]); |
102 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; | 103 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; |
128 DEBUG_PRINT(("big endian=%d, ", format_bigendian)); | 129 DEBUG_PRINT(("big endian=%d, ", format_bigendian)); |
129 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); | 130 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
130 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); | 131 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
131 | 132 |
132 if (this->spec.channels > 2) { | 133 if (this->spec.channels > 2) { |
133 this->spec.channels = 2; /* no more than stereo! */ | 134 this->spec.channels = 2; /* no more than stereo! */ |
134 } | 135 } |
135 | 136 |
136 while ((!valid_datatype) && (test_format)) { | 137 while ((!valid_datatype) && (test_format)) { |
137 /* Check formats available */ | 138 /* Check formats available */ |
138 snd_format = Sndstatus(SND_QUERYFORMATS); | 139 snd_format = Sndstatus(SND_QUERYFORMATS); |
139 this->spec.format = test_format; | 140 this->spec.format = test_format; |
140 resolution = SDL_AUDIO_BITSIZE(this->spec.format); | 141 resolution = SDL_AUDIO_BITSIZE(this->spec.format); |
141 format_signed = SDL_AUDIO_ISSIGNED(this->spec.format); | 142 format_signed = SDL_AUDIO_ISSIGNED(this->spec.format); |
142 format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format); | 143 format_bigendian = SDL_AUDIO_ISBIGENDIAN(this->spec.format); |
143 switch (test_format) { | 144 switch (test_format) { |
144 case AUDIO_U8: | 145 case AUDIO_U8: |
145 case AUDIO_S8: | 146 case AUDIO_S8: |
146 if (snd_format & SND_FORMAT8) { | 147 if (snd_format & SND_FORMAT8) { |
147 valid_datatype = 1; | 148 valid_datatype = 1; |
148 snd_format = Sndstatus(SND_QUERY8BIT); | 149 snd_format = Sndstatus(SND_QUERY8BIT); |
149 } | 150 } |
150 break; | 151 break; |
151 | 152 |
152 case AUDIO_U16LSB: | 153 case AUDIO_U16LSB: |
153 case AUDIO_S16LSB: | 154 case AUDIO_S16LSB: |
154 case AUDIO_U16MSB: | 155 case AUDIO_U16MSB: |
155 case AUDIO_S16MSB: | 156 case AUDIO_S16MSB: |
156 if (snd_format & SND_FORMAT16) { | 157 if (snd_format & SND_FORMAT16) { |
157 valid_datatype = 1; | 158 valid_datatype = 1; |
158 snd_format = Sndstatus(SND_QUERY16BIT); | 159 snd_format = Sndstatus(SND_QUERY16BIT); |
159 } | 160 } |
160 break; | 161 break; |
161 | 162 |
162 case AUDIO_S32LSB: | 163 case AUDIO_S32LSB: |
163 case AUDIO_S32MSB: | 164 case AUDIO_S32MSB: |
164 if (snd_format & SND_FORMAT32) { | 165 if (snd_format & SND_FORMAT32) { |
165 valid_datatype = 1; | 166 valid_datatype = 1; |
166 snd_format = Sndstatus(SND_QUERY32BIT); | 167 snd_format = Sndstatus(SND_QUERY32BIT); |
167 } | 168 } |
168 break; | 169 break; |
169 | 170 |
170 /* no float support... */ | 171 /* no float support... */ |
171 | 172 |
172 default: | 173 default: |
173 test_format = SDL_NextAudioFormat(); | 174 test_format = SDL_NextAudioFormat(); |
174 break; | 175 break; |
175 } | 176 } |
176 } | 177 } |
177 | 178 |
178 if (!valid_datatype) { | 179 if (!valid_datatype) { |
179 SDL_SetError("Unsupported audio format"); | 180 SDL_SetError("Unsupported audio format"); |
236 | 237 |
237 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", | 238 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", |
238 SDL_AUDIO_BITSIZE(this->spec.format))); | 239 SDL_AUDIO_BITSIZE(this->spec.format))); |
239 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); | 240 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
240 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); | 241 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
241 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | 242 DEBUG_PRINT(("big endian=%d, ", |
243 SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | |
242 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); | 244 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
243 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); | 245 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
244 | 246 |
245 return 0; | 247 return 0; |
246 } | 248 } |
324 return 0; | 326 return 0; |
325 } | 327 } |
326 | 328 |
327 /* Initialize all variables that we clean on shutdown */ | 329 /* Initialize all variables that we clean on shutdown */ |
328 this->hidden = (struct SDL_PrivateAudioData *) | 330 this->hidden = (struct SDL_PrivateAudioData *) |
329 SDL_malloc((sizeof *this->hidden)); | 331 SDL_malloc((sizeof *this->hidden)); |
330 if (this->hidden == NULL) { | 332 if (this->hidden == NULL) { |
331 SDL_OutOfMemory(); | 333 SDL_OutOfMemory(); |
332 return 0; | 334 return 0; |
333 } | 335 } |
334 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | 336 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
336 SDL_CalculateAudioSpec(&this->spec); | 338 SDL_CalculateAudioSpec(&this->spec); |
337 | 339 |
338 /* Allocate memory for audio buffers in DMA-able RAM */ | 340 /* Allocate memory for audio buffers in DMA-able RAM */ |
339 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); | 341 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); |
340 | 342 |
341 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); | 343 SDL_MintAudio_audiobuf[0] = |
344 Atari_SysMalloc(this->spec.size * 2, MX_STRAM); | |
342 if (SDL_MintAudio_audiobuf[0] == NULL) { | 345 if (SDL_MintAudio_audiobuf[0] == NULL) { |
343 SDL_free(this->hidden); | 346 SDL_free(this->hidden); |
344 this->hidden = NULL; | 347 this->hidden = NULL; |
345 SDL_OutOfMemory(); | 348 SDL_OutOfMemory(); |
346 return 0; | 349 return 0; |
347 } | 350 } |
348 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; | 351 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; |
349 SDL_MintAudio_numbuf = 0; | 352 SDL_MintAudio_numbuf = 0; |
350 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); | 353 SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence, |
354 this->spec.size * 2); | |
351 SDL_MintAudio_audiosize = this->spec.size; | 355 SDL_MintAudio_audiosize = this->spec.size; |
352 SDL_MintAudio_mutex = 0; | 356 SDL_MintAudio_mutex = 0; |
353 | 357 |
354 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", | 358 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", |
355 SDL_MintAudio_audiobuf[0])); | 359 SDL_MintAudio_audiobuf[0])); |
359 SDL_MintAudio_CheckFpu(); | 363 SDL_MintAudio_CheckFpu(); |
360 | 364 |
361 /* Setup audio hardware */ | 365 /* Setup audio hardware */ |
362 MINTGSXB_InitAudio(this); | 366 MINTGSXB_InitAudio(this); |
363 | 367 |
364 return 1; /* good to go. */ | 368 return 1; /* good to go. */ |
365 } | 369 } |
366 | 370 |
367 static void | 371 static void |
368 MINTGSXB_GsxbInterrupt(void) | 372 MINTGSXB_GsxbInterrupt(void) |
369 { | 373 { |
386 MINTGSXB_GsxbNullInterrupt(void) | 390 MINTGSXB_GsxbNullInterrupt(void) |
387 { | 391 { |
388 } | 392 } |
389 | 393 |
390 static int | 394 static int |
391 MINTGSXB_Init(SDL_AudioDriverImpl *impl) | 395 MINTGSXB_Init(SDL_AudioDriverImpl * impl) |
392 { | 396 { |
393 /* Cookie _SND present ? if not, assume ST machine */ | 397 /* Cookie _SND present ? if not, assume ST machine */ |
394 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { | 398 if (Getcookie(C__SND, &cookie_snd) == C_NOTFOUND) { |
395 cookie_snd = SND_PSG; | 399 cookie_snd = SND_PSG; |
396 } | 400 } |