diff 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
line wrap: on
line diff
--- a/src/audio/SDL_audio.c	Sat Mar 30 18:53:23 2002 +0000
+++ b/src/audio/SDL_audio.c	Sat Mar 30 19:48:56 2002 +0000
@@ -230,6 +230,22 @@
 	return(0);
 }
 
+static void SDL_LockAudio_Default(SDL_AudioDevice *audio)
+{
+	if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+		return;
+	}
+	SDL_mutexP(audio->mixer_lock);
+}
+
+static void SDL_UnlockAudio_Default(SDL_AudioDevice *audio)
+{
+	if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+		return;
+	}
+	SDL_mutexV(audio->mixer_lock);
+}
+
 int SDL_AudioInit(const char *driver_name)
 {
 	SDL_AudioDevice *audio;
@@ -309,6 +325,10 @@
 	current_audio = audio;
 	if ( current_audio ) {
 		current_audio->name = bootstrap[i]->name;
+		if ( !current_audio->LockAudio && !current_audio->UnlockAudio ) {
+			current_audio->LockAudio = SDL_LockAudio_Default;
+			current_audio->UnlockAudio = SDL_UnlockAudio_Default;
+		}
 	}
 	return(0);
 }
@@ -506,11 +526,8 @@
 	SDL_AudioDevice *audio = current_audio;
 
 	/* Obtain a lock on the mixing buffers */
-	if ( audio ) {
-		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
-			return;
-		}
-		SDL_mutexP(audio->mixer_lock);
+	if ( audio && audio->LockAudio ) {
+		audio->LockAudio(audio);
 	}
 }
 
@@ -519,11 +536,8 @@
 	SDL_AudioDevice *audio = current_audio;
 
 	/* Release lock on the mixing buffers */
-	if ( audio ) {
-		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
-			return;
-		}
-		SDL_mutexV(audio->mixer_lock);
+	if ( audio && audio->UnlockAudio ) {
+		audio->UnlockAudio(audio);
 	}
 }