Skip to content

Commit

Permalink
wav: fixed compiler warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jul 16, 2018
1 parent 4dfa1ba commit 9ca6a54
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/SDL_sound_wav.c
Expand Up @@ -65,6 +65,16 @@ static SDL_INLINE int read_le32(SDL_RWops *rw, Uint32 *ui32)
return 1;
} /* read_le32 */

static SDL_INLINE int read_le16s(SDL_RWops *rw, Sint16 *si16)
{
return read_le16(rw, (Uint16 *) si16);
} /* read_le16s */

static SDL_INLINE int read_le32s(SDL_RWops *rw, Sint32 *si32)
{
return read_le32(rw, (Uint32 *) si32);
} /* read_le32s */


/* This is just cleaner on the caller's end... */
static SDL_INLINE int read_uint8(SDL_RWops *rw, Uint8 *ui8)
Expand Down Expand Up @@ -157,11 +167,11 @@ static int read_fmt_chunk(SDL_RWops *rw, fmt_t *fmt)
/* skip reading the chunk ID, since it was already read at this point... */
fmt->chunkID = fmtID;

BAIL_IF_MACRO(!read_le32(rw, &fmt->chunkSize), NULL, 0);
BAIL_IF_MACRO(!read_le32s(rw, &fmt->chunkSize), NULL, 0);
BAIL_IF_MACRO(fmt->chunkSize < 16, "WAV: Invalid chunk size", 0);
fmt->next_chunk_offset = SDL_RWtell(rw) + fmt->chunkSize;

BAIL_IF_MACRO(!read_le16(rw, &fmt->wFormatTag), NULL, 0);
BAIL_IF_MACRO(!read_le16s(rw, &fmt->wFormatTag), NULL, 0);
BAIL_IF_MACRO(!read_le16(rw, &fmt->wChannels), NULL, 0);
BAIL_IF_MACRO(!read_le32(rw, &fmt->dwSamplesPerSec), NULL, 0);
BAIL_IF_MACRO(!read_le32(rw, &fmt->dwAvgBytesPerSec), NULL, 0);
Expand Down Expand Up @@ -195,7 +205,7 @@ static int read_data_chunk(SDL_RWops *rw, data_t *data)
{
/* skip reading the chunk ID, since it was already read at this point... */
data->chunkID = dataID;
BAIL_IF_MACRO(!read_le32(rw, &data->chunkSize), NULL, 0);
BAIL_IF_MACRO(!read_le32s(rw, &data->chunkSize), NULL, 0);
return 1;
} /* read_data_chunk */

Expand Down Expand Up @@ -322,10 +332,10 @@ static SDL_INLINE int read_adpcm_block_headers(Sound_Sample *sample)
BAIL_IF_MACRO(!read_le16(rw, &headers[i].iDelta), NULL, 0);

for (i = 0; i < max; i++)
BAIL_IF_MACRO(!read_le16(rw, &headers[i].iSamp1), NULL, 0);
BAIL_IF_MACRO(!read_le16s(rw, &headers[i].iSamp1), NULL, 0);

for (i = 0; i < max; i++)
BAIL_IF_MACRO(!read_le16(rw, &headers[i].iSamp2), NULL, 0);
BAIL_IF_MACRO(!read_le16s(rw, &headers[i].iSamp2), NULL, 0);

fmt->fmt.adpcm.samples_left_in_block = fmt->fmt.adpcm.wSamplesPerBlock;
fmt->fmt.adpcm.nibble_state = 0;
Expand Down Expand Up @@ -575,8 +585,8 @@ static int read_fmt_adpcm(SDL_RWops *rw, fmt_t *fmt)

for (i = 0; i < fmt->fmt.adpcm.wNumCoef; i++)
{
BAIL_IF_MACRO(!read_le16(rw, &fmt->fmt.adpcm.aCoef[i].iCoef1), NULL, 0);
BAIL_IF_MACRO(!read_le16(rw, &fmt->fmt.adpcm.aCoef[i].iCoef2), NULL, 0);
BAIL_IF_MACRO(!read_le16s(rw, &fmt->fmt.adpcm.aCoef[i].iCoef1), NULL, 0);
BAIL_IF_MACRO(!read_le16s(rw, &fmt->fmt.adpcm.aCoef[i].iCoef2), NULL, 0);
} /* for */

i = sizeof (ADPCMBLOCKHEADER) * fmt->wChannels;
Expand Down Expand Up @@ -646,7 +656,7 @@ static int find_chunk(SDL_RWops *rw, Uint32 id)
return 1;

/* skip ahead and see what next chunk is... */
BAIL_IF_MACRO(!read_le32(rw, &siz), NULL, 0);
BAIL_IF_MACRO(!read_le32s(rw, &siz), NULL, 0);
SDL_assert(siz >= 0);
pos += (sizeof (Uint32) * 2) + siz;
if (siz > 0)
Expand All @@ -673,7 +683,7 @@ static int WAV_open_internal(Sound_Sample *sample, const char *ext, fmt_t *fmt)

sample->actual.channels = (Uint8) fmt->wChannels;
sample->actual.rate = fmt->dwSamplesPerSec;
if ((fmt->wBitsPerSample == 4) /*|| (fmt->wBitsPerSample == 0) */ )
if (fmt->wBitsPerSample == 4)
sample->actual.format = AUDIO_S16SYS;
else if (fmt->wBitsPerSample == 8)
sample->actual.format = AUDIO_U8;
Expand Down

0 comments on commit 9ca6a54

Please sign in to comment.