Mercurial > sdl-ios-xcode
comparison src/audio/macrom/SDL_romaudio.c @ 3792:866c310e2cb5 SDL-ryan-multiple-audio-device
Changed some 1.3 audio symbol names.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Tue, 03 Oct 2006 22:17:59 +0000 |
parents | 37c9c4590689 |
children | b19680c84cdf |
comparison
equal
deleted
inserted
replaced
3791:be33495e4d97 | 3792:866c310e2cb5 |
---|---|
50 #include "../SDL_sysaudio.h" | 50 #include "../SDL_sysaudio.h" |
51 #include "SDL_romaudio.h" | 51 #include "SDL_romaudio.h" |
52 | 52 |
53 /* Audio driver functions */ | 53 /* Audio driver functions */ |
54 | 54 |
55 static void SNDMGR_CloseAudio(_THIS); | 55 static void SNDMGR_CloseDevice(_THIS); |
56 static int SNDMGR_OpenAudio(_THIS, const char *devname, int iscapture); | 56 static int SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture); |
57 static void SNDMGR_LockAudio(_THIS); | 57 static void SNDMGR_LockDevice(_THIS); |
58 static void SNDMGR_UnlockAudio(_THIS); | 58 static void SNDMGR_UnlockDevice(_THIS); |
59 | 59 |
60 /* Audio driver bootstrap functions */ | 60 /* Audio driver bootstrap functions */ |
61 | |
62 | 61 |
63 static int | 62 static int |
64 SNDMGR_Available(void) | 63 SNDMGR_Available(void) |
65 { | 64 { |
66 return (1); | 65 return (1); |
69 | 68 |
70 static int | 69 static int |
71 SNDMGR_Init(SDL_AudioDriverImpl *impl) | 70 SNDMGR_Init(SDL_AudioDriverImpl *impl) |
72 { | 71 { |
73 /* Set the function pointers */ | 72 /* Set the function pointers */ |
74 impl->OpenAudio = SNDMGR_OpenAudio; | 73 impl->OpenDevice = SNDMGR_OpenDevice; |
75 impl->CloseAudio = SNDMGR_CloseAudio; | 74 impl->CloseDevice = SNDMGR_CloseDevice; |
76 impl->LockAudio = SNDMGR_LockAudio; | 75 impl->LockDevice = SNDMGR_LockDevice; |
77 impl->UnlockAudio = SNDMGR_UnlockAudio; | 76 impl->UnlockDevice = SNDMGR_UnlockDevice; |
78 | 77 |
79 #ifdef __MACOSX__ /* Mac OS X uses threaded audio, so normal thread code is okay */ | 78 #ifdef __MACOSX__ /* Mac OS X uses threaded audio, so normal thread code is okay */ |
80 impl->LockAudio = NULL; | 79 impl->LockDevice = NULL; |
81 impl->UnlockAudio = NULL; | 80 impl->UnlockDevice = NULL; |
82 #endif | 81 #endif |
83 | 82 |
84 return 1; | 83 return 1; |
85 } | 84 } |
86 | 85 |
127 | 126 |
128 DecrementAtomic((SInt32 *) & need_to_mix); | 127 DecrementAtomic((SInt32 *) & need_to_mix); |
129 } | 128 } |
130 | 129 |
131 static void | 130 static void |
132 SNDMGR_LockAudio(_THIS) | 131 SNDMGR_LockDevice(_THIS) |
133 { | 132 { |
134 IncrementAtomic((SInt32 *) & audio_is_locked); | 133 IncrementAtomic((SInt32 *) & audio_is_locked); |
135 } | 134 } |
136 | 135 |
137 static void | 136 static void |
138 SNDMGR_UnlockAudio(_THIS) | 137 SNDMGR_UnlockDevice(_THIS) |
139 { | 138 { |
140 SInt32 oldval; | 139 SInt32 oldval; |
141 | 140 |
142 oldval = DecrementAtomic((SInt32 *) & audio_is_locked); | 141 oldval = DecrementAtomic((SInt32 *) & audio_is_locked); |
143 if (oldval != 1) /* != 1 means audio is still locked. */ | 142 if (oldval != 1) /* != 1 means audio is still locked. */ |
196 SndDoCommand(chan, &cmd, 0); | 195 SndDoCommand(chan, &cmd, 0); |
197 } | 196 } |
198 } | 197 } |
199 | 198 |
200 static int | 199 static int |
201 SNDMGR_OpenAudio(_THIS, const char *devname, int iscapture) | 200 SNDMGR_OpenDevice(_THIS, const char *devname, int iscapture) |
202 { | 201 { |
203 SDL_AudioSpec *spec = &this->spec; | 202 SDL_AudioSpec *spec = &this->spec; |
204 SndChannelPtr channel = NULL; | 203 SndChannelPtr channel = NULL; |
205 SndCallBackUPP callback; | 204 SndCallBackUPP callback; |
206 int sample_bits; | 205 int sample_bits; |
282 | 281 |
283 /* allocate 2 buffers */ | 282 /* allocate 2 buffers */ |
284 for (i = 0; i < 2; i++) { | 283 for (i = 0; i < 2; i++) { |
285 buffer[i] = (UInt8 *) malloc(sizeof(UInt8) * spec->size); | 284 buffer[i] = (UInt8 *) malloc(sizeof(UInt8) * spec->size); |
286 if (buffer[i] == NULL) { | 285 if (buffer[i] == NULL) { |
287 SNDMGR_CloseAudio(this); | 286 SNDMGR_CloseDevice(this); |
288 SDL_OutOfMemory(); | 287 SDL_OutOfMemory(); |
289 return 0; | 288 return 0; |
290 } | 289 } |
291 memset(buffer[i], 0, spec->size); | 290 memset(buffer[i], 0, spec->size); |
292 } | 291 } |
293 | 292 |
294 /* Create the sound manager channel */ | 293 /* Create the sound manager channel */ |
295 channel = (SndChannelPtr) SDL_malloc(sizeof(*channel)); | 294 channel = (SndChannelPtr) SDL_malloc(sizeof(*channel)); |
296 if (channel == NULL) { | 295 if (channel == NULL) { |
297 SNDMGR_CloseAudio(this); | 296 SNDMGR_CloseDevice(this); |
298 SDL_OutOfMemory(); | 297 SDL_OutOfMemory(); |
299 return 0; | 298 return 0; |
300 } | 299 } |
301 this->hidden->channel = channel; | 300 this->hidden->channel = channel; |
302 if (spec->channels >= 2) { | 301 if (spec->channels >= 2) { |
305 initOptions = initMono; | 304 initOptions = initMono; |
306 } | 305 } |
307 channel->userInfo = (long) this; | 306 channel->userInfo = (long) this; |
308 channel->qLength = 128; | 307 channel->qLength = 128; |
309 if (SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr) { | 308 if (SndNewChannel(&channel, sampledSynth, initOptions, callback) != noErr) { |
310 SNDMGR_CloseAudio(this); | 309 SNDMGR_CloseDevice(this); |
311 SDL_SetError("Unable to create audio channel"); | 310 SDL_SetError("Unable to create audio channel"); |
312 return 0; | 311 return 0; |
313 } | 312 } |
314 | 313 |
315 /* start playback */ | 314 /* start playback */ |
324 audio_is_opened = 1; | 323 audio_is_opened = 1; |
325 return 1; | 324 return 1; |
326 } | 325 } |
327 | 326 |
328 static void | 327 static void |
329 SNDMGR_CloseAudio(_THIS) | 328 SNDMGR_CloseDevice(_THIS) |
330 { | 329 { |
331 | 330 |
332 int i; | 331 int i; |
333 | 332 |
334 running = 0; | 333 running = 0; |