Mercurial > sdl-ios-xcode
comparison src/audio/SDL_audio.c @ 322:fd93a09655e3
The audio lock and unlock functions are now a part of the driver.
The MacOS audio locking has been implemented, courtesy of Ryan Gordon
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sat, 30 Mar 2002 19:48:56 +0000 |
parents | f6ffac90895c |
children | d219b0e02f5f |
comparison
equal
deleted
inserted
replaced
321:af42e7c4c860 | 322:fd93a09655e3 |
---|---|
226 | 226 |
227 D(bug("CloseAudio..Done, subtask exiting...\n")); | 227 D(bug("CloseAudio..Done, subtask exiting...\n")); |
228 audio_configured = 0; | 228 audio_configured = 0; |
229 #endif | 229 #endif |
230 return(0); | 230 return(0); |
231 } | |
232 | |
233 static void SDL_LockAudio_Default(SDL_AudioDevice *audio) | |
234 { | |
235 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) { | |
236 return; | |
237 } | |
238 SDL_mutexP(audio->mixer_lock); | |
239 } | |
240 | |
241 static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio) | |
242 { | |
243 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) { | |
244 return; | |
245 } | |
246 SDL_mutexV(audio->mixer_lock); | |
231 } | 247 } |
232 | 248 |
233 int SDL_AudioInit(const char *driver_name) | 249 int SDL_AudioInit(const char *driver_name) |
234 { | 250 { |
235 SDL_AudioDevice *audio; | 251 SDL_AudioDevice *audio; |
307 } | 323 } |
308 } | 324 } |
309 current_audio = audio; | 325 current_audio = audio; |
310 if ( current_audio ) { | 326 if ( current_audio ) { |
311 current_audio->name = bootstrap[i]->name; | 327 current_audio->name = bootstrap[i]->name; |
328 if ( !current_audio->LockAudio && !current_audio->UnlockAudio ) { | |
329 current_audio->LockAudio = SDL_LockAudio_Default; | |
330 current_audio->UnlockAudio = SDL_UnlockAudio_Default; | |
331 } | |
312 } | 332 } |
313 return(0); | 333 return(0); |
314 } | 334 } |
315 | 335 |
316 char *SDL_AudioDriverName(char *namebuf, int maxlen) | 336 char *SDL_AudioDriverName(char *namebuf, int maxlen) |
504 void SDL_LockAudio (void) | 524 void SDL_LockAudio (void) |
505 { | 525 { |
506 SDL_AudioDevice *audio = current_audio; | 526 SDL_AudioDevice *audio = current_audio; |
507 | 527 |
508 /* Obtain a lock on the mixing buffers */ | 528 /* Obtain a lock on the mixing buffers */ |
509 if ( audio ) { | 529 if ( audio && audio->LockAudio ) { |
510 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) { | 530 audio->LockAudio(audio); |
511 return; | |
512 } | |
513 SDL_mutexP(audio->mixer_lock); | |
514 } | 531 } |
515 } | 532 } |
516 | 533 |
517 void SDL_UnlockAudio (void) | 534 void SDL_UnlockAudio (void) |
518 { | 535 { |
519 SDL_AudioDevice *audio = current_audio; | 536 SDL_AudioDevice *audio = current_audio; |
520 | 537 |
521 /* Release lock on the mixing buffers */ | 538 /* Release lock on the mixing buffers */ |
522 if ( audio ) { | 539 if ( audio && audio->UnlockAudio ) { |
523 if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) { | 540 audio->UnlockAudio(audio); |
524 return; | |
525 } | |
526 SDL_mutexV(audio->mixer_lock); | |
527 } | 541 } |
528 } | 542 } |
529 | 543 |
530 void SDL_CloseAudio (void) | 544 void SDL_CloseAudio (void) |
531 { | 545 { |