Mercurial > sdl-ios-xcode
comparison src/audio/baudio/SDL_beaudio.cc @ 1998:cbac0f77a799
Fixed silly logic thing.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Thu, 31 Aug 2006 22:22:34 +0000 |
parents | 46319c67b3d7 |
children | 02108bfd6550 |
comparison
equal
deleted
inserted
replaced
1997:46319c67b3d7 | 1998:cbac0f77a799 |
---|---|
155 | 155 |
156 int BE_OpenAudio(_THIS, SDL_AudioSpec * spec) | 156 int BE_OpenAudio(_THIS, SDL_AudioSpec * spec) |
157 { | 157 { |
158 media_raw_audio_format format; | 158 media_raw_audio_format format; |
159 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); | 159 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
160 int valid_datatype = 0; | |
161 | 160 |
162 /* Parse the audio format and fill the Be raw audio format */ | 161 /* Parse the audio format and fill the Be raw audio format */ |
163 memset(&format, '\0', sizeof (media_raw_audio_format)); | 162 memset(&format, '\0', sizeof (media_raw_audio_format)); |
164 format.byte_order = B_MEDIA_LITTLE_ENDIAN; | 163 format.byte_order = B_MEDIA_LITTLE_ENDIAN; |
165 format.frame_rate = (float) spec->freq; | 164 format.frame_rate = (float) spec->freq; |
166 format.channel_count = spec->channels; /* !!! FIXME: support > 2? */ | 165 format.channel_count = spec->channels; /* !!! FIXME: support > 2? */ |
167 while ((!valid_datatype) && (test_format)) { | 166 while (test_format) { |
168 spec->format = test_format; | 167 spec->format = test_format; |
169 switch (test_format) { | 168 switch (test_format) { |
170 case AUDIO_S8: | 169 case AUDIO_S8: |
171 valid_datatype = 1; | |
172 format.format = media_raw_audio_format::B_AUDIO_CHAR; | 170 format.format = media_raw_audio_format::B_AUDIO_CHAR; |
173 break; | 171 break; |
174 | 172 |
175 case AUDIO_U8: | 173 case AUDIO_U8: |
176 valid_datatype = 1; | |
177 format.format = media_raw_audio_format::B_AUDIO_UCHAR; | 174 format.format = media_raw_audio_format::B_AUDIO_UCHAR; |
178 break; | 175 break; |
179 | 176 |
180 case AUDIO_S16LSB: | 177 case AUDIO_S16LSB: |
181 valid_datatype = 1; | |
182 format.format = media_raw_audio_format::B_AUDIO_SHORT; | 178 format.format = media_raw_audio_format::B_AUDIO_SHORT; |
183 break; | 179 break; |
184 | 180 |
185 case AUDIO_S16MSB: | 181 case AUDIO_S16MSB: |
186 valid_datatype = 1; | |
187 format.format = media_raw_audio_format::B_AUDIO_SHORT; | 182 format.format = media_raw_audio_format::B_AUDIO_SHORT; |
188 format.byte_order = B_MEDIA_BIG_ENDIAN; | 183 format.byte_order = B_MEDIA_BIG_ENDIAN; |
189 break; | 184 break; |
190 | 185 |
191 case AUDIO_S32LSB: | 186 case AUDIO_S32LSB: |
192 valid_datatype = 1; | |
193 format.format = media_raw_audio_format::B_AUDIO_INT; | 187 format.format = media_raw_audio_format::B_AUDIO_INT; |
194 break; | 188 break; |
195 | 189 |
196 case AUDIO_S32MSB: | 190 case AUDIO_S32MSB: |
197 valid_datatype = 1; | |
198 format.format = media_raw_audio_format::B_AUDIO_INT; | 191 format.format = media_raw_audio_format::B_AUDIO_INT; |
199 format.byte_order = B_MEDIA_BIG_ENDIAN; | 192 format.byte_order = B_MEDIA_BIG_ENDIAN; |
200 break; | 193 break; |
201 | 194 |
202 case AUDIO_F32LSB: | 195 case AUDIO_F32LSB: |
203 valid_datatype = 1; | |
204 format.format = media_raw_audio_format::B_AUDIO_FLOAT; | 196 format.format = media_raw_audio_format::B_AUDIO_FLOAT; |
205 break; | 197 break; |
206 | 198 |
207 case AUDIO_F32MSB: | 199 case AUDIO_F32MSB: |
208 valid_datatype = 1; | |
209 format.format = media_raw_audio_format::B_AUDIO_FLOAT; | 200 format.format = media_raw_audio_format::B_AUDIO_FLOAT; |
210 format.byte_order = B_MEDIA_BIG_ENDIAN; | 201 format.byte_order = B_MEDIA_BIG_ENDIAN; |
211 break; | 202 break; |
212 | 203 |
213 default: | 204 default: |
216 } | 207 } |
217 } | 208 } |
218 | 209 |
219 format.buffer_size = spec->samples; | 210 format.buffer_size = spec->samples; |
220 | 211 |
221 if (!valid_datatype) { /* shouldn't happen, but just in case... */ | 212 if (!test_format) { /* shouldn't happen, but just in case... */ |
222 SDL_SetError("Unsupported audio format"); | 213 SDL_SetError("Unsupported audio format"); |
223 return (-1); | 214 return (-1); |
224 } | 215 } |
225 | 216 |
226 /* Initialize the Be Application, if it's not already started */ | 217 /* Initialize the Be Application, if it's not already started */ |