Re-added MacOS X audio locking
authorSam Lantinga <slouken@libsdl.org>
Sat, 13 Apr 2002 23:31:07 +0000
changeset 34825809353f877
parent 347 1b89c9ca9246
child 349 3c052d3bcc76
Re-added MacOS X audio locking
src/audio/macrom/SDL_romaudio.c
     1.1 --- a/src/audio/macrom/SDL_romaudio.c	Sat Apr 13 20:33:21 2002 +0000
     1.2 +++ b/src/audio/macrom/SDL_romaudio.c	Sat Apr 13 23:31:07 2002 +0000
     1.3 @@ -91,6 +91,10 @@
     1.4      this->UnlockAudio = Mac_UnlockAudio;
     1.5      this->free        = Audio_DeleteDevice;
     1.6  
     1.7 +#ifdef MACOSX	/* MacOS X uses threaded audio, so normal thread code is okay */
     1.8 +    this->LockAudio   = NULL;
     1.9 +    this->UnlockAudio = NULL;
    1.10 +#endif
    1.11      return this;
    1.12  }
    1.13  
    1.14 @@ -100,7 +104,7 @@
    1.15  };
    1.16  
    1.17  #if defined(TARGET_API_MAC_CARBON) || defined(USE_RYANS_SOUNDCODE)
    1.18 -/* FIXME: Does this work correctly on MacOS X as well? */
    1.19 +/* This works correctly on MacOS X */
    1.20  
    1.21  #pragma options align=power
    1.22  
    1.23 @@ -115,19 +119,23 @@
    1.24  static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
    1.25  {
    1.26     if ( ! audio->paused ) {
    1.27 +#ifdef MACOSX
    1.28 +        SDL_mutexP(audio->mixer_lock);
    1.29 +#endif
    1.30          if ( audio->convert.needed ) {
    1.31 -                audio->spec.callback(audio->spec.userdata,
    1.32 +            audio->spec.callback(audio->spec.userdata,
    1.33                      (Uint8 *)audio->convert.buf,audio->convert.len);
    1.34 -               SDL_ConvertAudio(&audio->convert);
    1.35 -#if 0
    1.36 +            SDL_ConvertAudio(&audio->convert);
    1.37              if ( audio->convert.len_cvt != audio->spec.size ) {
    1.38 -                /* Uh oh... probably crashes here; */
    1.39 +                /* Uh oh... probably crashes here */;
    1.40              }
    1.41 -#endif
    1.42              memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
    1.43          } else {
    1.44              audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
    1.45          }
    1.46 +#ifdef MACOSX
    1.47 +        SDL_mutexV(audio->mixer_lock);
    1.48 +#endif
    1.49      }
    1.50  
    1.51      DecrementAtomic((SInt32 *) &need_to_mix);