The audio lock and unlock functions are now a part of the driver.
authorSam Lantinga
Sat, 30 Mar 2002 19:48:56 +0000
changeset 322fd93a09655e3
parent 321 af42e7c4c860
child 323 b7e8038e40ae
The audio lock and unlock functions are now a part of the driver.
The MacOS audio locking has been implemented, courtesy of Ryan Gordon
src/audio/SDL_audio.c
src/audio/SDL_sysaudio.h
     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  
     2.1 --- a/src/audio/SDL_sysaudio.h	Sat Mar 30 18:53:23 2002 +0000
     2.2 +++ b/src/audio/SDL_sysaudio.h	Sat Mar 30 19:48:56 2002 +0000
     2.3 @@ -59,6 +59,11 @@
     2.4  	void (*CloseAudio)(_THIS);
     2.5  
     2.6  	/* * * */
     2.7 +	/* Lock / Unlock functions added for the Mac port */
     2.8 +	void (*LockAudio)(_THIS);
     2.9 +	void (*UnlockAudio)(_THIS);
    2.10 +
    2.11 +	/* * * */
    2.12  	/* Data common to all devices */
    2.13  
    2.14  	/* The current audio specification (shared with audio thread) */