comparison src/audio/amigaos/SDL_ahiaudio.c @ 1996:f25d771fe6f2

Added int32 support to Amiga audio driver and cleaned up some other details in driver initialization. May need tweaking: I can't compile the amiga driver here.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 31 Aug 2006 21:43:25 +0000
parents c121d94672cb
children cbac0f77a799
comparison
equal deleted inserted replaced
1995:0ca6ba107642 1996:f25d771fe6f2
224 224
225 static int 225 static int
226 AHI_OpenAudio(_THIS, SDL_AudioSpec * spec) 226 AHI_OpenAudio(_THIS, SDL_AudioSpec * spec)
227 { 227 {
228 // int width; 228 // int width;
229 SDL_AudioFormat test_format = SDL_FirstAudioFormat(spec->format);
230 int valid_datatype = 0;
229 231
230 D(bug("AHI opening...\n")); 232 D(bug("AHI opening...\n"));
231 233
232 /* Determine the audio parameters from the AudioSpec */ 234 /* Determine the audio parameters from the AudioSpec */
233 switch (spec->format & 0xFF) { 235 while ((!valid_datatype) && (test_format)) {
234 236 switch (test_format) {
235 case 8: 237 case AUDIO_S8:
236 { /* Signed 8 bit audio data */ 238 D(bug("AUDIO_S8...\n"));
237 D(bug("Samples a 8 bit...\n")); 239 valid_datatype = 1;
238 spec->format = AUDIO_S8; 240 spec->format = AUDIO_S8;
239 this->hidden->bytespersample = 1; 241 this->hidden->bytespersample = 1;
240 if (spec->channels < 2) 242 if (spec->channels < 2)
241 this->hidden->type = AHIST_M8S; 243 this->hidden->type = AHIST_M8S;
242 else 244 else
243 this->hidden->type = AHIST_S8S; 245 this->hidden->type = AHIST_S8S;
244 } 246 break;
245 break; 247
246 248 case AUDIO_S16MSB:
247 case 16: 249 D(bug("AUDIO_S16MSB...\n"));
248 { /* Signed 16 bit audio data */ 250 valid_datatype = 1;
249 D(bug("Samples a 16 bit...\n")); 251 spec->format = AUDIO_S16MSB;
250 spec->format = AUDIO_S16MSB; 252 this->hidden->bytespersample = 2;
251 this->hidden->bytespersample = 2; 253 if (spec->channels < 2)
252 if (spec->channels < 2) 254 this->hidden->type = AHIST_M16S;
253 this->hidden->type = AHIST_M16S; 255 else
254 else 256 this->hidden->type = AHIST_S16S;
255 this->hidden->type = AHIST_S16S; 257 break;
256 } 258
257 break; 259 case AUDIO_S32MSB:
258 260 D(bug("AUDIO_S32MSB...\n"));
259 default: 261 valid_datatype = 1;
260 { 262 spec->format = AUDIO_S32MSB;
261 SDL_SetError("Unsupported audio format"); 263 this->hidden->bytespersample = 4;
262 return (-1); 264 if (spec->channels < 2)
263 } 265 this->hidden->type = AHIST_M32S;
264 } 266 else
265 267 this->hidden->type = AHIST_S32S;
266 if (spec->channels != 1 && spec->channels != 2) { 268 break;
267 D(bug("Wrong channel number!\n")); 269
268 SDL_SetError("Channel number non supported"); 270 default:
269 return -1; 271 test_format = SDL_NextAudioFormat();
272 break;
273 }
274 }
275
276 if (!valid_datatype) { /* shouldn't happen, but just in case... */
277 SDL_SetError("Unsupported audio format");
278 return (-1);
279 }
280
281 if (spec->channels > 2) {
282 spec->channels = 2; /* will convert at higher level. */
270 } 283 }
271 284
272 D(bug("Before CalculateAudioSpec\n")); 285 D(bug("Before CalculateAudioSpec\n"));
273 /* Update the fragment size as size in bytes */ 286 /* Update the fragment size as size in bytes */
274 SDL_CalculateAudioSpec(spec); 287 SDL_CalculateAudioSpec(spec);