comparison SDL_sound.c @ 143:3e60862fbd76

Start of audio converter work.
author Ryan C. Gordon <icculus@icculus.org>
date Mon, 15 Oct 2001 21:21:11 +0000
parents fd942c1433f8
children 1df5c106504e
comparison
equal deleted inserted replaced
142:56f6acdc4ea0 143:3e60862fbd76
379 /* Now we need to set up the conversion buffer... */ 379 /* Now we need to set up the conversion buffer... */
380 380
381 memcpy(&desired, (_desired != NULL) ? _desired : &sample->actual, 381 memcpy(&desired, (_desired != NULL) ? _desired : &sample->actual,
382 sizeof (Sound_AudioInfo)); 382 sizeof (Sound_AudioInfo));
383 383
384 if (SDL_BuildAudioCVT(&internal->sdlcvt, 384 if (Sound_BuildAudioCVT(&internal->sdlcvt,
385 sample->actual.format, 385 sample->actual.format,
386 sample->actual.channels, 386 sample->actual.channels,
387 (int) sample->actual.rate, /* !!! FIXME: Int? Really? */ 387 sample->actual.rate,
388 desired.format, 388 desired.format,
389 desired.channels, 389 desired.channels,
390 (int) desired.rate) == -1) /* !!! FIXME: Int? Really? */ 390 desired.rate) == -1)
391 { 391 {
392 Sound_SetError(SDL_GetError()); 392 Sound_SetError(SDL_GetError());
393 funcs->close(sample); 393 funcs->close(sample);
394 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */ 394 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */
395 return(0); 395 return(0);
396 } /* if */ 396 } /* if */
397 397
398 if (internal->sdlcvt.len_mult > 1) 398 if (internal->sdlcvt.len_mult > 1)
399 { 399 {
400 void *rc = realloc(sample->buffer, 400 void *rc = realloc(sample->buffer,
401 sample->buffer_size * internal->sdlcvt.len_mult); 401 sample->buffer_size * internal->sdlcvt.len_mult);
402 if (rc == NULL) 402 if (rc == NULL)
403 { 403 {
404 funcs->close(sample); 404 funcs->close(sample);
405 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */ 405 SDL_RWseek(internal->rw, pos, SEEK_SET); /* set for next try... */
406 return(0); 406 return(0);
609 retval = internal->funcs->read(sample); 609 retval = internal->funcs->read(sample);
610 610
611 if (internal->sdlcvt.needed) 611 if (internal->sdlcvt.needed)
612 { 612 {
613 internal->sdlcvt.len = retval; 613 internal->sdlcvt.len = retval;
614 SDL_ConvertAudio(&internal->sdlcvt); 614 Sound_ConvertAudio(&internal->sdlcvt);
615 retval *= internal->sdlcvt.len_mult; 615 retval = internal->sdlcvt.len_cvt;
616 } /* if */ 616 } /* if */
617 617
618 return(retval); 618 return(retval);
619 } /* Sound_Decode */ 619 } /* Sound_Decode */
620 620