Mercurial > sdl-ios-xcode
comparison src/audio/macrom/SDL_romaudio.c @ 47:45b1c4303f87
Added initial support for Quartz video (thanks Darrell!)
author | Sam Lantinga <slouken@lokigames.com> |
---|---|
date | Thu, 07 Jun 2001 14:28:11 +0000 |
parents | 74212992fb08 |
children | e8157fcb3114 |
comparison
equal
deleted
inserted
replaced
46:3dcf26fa9d15 | 47:45b1c4303f87 |
---|---|
103 static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) { | 103 static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) { |
104 | 104 |
105 UInt32 fill_me, play_me; | 105 UInt32 fill_me, play_me; |
106 SndCommand cmd; | 106 SndCommand cmd; |
107 SDL_AudioDevice *audio = (SDL_AudioDevice *)chan->userInfo; | 107 SDL_AudioDevice *audio = (SDL_AudioDevice *)chan->userInfo; |
108 | 108 |
109 fill_me = cmd_passed->param2; /* buffer that has just finished playing, | 109 fill_me = cmd_passed->param2; /* buffer that has just finished playing, so fill it */ |
110 so fill it */ | |
111 play_me = ! fill_me; /* filled buffer to play _now_ */ | 110 play_me = ! fill_me; /* filled buffer to play _now_ */ |
112 | 111 |
113 if ( ! audio->enabled ) { | 112 if ( ! audio->enabled ) { |
114 return; | 113 return; |
115 } | 114 } |
117 header.samplePtr = (Ptr)buffer[play_me]; | 116 header.samplePtr = (Ptr)buffer[play_me]; |
118 | 117 |
119 cmd.cmd = bufferCmd; | 118 cmd.cmd = bufferCmd; |
120 cmd.param1 = 0; | 119 cmd.param1 = 0; |
121 cmd.param2 = (long)&header; | 120 cmd.param2 = (long)&header; |
122 | 121 |
123 SndDoCommand (chan, &cmd, 0); | 122 SndDoCommand (chan, &cmd, 0); |
124 | 123 |
125 memset (buffer[fill_me], 0, audio->spec.size); | 124 memset (buffer[fill_me], 0, audio->spec.size); |
126 | 125 |
127 if ( ! audio->paused ) { | 126 if ( ! audio->paused ) { |
128 if ( audio->convert.needed ) { | 127 if ( audio->convert.needed ) { |
129 audio->spec.callback(audio->spec.userdata, | 128 #if MACOSX |
130 (Uint8 *)audio->convert.buf,audio->convert.len); | 129 SDL_mutexP(audio->mixer_lock); |
130 #endif | |
131 audio->spec.callback(audio->spec.userdata, | |
132 (Uint8 *)audio->convert.buf,audio->convert.len); | |
133 #if MACOSX | |
134 SDL_mutexV(audio->mixer_lock); | |
135 #endif | |
131 SDL_ConvertAudio(&audio->convert); | 136 SDL_ConvertAudio(&audio->convert); |
132 #if 0 | 137 #if 0 |
133 if ( audio->convert.len_cvt != audio->spec.size ) { | 138 if ( audio->convert.len_cvt != audio->spec.size ) { |
134 /* Uh oh... probably crashes here; */ | 139 /* Uh oh... probably crashes here; */ |
135 } | 140 } |
136 #endif | 141 #endif |
137 memcpy(buffer[fill_me], audio->convert.buf, | 142 memcpy(buffer[fill_me], audio->convert.buf, |
138 audio->convert.len_cvt); | 143 audio->convert.len_cvt); |
139 } else { | 144 } else { |
145 #if MACOSX | |
146 SDL_mutexP(audio->mixer_lock); | |
147 #endif | |
140 audio->spec.callback(audio->spec.userdata, | 148 audio->spec.callback(audio->spec.userdata, |
141 (Uint8 *)buffer[fill_me], audio->spec.size); | 149 (Uint8 *)buffer[fill_me], audio->spec.size); |
142 } | 150 #if MACOSX |
143 } | 151 SDL_mutexV(audio->mixer_lock); |
144 | 152 #endif |
153 } | |
154 } | |
155 | |
145 if ( running ) { | 156 if ( running ) { |
146 | 157 |
147 cmd.cmd = callBackCmd; | 158 cmd.cmd = callBackCmd; |
148 cmd.param1 = 0; | 159 cmd.param1 = 0; |
149 cmd.param2 = play_me; | 160 cmd.param2 = play_me; |
150 | 161 |
151 SndDoCommand (chan, &cmd, 0); | 162 SndDoCommand (chan, &cmd, 0); |
152 } | 163 } |
164 | |
153 } | 165 } |
154 | 166 |
155 static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) { | 167 static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) { |
156 | 168 |
157 SndCallBackUPP callback; | 169 SndCallBackUPP callback; |