comparison src/audio/baudio/SDL_beaudio.cc @ 2001:02108bfd6550

Actually, my silly logic bug was actually correct. :/
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 31 Aug 2006 23:16:48 +0000
parents cbac0f77a799
children adf732f1f016
comparison
equal deleted inserted replaced
2000:8c05b048c32c 2001:02108bfd6550
153 SDL_QuitBeApp(); 153 SDL_QuitBeApp();
154 } 154 }
155 155
156 int BE_OpenAudio(_THIS, SDL_AudioSpec * spec) 156 int BE_OpenAudio(_THIS, SDL_AudioSpec * spec)
157 { 157 {
158 int valid_datatype = 0;
158 media_raw_audio_format format; 159 media_raw_audio_format format;
159 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); 160 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
160 161
161 /* Parse the audio format and fill the Be raw audio format */ 162 /* Parse the audio format and fill the Be raw audio format */
162 memset(&format, '\0', sizeof (media_raw_audio_format)); 163 memset(&format, '\0', sizeof (media_raw_audio_format));
163 format.byte_order = B_MEDIA_LITTLE_ENDIAN; 164 format.byte_order = B_MEDIA_LITTLE_ENDIAN;
164 format.frame_rate = (float) spec->freq; 165 format.frame_rate = (float) spec->freq;
165 format.channel_count = spec->channels; /* !!! FIXME: support > 2? */ 166 format.channel_count = spec->channels; /* !!! FIXME: support > 2? */
166 while (test_format) { 167 while ((!valid_datatype) && (test_format)) {
168 valid_datatype = 1;
167 spec->format = test_format; 169 spec->format = test_format;
168 switch (test_format) { 170 switch (test_format) {
169 case AUDIO_S8: 171 case AUDIO_S8:
170 format.format = media_raw_audio_format::B_AUDIO_CHAR; 172 format.format = media_raw_audio_format::B_AUDIO_CHAR;
171 break; 173 break;
200 format.format = media_raw_audio_format::B_AUDIO_FLOAT; 202 format.format = media_raw_audio_format::B_AUDIO_FLOAT;
201 format.byte_order = B_MEDIA_BIG_ENDIAN; 203 format.byte_order = B_MEDIA_BIG_ENDIAN;
202 break; 204 break;
203 205
204 default: 206 default:
207 valid_datatype = 0;
205 test_format = SDL_NextAudioFormat(); 208 test_format = SDL_NextAudioFormat();
206 break; 209 break;
207 } 210 }
208 } 211 }
209 212
210 format.buffer_size = spec->samples; 213 format.buffer_size = spec->samples;
211 214
212 if (!test_format) { /* shouldn't happen, but just in case... */ 215 if (!valid_datatype) { /* shouldn't happen, but just in case... */
213 SDL_SetError("Unsupported audio format"); 216 SDL_SetError("Unsupported audio format");
214 return (-1); 217 return (-1);
215 } 218 }
216 219
217 /* Initialize the Be Application, if it's not already started */ 220 /* Initialize the Be Application, if it's not already started */