src/audio/SDL_audio.c
changeset 322 fd93a09655e3
parent 297 f6ffac90895c
child 398 d219b0e02f5f
     1.1 --- a/src/audio/SDL_audio.c	Sat Mar 30 18:53:23 2002 +0000
     1.2 +++ b/src/audio/SDL_audio.c	Sat Mar 30 19:48:56 2002 +0000
     1.3 @@ -230,6 +230,22 @@
     1.4  	return(0);
     1.5  }
     1.6  
     1.7 +static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
     1.8 +{
     1.9 +	if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
    1.10 +		return;
    1.11 +	}
    1.12 +	SDL_mutexP(audio->mixer_lock);
    1.13 +}
    1.14 +
    1.15 +static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio)
    1.16 +{
    1.17 +	if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
    1.18 +		return;
    1.19 +	}
    1.20 +	SDL_mutexV(audio->mixer_lock);
    1.21 +}
    1.22 +
    1.23  int SDL_AudioInit(const char *driver_name)
    1.24  {
    1.25  	SDL_AudioDevice *audio;
    1.26 @@ -309,6 +325,10 @@
    1.27  	current_audio = audio;
    1.28  	if ( current_audio ) {
    1.29  		current_audio->name = bootstrap[i]->name;
    1.30 +		if ( !current_audio->LockAudio && !current_audio->UnlockAudio ) {
    1.31 +			current_audio->LockAudio = SDL_LockAudio_Default;
    1.32 +			current_audio->UnlockAudio = SDL_UnlockAudio_Default;
    1.33 +		}
    1.34  	}
    1.35  	return(0);
    1.36  }
    1.37 @@ -506,11 +526,8 @@
    1.38  	SDL_AudioDevice *audio = current_audio;
    1.39  
    1.40  	/* Obtain a lock on the mixing buffers */
    1.41 -	if ( audio ) {
    1.42 -		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
    1.43 -			return;
    1.44 -		}
    1.45 -		SDL_mutexP(audio->mixer_lock);
    1.46 +	if ( audio && audio->LockAudio ) {
    1.47 +		audio->LockAudio(audio);
    1.48  	}
    1.49  }
    1.50  
    1.51 @@ -519,11 +536,8 @@
    1.52  	SDL_AudioDevice *audio = current_audio;
    1.53  
    1.54  	/* Release lock on the mixing buffers */
    1.55 -	if ( audio ) {
    1.56 -		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
    1.57 -			return;
    1.58 -		}
    1.59 -		SDL_mutexV(audio->mixer_lock);
    1.60 +	if ( audio && audio->UnlockAudio ) {
    1.61 +		audio->UnlockAudio(audio);
    1.62  	}
    1.63  }
    1.64