comparison src/audio/macrom/SDL_romaudio.c @ 348:25809353f877

Re-added MacOS X audio locking
author Sam Lantinga <slouken@libsdl.org>
date Sat, 13 Apr 2002 23:31:07 +0000
parents f25f666d609a
children b8d311d90021
comparison
equal deleted inserted replaced
347:1b89c9ca9246 348:25809353f877
89 this->CloseAudio = Mac_CloseAudio; 89 this->CloseAudio = Mac_CloseAudio;
90 this->LockAudio = Mac_LockAudio; 90 this->LockAudio = Mac_LockAudio;
91 this->UnlockAudio = Mac_UnlockAudio; 91 this->UnlockAudio = Mac_UnlockAudio;
92 this->free = Audio_DeleteDevice; 92 this->free = Audio_DeleteDevice;
93 93
94 #ifdef MACOSX /* MacOS X uses threaded audio, so normal thread code is okay */
95 this->LockAudio = NULL;
96 this->UnlockAudio = NULL;
97 #endif
94 return this; 98 return this;
95 } 99 }
96 100
97 AudioBootStrap SNDMGR_bootstrap = { 101 AudioBootStrap SNDMGR_bootstrap = {
98 "sndmgr", "MacOS SoundManager 3.0", 102 "sndmgr", "MacOS SoundManager 3.0",
99 Audio_Available, Audio_CreateDevice 103 Audio_Available, Audio_CreateDevice
100 }; 104 };
101 105
102 #if defined(TARGET_API_MAC_CARBON) || defined(USE_RYANS_SOUNDCODE) 106 #if defined(TARGET_API_MAC_CARBON) || defined(USE_RYANS_SOUNDCODE)
103 /* FIXME: Does this work correctly on MacOS X as well? */ 107 /* This works correctly on MacOS X */
104 108
105 #pragma options align=power 109 #pragma options align=power
106 110
107 static volatile SInt32 audio_is_locked = 0; 111 static volatile SInt32 audio_is_locked = 0;
108 static volatile SInt32 need_to_mix = 0; 112 static volatile SInt32 need_to_mix = 0;
113 static volatile Uint32 fill_me = 0; 117 static volatile Uint32 fill_me = 0;
114 118
115 static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer) 119 static void mix_buffer(SDL_AudioDevice *audio, UInt8 *buffer)
116 { 120 {
117 if ( ! audio->paused ) { 121 if ( ! audio->paused ) {
122 #ifdef MACOSX
123 SDL_mutexP(audio->mixer_lock);
124 #endif
118 if ( audio->convert.needed ) { 125 if ( audio->convert.needed ) {
119 audio->spec.callback(audio->spec.userdata, 126 audio->spec.callback(audio->spec.userdata,
120 (Uint8 *)audio->convert.buf,audio->convert.len); 127 (Uint8 *)audio->convert.buf,audio->convert.len);
121 SDL_ConvertAudio(&audio->convert); 128 SDL_ConvertAudio(&audio->convert);
122 #if 0
123 if ( audio->convert.len_cvt != audio->spec.size ) { 129 if ( audio->convert.len_cvt != audio->spec.size ) {
124 /* Uh oh... probably crashes here; */ 130 /* Uh oh... probably crashes here */;
125 } 131 }
126 #endif
127 memcpy(buffer, audio->convert.buf, audio->convert.len_cvt); 132 memcpy(buffer, audio->convert.buf, audio->convert.len_cvt);
128 } else { 133 } else {
129 audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size); 134 audio->spec.callback(audio->spec.userdata, buffer, audio->spec.size);
130 } 135 }
136 #ifdef MACOSX
137 SDL_mutexV(audio->mixer_lock);
138 #endif
131 } 139 }
132 140
133 DecrementAtomic((SInt32 *) &need_to_mix); 141 DecrementAtomic((SInt32 *) &need_to_mix);
134 } 142 }
135 143