comparison src/audio/SDL_wave.c @ 1330:450721ad5436

It's now possible to build SDL without any C runtime at all on Windows, using Visual C++ 2005
author Sam Lantinga <slouken@libsdl.org>
date Mon, 06 Feb 2006 08:28:51 +0000
parents c9b51268668f
children 3692456e7b0f
comparison
equal deleted inserted replaced
1329:bc67bbf87818 1330:450721ad5436
22 22
23 #ifndef DISABLE_FILE 23 #ifndef DISABLE_FILE
24 24
25 /* Microsoft WAVE file loading routines */ 25 /* Microsoft WAVE file loading routines */
26 26
27 #include <stdlib.h>
28 #include <string.h>
29
30 #include "SDL_error.h" 27 #include "SDL_error.h"
31 #include "SDL_audio.h" 28 #include "SDL_audio.h"
29 #include "SDL_stdlib.h"
30 #include "SDL_string.h"
32 #include "SDL_wave.h" 31 #include "SDL_wave.h"
33 #include "SDL_endian.h" 32 #include "SDL_endian.h"
34 33
35 #ifndef NELEMS
36 #define NELEMS(array) ((sizeof array)/(sizeof array[0]))
37 #endif
38 34
39 static int ReadChunk(SDL_RWops *src, Chunk *chunk); 35 static int ReadChunk(SDL_RWops *src, Chunk *chunk);
40 36
41 struct MS_ADPCM_decodestate { 37 struct MS_ADPCM_decodestate {
42 Uint8 hPredictor; 38 Uint8 hPredictor;
340 Sint32 encoded_len, samplesleft; 336 Sint32 encoded_len, samplesleft;
341 int c, channels; 337 int c, channels;
342 338
343 /* Check to make sure we have enough variables in the state array */ 339 /* Check to make sure we have enough variables in the state array */
344 channels = IMA_ADPCM_state.wavefmt.channels; 340 channels = IMA_ADPCM_state.wavefmt.channels;
345 if ( channels > NELEMS(IMA_ADPCM_state.state) ) { 341 if ( channels > SDL_arraysize(IMA_ADPCM_state.state) ) {
346 SDL_SetError("IMA ADPCM decoder can only handle %d channels", 342 SDL_SetError("IMA ADPCM decoder can only handle %d channels",
347 NELEMS(IMA_ADPCM_state.state)); 343 SDL_arraysize(IMA_ADPCM_state.state));
348 return(-1); 344 return(-1);
349 } 345 }
350 state = IMA_ADPCM_state.state; 346 state = IMA_ADPCM_state.state;
351 347
352 /* Allocate the proper sized output buffer */ 348 /* Allocate the proper sized output buffer */
562 if ( freesrc && src ) { 558 if ( freesrc && src ) {
563 SDL_RWclose(src); 559 SDL_RWclose(src);
564 } 560 }
565 else { 561 else {
566 // seek to the end of the file (given by the RIFF chunk) 562 // seek to the end of the file (given by the RIFF chunk)
567 SDL_RWseek(src, wavelen - chunk.length - headerDiff, SEEK_CUR); 563 SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
568 } 564 }
569 if ( was_error ) { 565 if ( was_error ) {
570 spec = NULL; 566 spec = NULL;
571 } 567 }
572 return(spec); 568 return(spec);