Mercurial > sdl-ios-xcode
comparison src/audio/amigaos/SDL_ahiaudio.c @ 3851:405a192b68e7 SDL-1.2
Backport from 1.3: most of the audio drivers can now handle data
conversion at a higher level when they can't open the hardware in the
exact format requested.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Fri, 01 Sep 2006 22:50:24 +0000 |
parents | d910939febfa |
children | 5b5e549382b3 |
comparison
equal
deleted
inserted
replaced
3850:28db418c7573 | 3851:405a192b68e7 |
---|---|
218 D(bug("...done!\n")); | 218 D(bug("...done!\n")); |
219 } | 219 } |
220 | 220 |
221 static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) | 221 static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) |
222 { | 222 { |
223 // int width; | 223 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format); |
224 | 224 int valid_datatype = 1; |
225 D(bug("AHI opening...\n")); | 225 |
226 | 226 D(bug("AHI opening...\n")); |
227 /* Determine the audio parameters from the AudioSpec */ | 227 |
228 switch ( spec->format & 0xFF ) { | 228 /* Determine the audio parameters from the AudioSpec */ |
229 | 229 while ((!valid_datatype) && (test_format)) { |
230 case 8: { /* Signed 8 bit audio data */ | 230 valid_datatype = 1; |
231 D(bug("Samples a 8 bit...\n")); | 231 switch (test_format) { |
232 spec->format = AUDIO_S8; | 232 case AUDIO_S8: |
233 this->hidden->bytespersample=1; | 233 D(bug("AUDIO_S8...\n")); |
234 if(spec->channels<2) | 234 spec->format = AUDIO_S8; |
235 this->hidden->type = AHIST_M8S; | 235 this->hidden->bytespersample = 1; |
236 else | 236 if (spec->channels < 2) |
237 this->hidden->type = AHIST_S8S; | 237 this->hidden->type = AHIST_M8S; |
238 } | 238 else |
239 break; | 239 this->hidden->type = AHIST_S8S; |
240 | 240 break; |
241 case 16: { /* Signed 16 bit audio data */ | 241 |
242 D(bug("Samples a 16 bit...\n")); | 242 case AUDIO_S16MSB: |
243 spec->format = AUDIO_S16MSB; | 243 D(bug("AUDIO_S16MSB...\n")); |
244 this->hidden->bytespersample=2; | 244 spec->format = AUDIO_S16MSB; |
245 if(spec->channels<2) | 245 this->hidden->bytespersample = 2; |
246 this->hidden->type = AHIST_M16S; | 246 if (spec->channels < 2) |
247 else | 247 this->hidden->type = AHIST_M16S; |
248 this->hidden->type = AHIST_S16S; | 248 else |
249 } | 249 this->hidden->type = AHIST_S16S; |
250 break; | 250 break; |
251 | 251 |
252 default: { | 252 default: |
253 SDL_SetError("Unsupported audio format"); | 253 valid_datatype = 0; |
254 return(-1); | 254 test_format = SDL_NextAudioFormat(); |
255 } | 255 break; |
256 } | 256 } |
257 | 257 } |
258 if(spec->channels!=1 && spec->channels!=2) | 258 |
259 { | 259 if (!valid_datatype) { /* shouldn't happen, but just in case... */ |
260 D(bug("Wrong channel number!\n")); | 260 SDL_SetError("Unsupported audio format"); |
261 SDL_SetError("Channel number non supported"); | 261 return (-1); |
262 return -1; | 262 } |
263 } | 263 |
264 if (spec->channels > 2) { | |
265 spec->channels = 2; /* will convert at higher level. */ | |
266 } | |
264 | 267 |
265 D(bug("Before CalculateAudioSpec\n")); | 268 D(bug("Before CalculateAudioSpec\n")); |
266 /* Update the fragment size as size in bytes */ | 269 /* Update the fragment size as size in bytes */ |
267 SDL_CalculateAudioSpec(spec); | 270 SDL_CalculateAudioSpec(spec); |
268 | 271 |