comparison SDL_sound.c @ 37:f27bcbcaeab1

Added AIFF entry, and (for now) some multiple-streams-in-one-rwops support.
author Ryan C. Gordon <icculus@icculus.org>
date Thu, 20 Sep 2001 07:56:24 +0000
parents ddc3614c9042
children c4b8c39a9798
comparison
equal deleted inserted replaced
36:b2313d8c27cf 37:f27bcbcaeab1
50 50
51 #if (defined SOUND_SUPPORTS_WAV) 51 #if (defined SOUND_SUPPORTS_WAV)
52 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_WAV; 52 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_WAV;
53 #endif 53 #endif
54 54
55 #if (defined SOUND_SUPPORTS_AIFF)
56 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_AIFF;
57 #endif
58
55 #if (defined SOUND_SUPPORTS_OGG) 59 #if (defined SOUND_SUPPORTS_OGG)
56 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_OGG; 60 extern const Sound_DecoderFunctions __Sound_DecoderFunctions_OGG;
57 #endif 61 #endif
58 62
59 #if (defined SOUND_SUPPORTS_VOC) 63 #if (defined SOUND_SUPPORTS_VOC)
70 &__Sound_DecoderFunctions_MP3, 74 &__Sound_DecoderFunctions_MP3,
71 #endif 75 #endif
72 76
73 #if (defined SOUND_SUPPORTS_WAV) 77 #if (defined SOUND_SUPPORTS_WAV)
74 &__Sound_DecoderFunctions_WAV, 78 &__Sound_DecoderFunctions_WAV,
79 #endif
80
81 #if (defined SOUND_SUPPORTS_AIFF)
82 &__Sound_DecoderFunctions_AIFF,
75 #endif 83 #endif
76 84
77 #if (defined SOUND_SUPPORTS_OGG) 85 #if (defined SOUND_SUPPORTS_OGG)
78 &__Sound_DecoderFunctions_OGG, 86 &__Sound_DecoderFunctions_OGG,
79 #endif 87 #endif
291 static int init_sample(const Sound_DecoderFunctions *funcs, 299 static int init_sample(const Sound_DecoderFunctions *funcs,
292 Sound_Sample *sample, const char *ext, 300 Sound_Sample *sample, const char *ext,
293 Sound_AudioInfo *_desired) 301 Sound_AudioInfo *_desired)
294 { 302 {
295 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque; 303 Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
304 Sound_AudioInfo desired;
296 int pos = SDL_RWtell(internal->rw); /* !!! FIXME: Int? Really? */ 305 int pos = SDL_RWtell(internal->rw); /* !!! FIXME: Int? Really? */
297 Sound_AudioInfo desired;
298 306
299 /* fill in the funcs for this decoder... */ 307 /* fill in the funcs for this decoder... */
300 sample->decoder = &funcs->info; 308 sample->decoder = &funcs->info;
301 internal->funcs = funcs; 309 internal->funcs = funcs;
302 if (!funcs->open(sample, ext)) 310 if (!funcs->open(sample, ext))
352 internal->next = samplesList; 360 internal->next = samplesList;
353 if (samplesList != NULL) 361 if (samplesList != NULL)
354 internal->prev = sample; 362 internal->prev = sample;
355 } /* if */ 363 } /* if */
356 samplesList = sample; 364 samplesList = sample;
365
366 #if (defined MULTIPLE_STREAMS_PER_RWOPS)
367 internal->pos = SDL_RWtell(internal->rw);
368 #endif
357 369
358 _D(("New sample DESIRED format: %s format, %d rate, %d channels.\n", 370 _D(("New sample DESIRED format: %s format, %d rate, %d channels.\n",
359 fmt_to_str(sample->desired.format), 371 fmt_to_str(sample->desired.format),
360 sample->desired.rate, 372 sample->desired.rate,
361 sample->desired.channels)); 373 sample->desired.channels));
530 assert(internal->buffer_size > 0); 542 assert(internal->buffer_size > 0);
531 543
532 /* reset EAGAIN. Decoder can flip it back on if it needs to. */ 544 /* reset EAGAIN. Decoder can flip it back on if it needs to. */
533 sample->flags &= !SOUND_SAMPLEFLAG_EAGAIN; 545 sample->flags &= !SOUND_SAMPLEFLAG_EAGAIN;
534 546
547 #if (defined MULTIPLE_STREAMS_PER_RWOPS)
548 if (SDL_RWseek(internal->rw, internal->pos, SEEK_SET) == -1)
549 {
550 sample->flags |= SOUND_SAMPLEFLAG_ERROR;
551 return(0);
552 } /* if */
553 #endif
554
535 retval = internal->funcs->read(sample); 555 retval = internal->funcs->read(sample);
556
557 #if (defined MULTIPLE_STREAMS_PER_RWOPS)
558 internal->pos = SDL_RWtell(internal->rw);
559 #endif
560
536 if (internal->sdlcvt.needed) 561 if (internal->sdlcvt.needed)
537 { 562 {
538 internal->sdlcvt.len = retval; 563 internal->sdlcvt.len = retval;
539 SDL_ConvertAudio(&internal->sdlcvt); 564 SDL_ConvertAudio(&internal->sdlcvt);
540 retval *= internal->sdlcvt.len_mult; 565 retval *= internal->sdlcvt.len_mult;