Mercurial > sdl-ios-xcode
comparison src/audio/mint/SDL_mintaudio_stfa.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 |
---|---|
96 void *oldpile = (void *) Super(0); | 96 void *oldpile = (void *) Super(0); |
97 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; | 97 cookie_stfa->sound_enable = STFA_PLAY_DISABLE; |
98 Super(oldpile); | 98 Super(oldpile); |
99 | 99 |
100 /* Wait if currently playing sound */ | 100 /* Wait if currently playing sound */ |
101 while (SDL_MintAudio_mutex != 0) {} | 101 while (SDL_MintAudio_mutex != 0) { |
102 } | |
102 | 103 |
103 /* Clear buffers */ | 104 /* Clear buffers */ |
104 if (SDL_MintAudio_audiobuf[0]) { | 105 if (SDL_MintAudio_audiobuf[0]) { |
105 Mfree(SDL_MintAudio_audiobuf[0]); | 106 Mfree(SDL_MintAudio_audiobuf[0]); |
106 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; | 107 SDL_MintAudio_audiobuf[0] = SDL_MintAudio_audiobuf[1] = NULL; |
118 | 119 |
119 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", | 120 DEBUG_PRINT((DEBUG_NAME "asked: %d bits, ", |
120 SDL_AUDIO_BITSIZE(this->spec.format))); | 121 SDL_AUDIO_BITSIZE(this->spec.format))); |
121 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); | 122 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
122 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); | 123 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
123 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | 124 DEBUG_PRINT(("big endian=%d, ", |
125 SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | |
124 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); | 126 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
125 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); | 127 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
126 | 128 |
127 if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) { | 129 if (SDL_AUDIO_BITSIZE(this->spec.format) > 16) { |
128 this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ | 130 this->spec.format = AUDIO_S16SYS; /* clamp out int32/float32 ... */ |
129 } | 131 } |
130 | 132 |
131 if (this->spec.channels > 2) { | 133 if (this->spec.channels > 2) { |
132 this->spec.channels = 2; /* no more than stereo! */ | 134 this->spec.channels = 2; /* no more than stereo! */ |
133 } | 135 } |
134 | 136 |
135 /* Check formats available */ | 137 /* Check formats available */ |
136 MINTAUDIO_freqcount = 0; | 138 MINTAUDIO_freqcount = 0; |
137 for (i = 0; i < 16; i++) { | 139 for (i = 0; i < 16; i++) { |
152 | 154 |
153 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", | 155 DEBUG_PRINT((DEBUG_NAME "obtained: %d bits, ", |
154 SDL_AUDIO_BITSIZE(this->spec.format))); | 156 SDL_AUDIO_BITSIZE(this->spec.format))); |
155 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); | 157 DEBUG_PRINT(("float=%d, ", SDL_AUDIO_ISFLOAT(this->spec.format))); |
156 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); | 158 DEBUG_PRINT(("signed=%d, ", SDL_AUDIO_ISSIGNED(this->spec.format))); |
157 DEBUG_PRINT(("big endian=%d, ", SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | 159 DEBUG_PRINT(("big endian=%d, ", |
160 SDL_AUDIO_ISBIGENDIAN(this->spec.format))); | |
158 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); | 161 DEBUG_PRINT(("channels=%d, ", this->spec.channels)); |
159 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); | 162 DEBUG_PRINT(("freq=%d\n", this->spec.freq)); |
160 | 163 |
161 return 0; | 164 return 0; |
162 } | 165 } |
219 return 0; | 222 return 0; |
220 } | 223 } |
221 | 224 |
222 /* Initialize all variables that we clean on shutdown */ | 225 /* Initialize all variables that we clean on shutdown */ |
223 this->hidden = (struct SDL_PrivateAudioData *) | 226 this->hidden = (struct SDL_PrivateAudioData *) |
224 SDL_malloc((sizeof *this->hidden)); | 227 SDL_malloc((sizeof *this->hidden)); |
225 if (this->hidden == NULL) { | 228 if (this->hidden == NULL) { |
226 SDL_OutOfMemory(); | 229 SDL_OutOfMemory(); |
227 return 0; | 230 return 0; |
228 } | 231 } |
229 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | 232 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
231 SDL_CalculateAudioSpec(&this->spec); | 234 SDL_CalculateAudioSpec(&this->spec); |
232 | 235 |
233 /* Allocate memory for audio buffers in DMA-able RAM */ | 236 /* Allocate memory for audio buffers in DMA-able RAM */ |
234 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); | 237 DEBUG_PRINT((DEBUG_NAME "buffer size=%d\n", this->spec.size)); |
235 | 238 |
236 SDL_MintAudio_audiobuf[0] = Atari_SysMalloc(this->spec.size * 2, MX_STRAM); | 239 SDL_MintAudio_audiobuf[0] = |
240 Atari_SysMalloc(this->spec.size * 2, MX_STRAM); | |
237 if (SDL_MintAudio_audiobuf[0] == NULL) { | 241 if (SDL_MintAudio_audiobuf[0] == NULL) { |
238 SDL_OutOfMemory() | 242 SDL_OutOfMemory() |
239 SDL_free(this->hidden); | 243 SDL_free(this->hidden); |
240 this->hidden = NULL; | 244 this->hidden = NULL; |
241 return 0; | 245 return 0; |
242 } | 246 } |
243 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; | 247 SDL_MintAudio_audiobuf[1] = SDL_MintAudio_audiobuf[0] + this->spec.size; |
244 SDL_MintAudio_numbuf = 0; | 248 SDL_MintAudio_numbuf = 0; |
245 SDL_memset(SDL_MintAudio_audiobuf[0],this->spec.silence,this->spec.size*2); | 249 SDL_memset(SDL_MintAudio_audiobuf[0], this->spec.silence, |
250 this->spec.size * 2); | |
246 SDL_MintAudio_audiosize = this->spec.size; | 251 SDL_MintAudio_audiosize = this->spec.size; |
247 SDL_MintAudio_mutex = 0; | 252 SDL_MintAudio_mutex = 0; |
248 | 253 |
249 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", | 254 DEBUG_PRINT((DEBUG_NAME "buffer 0 at 0x%08x\n", |
250 SDL_MintAudio_audiobuf[0])); | 255 SDL_MintAudio_audiobuf[0])); |
254 SDL_MintAudio_CheckFpu(); | 259 SDL_MintAudio_CheckFpu(); |
255 | 260 |
256 /* Setup audio hardware */ | 261 /* Setup audio hardware */ |
257 MINTSTFA_InitAudio(this); | 262 MINTSTFA_InitAudio(this); |
258 | 263 |
259 return 1; /* good to go. */ | 264 return 1; /* good to go. */ |
260 } | 265 } |
261 | 266 |
262 | 267 |
263 static int | 268 static int |
264 MINTSTFA_Init(SDL_AudioDriverImpl *impl) | 269 MINTSTFA_Init(SDL_AudioDriverImpl * impl) |
265 { | 270 { |
266 /* Cookie _MCH present ? if not, assume ST machine */ | 271 /* Cookie _MCH present ? if not, assume ST machine */ |
267 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { | 272 if (Getcookie(C__MCH, &cookie_mch) == C_NOTFOUND) { |
268 cookie_mch = MCH_ST; | 273 cookie_mch = MCH_ST; |
269 } | 274 } |