Mercurial > sdl-ios-xcode
comparison src/audio/SDL_audio.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 | 8f8209f8da6d |
children | 589bc3d060cd |
comparison
equal
deleted
inserted
replaced
3791:be33495e4d97 | 3792:866c310e2cb5 |
---|---|
228 stream = device->convert.buf; | 228 stream = device->convert.buf; |
229 } else { | 229 } else { |
230 continue; | 230 continue; |
231 } | 231 } |
232 } else { | 232 } else { |
233 stream = current_audio.impl.GetAudioBuf(device); | 233 stream = current_audio.impl.GetDeviceBuf(device); |
234 if (stream == NULL) { | 234 if (stream == NULL) { |
235 stream = device->fake_stream; | 235 stream = device->fake_stream; |
236 } | 236 } |
237 } | 237 } |
238 | 238 |
248 } | 248 } |
249 | 249 |
250 /* Convert the audio if necessary */ | 250 /* Convert the audio if necessary */ |
251 if (device->convert.needed) { | 251 if (device->convert.needed) { |
252 SDL_ConvertAudio(&device->convert); | 252 SDL_ConvertAudio(&device->convert); |
253 stream = current_audio.impl.GetAudioBuf(device); | 253 stream = current_audio.impl.GetDeviceBuf(device); |
254 if (stream == NULL) { | 254 if (stream == NULL) { |
255 stream = device->fake_stream; | 255 stream = device->fake_stream; |
256 } | 256 } |
257 SDL_memcpy(stream, device->convert.buf, device->convert.len_cvt); | 257 SDL_memcpy(stream, device->convert.buf, device->convert.len_cvt); |
258 } | 258 } |
259 | 259 |
260 /* Ready current buffer for play and change current buffer */ | 260 /* Ready current buffer for play and change current buffer */ |
261 if (stream != device->fake_stream) { | 261 if (stream != device->fake_stream) { |
262 current_audio.impl.PlayAudio(device); | 262 current_audio.impl.PlayDevice(device); |
263 } | 263 } |
264 | 264 |
265 /* Wait for an audio buffer to become available */ | 265 /* Wait for an audio buffer to become available */ |
266 if (stream == device->fake_stream) { | 266 if (stream == device->fake_stream) { |
267 SDL_Delay((device->spec.samples * 1000) / device->spec.freq); | 267 SDL_Delay((device->spec.samples * 1000) / device->spec.freq); |
268 } else { | 268 } else { |
269 current_audio.impl.WaitAudio(device); | 269 current_audio.impl.WaitDevice(device); |
270 } | 270 } |
271 } | 271 } |
272 | 272 |
273 /* Wait for the audio to drain.. */ | 273 /* Wait for the audio to drain.. */ |
274 if (current_audio.impl.WaitDone) { | 274 if (current_audio.impl.WaitDone) { |
275 current_audio.impl.WaitDone(device); | 275 current_audio.impl.WaitDone(device); |
276 } | 276 } |
277 #if SDL_AUDIO_DRIVER_AHI | 277 #if SDL_AUDIO_DRIVER_AHI |
278 D(bug("WaitAudio...Done\n")); | 278 D(bug("WaitDevice...Done\n")); |
279 | 279 |
280 audio->CloseAudio(audio); | 280 audio->CloseDevice(audio); |
281 | 281 |
282 D(bug("CloseAudio..Done, subtask exiting...\n")); | 282 D(bug("CloseDevice..Done, subtask exiting...\n")); |
283 audio_configured = 0; | 283 audio_configured = 0; |
284 #endif | 284 #endif |
285 #ifdef __OS2__ | 285 #ifdef __OS2__ |
286 #ifdef DEBUG_BUILD | 286 #ifdef DEBUG_BUILD |
287 printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); | 287 printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); |
289 #endif | 289 #endif |
290 return (0); | 290 return (0); |
291 } | 291 } |
292 | 292 |
293 static void | 293 static void |
294 SDL_LockAudio_Default(SDL_AudioDevice * audio) | 294 SDL_LockDevice_Default(SDL_AudioDevice * audio) |
295 { | 295 { |
296 if (audio->thread && (SDL_ThreadID() == audio->threadid)) { | 296 if (audio->thread && (SDL_ThreadID() == audio->threadid)) { |
297 return; | 297 return; |
298 } | 298 } |
299 SDL_mutexP(audio->mixer_lock); | 299 SDL_mutexP(audio->mixer_lock); |
300 } | 300 } |
301 | 301 |
302 static void | 302 static void |
303 SDL_UnlockAudio_Default(SDL_AudioDevice * audio) | 303 SDL_UnlockDevice_Default(SDL_AudioDevice * audio) |
304 { | 304 { |
305 if (audio->thread && (SDL_ThreadID() == audio->threadid)) { | 305 if (audio->thread && (SDL_ThreadID() == audio->threadid)) { |
306 return; | 306 return; |
307 } | 307 } |
308 SDL_mutexV(audio->mixer_lock); | 308 SDL_mutexV(audio->mixer_lock); |
436 SDL_memset(¤t_audio, 0, sizeof (current_audio)); | 436 SDL_memset(¤t_audio, 0, sizeof (current_audio)); |
437 return (-1); /* No driver was available, so fail. */ | 437 return (-1); /* No driver was available, so fail. */ |
438 } | 438 } |
439 } | 439 } |
440 | 440 |
441 if (!current_audio.impl.LockAudio && !current_audio.impl.UnlockAudio) { | 441 if (!current_audio.impl.LockDevice && !current_audio.impl.UnlockDevice) { |
442 current_audio.impl.LockAudio = SDL_LockAudio_Default; | 442 current_audio.impl.LockDevice = SDL_LockDevice_Default; |
443 current_audio.impl.UnlockAudio = SDL_UnlockAudio_Default; | 443 current_audio.impl.UnlockDevice = SDL_UnlockDevice_Default; |
444 } | 444 } |
445 | 445 |
446 return (0); | 446 return (0); |
447 } | 447 } |
448 | 448 |
465 return current_audio.impl.DetectDevices(iscapture); | 465 return current_audio.impl.DetectDevices(iscapture); |
466 } | 466 } |
467 | 467 |
468 | 468 |
469 const char * | 469 const char * |
470 SDL_GetAudioDevice(int index, int iscapture) | 470 SDL_GetAudioDeviceName(int index, int iscapture) |
471 { | 471 { |
472 if (!SDL_WasInit(SDL_INIT_AUDIO)) { | 472 if (!SDL_WasInit(SDL_INIT_AUDIO)) { |
473 SDL_SetError("Audio subsystem is not initialized"); | 473 SDL_SetError("Audio subsystem is not initialized"); |
474 return NULL; | 474 return NULL; |
475 } | 475 } |
476 | 476 |
477 if ((index < 0) && (!current_audio.impl.GetAudioDevice)) { | 477 if ((index < 0) && (!current_audio.impl.GetDeviceName)) { |
478 SDL_SetError("No such device"); | 478 SDL_SetError("No such device"); |
479 return NULL; | 479 return NULL; |
480 } | 480 } |
481 | 481 |
482 return current_audio.impl.GetAudioDevice(index, iscapture); | 482 return current_audio.impl.GetDeviceName(index, iscapture); |
483 } | 483 } |
484 | 484 |
485 | 485 |
486 static void | 486 static void |
487 close_audio_device(SDL_AudioDevice *device) | 487 close_audio_device(SDL_AudioDevice *device) |
499 if (device->convert.needed) { | 499 if (device->convert.needed) { |
500 SDL_FreeAudioMem(device->convert.buf); | 500 SDL_FreeAudioMem(device->convert.buf); |
501 } | 501 } |
502 #if !SDL_AUDIO_DRIVER_AHI /* !!! FIXME: get rid of this #if. */ | 502 #if !SDL_AUDIO_DRIVER_AHI /* !!! FIXME: get rid of this #if. */ |
503 if (device->opened) { | 503 if (device->opened) { |
504 current_audio.impl.CloseAudio(device); | 504 current_audio.impl.CloseDevice(device); |
505 device->opened = 0; | 505 device->opened = 0; |
506 } | 506 } |
507 #endif | 507 #endif |
508 SDL_FreeAudioMem(device); | 508 SDL_FreeAudioMem(device); |
509 } | 509 } |
630 #endif /* __MINT__ */ | 630 #endif /* __MINT__ */ |
631 | 631 |
632 /* !!! FIXME: Get this #if out of the core. */ | 632 /* !!! FIXME: Get this #if out of the core. */ |
633 /* AmigaOS opens audio inside the main loop */ | 633 /* AmigaOS opens audio inside the main loop */ |
634 #if !SDL_AUDIO_DRIVER_AHI | 634 #if !SDL_AUDIO_DRIVER_AHI |
635 if (!current_audio.impl.OpenAudio(device, devname, iscapture)) { | 635 if (!current_audio.impl.OpenDevice(device, devname, iscapture)) { |
636 close_audio_device(device); | 636 close_audio_device(device); |
637 return 0; | 637 return 0; |
638 } | 638 } |
639 device->opened = 2; /* !!! FIXME */ | 639 device->opened = 2; /* !!! FIXME */ |
640 #else | 640 #else |
822 | 822 |
823 | 823 |
824 void | 824 void |
825 SDL_LockAudioDevice(SDL_AudioDeviceID devid) | 825 SDL_LockAudioDevice(SDL_AudioDeviceID devid) |
826 { | 826 { |
827 if (current_audio.impl.LockAudio != NULL) { | 827 if (current_audio.impl.LockDevice != NULL) { |
828 SDL_AudioDevice *device = get_audio_device(devid); | 828 SDL_AudioDevice *device = get_audio_device(devid); |
829 /* Obtain a lock on the mixing buffers */ | 829 /* Obtain a lock on the mixing buffers */ |
830 if (device) { | 830 if (device) { |
831 current_audio.impl.LockAudio(device); | 831 current_audio.impl.LockDevice(device); |
832 } | 832 } |
833 } | 833 } |
834 } | 834 } |
835 | 835 |
836 void | 836 void |
840 } | 840 } |
841 | 841 |
842 void | 842 void |
843 SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) | 843 SDL_UnlockAudioDevice(SDL_AudioDeviceID devid) |
844 { | 844 { |
845 if (current_audio.impl.UnlockAudio != NULL) { | 845 if (current_audio.impl.UnlockDevice != NULL) { |
846 SDL_AudioDevice *device = get_audio_device(devid); | 846 SDL_AudioDevice *device = get_audio_device(devid); |
847 /* Obtain a lock on the mixing buffers */ | 847 /* Obtain a lock on the mixing buffers */ |
848 if (device) { | 848 if (device) { |
849 current_audio.impl.UnlockAudio(device); | 849 current_audio.impl.UnlockDevice(device); |
850 } | 850 } |
851 } | 851 } |
852 } | 852 } |
853 | 853 |
854 void | 854 void |