Commit 3629d251 authored by Sam Lantinga's avatar Sam Lantinga

Re-added MacOS X audio locking

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40349
parent 5b4fdd0d
...@@ -91,6 +91,10 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) ...@@ -91,6 +91,10 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex)
this->UnlockAudio = Mac_UnlockAudio; this->UnlockAudio = Mac_UnlockAudio;
this->free = Audio_DeleteDevice; this->free = Audio_DeleteDevice;
#ifdef MACOSX /* MacOS X uses threaded audio, so normal thread code is okay */
this->LockAudio = NULL;
this->UnlockAudio = NULL;
#endif
return this; return this;
} }
...@@ -100,7 +104,7 @@ AudioBootStrap SNDMGR_bootstrap = { ...@@ -100,7 +104,7 @@ AudioBootStrap SNDMGR_bootstrap = {
}; };
#if defined(TARGET_API_MAC_CARBON) || defined(USE_RYANS_SOUNDCODE) #if defined(TARGET_API_MAC_CARBON) || defined(USE_RYANS_SOUNDCODE)
/* FIXME: Does this work correctly on MacOS X as well? */ /* This works correctly on MacOS X */
#pragma options align=power #pragma options align=power
...@@ -115,19 +119,23 @@ static volatile Uint32 fill_me = 0; ...@@ -115,19 +119,23 @@ static volatile Uint32 fill_me = 0;
static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer) static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
{ {
if ( ! audio->paused ) { if ( ! audio->paused ) {
#ifdef MACOSX
SDL_mutexP(audio->mixer_lock);
#endif
if ( audio->convert.needed ) { if ( audio->convert.needed ) {
audio->spec.callback(audio->spec.userdata, audio->spec.callback(audio->spec.userdata,
(Uint8 *)audio->convert.buf,audio->convert.len); (Uint8 *)audio->convert.buf,audio->convert.len);
SDL_ConvertAudio(&audio->convert); SDL_ConvertAudio(&audio->convert);
#if 0
if ( audio->convert.len_cvt != audio->spec.size ) { if ( audio->convert.len_cvt != audio->spec.size ) {
/* Uh oh... probably crashes here; */ /* Uh oh... probably crashes here */;
} }
#endif
memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
} else { } else {
audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
} }
#ifdef MACOSX
SDL_mutexV(audio->mixer_lock);
#endif
} }
DecrementAtomic((SInt32 *) &need_to_mix); DecrementAtomic((SInt32 *) &need_to_mix);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment