Skip to content

Commit

Permalink
More warning fixes
Browse files Browse the repository at this point in the history
- __MIX_INTERNAL_EFFECT__ -> MIX_INTERNAL_EFFECT__ ("reserved identifier")
- add missing casts
- change seek_sample from double to FLAC__uint64 in FLAC_Seek()
- change 255.0 to 255.0f in float divisons
- replace two tabs with 4 spaces in mixer.c
  • Loading branch information
Wohlstand committed Nov 26, 2019
1 parent ebaea1d commit 840d849
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/codecs/music_flac.c
Expand Up @@ -647,11 +647,11 @@ static int FLAC_GetAudio(void *context, void *data, int bytes)
static int FLAC_Seek(void *context, double position)
{
FLAC_Music *music = (FLAC_Music *)context;
double seek_sample = music->sample_rate * position;
FLAC__uint64 seek_sample = (FLAC__uint64) (music->sample_rate * position);

SDL_AudioStreamClear(music->stream);
music->pcm_pos = seek_sample;
if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, (FLAC__uint64)seek_sample)) {
if (!flac.FLAC__stream_decoder_seek_absolute(music->flac_decoder, seek_sample)) {
if (flac.FLAC__stream_decoder_get_state(music->flac_decoder) == FLAC__STREAM_DECODER_SEEK_ERROR) {
flac.FLAC__stream_decoder_flush(music->flac_decoder);
}
Expand Down
2 changes: 1 addition & 1 deletion src/effect_position.c
Expand Up @@ -33,7 +33,7 @@
#include "SDL_mixer.h"
#include "mixer.h"

#define __MIX_INTERNAL_EFFECT__
#define MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* profile code:
Expand Down
2 changes: 1 addition & 1 deletion src/effect_stereoreverse.c
Expand Up @@ -30,7 +30,7 @@
#include "SDL.h"
#include "SDL_mixer.h"

#define __MIX_INTERNAL_EFFECT__
#define MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* profile code:
Expand Down
6 changes: 3 additions & 3 deletions src/effects_internal.c
Expand Up @@ -30,7 +30,7 @@
#include <stdlib.h>
#include "SDL_mixer.h"

#define __MIX_INTERNAL_EFFECT__
#define MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* Should we favor speed over memory usage and/or quality of output? */
Expand Down Expand Up @@ -74,7 +74,7 @@ void *_Eff_build_volume_table_u8(void)
_Eff_volume_table = (void *) rc;
for (volume = 0; volume < 256; volume++) {
for (sample = -128; sample < 128; sample ++) {
*rc = (Uint8)(((float) sample) * ((float) volume / 255.0))
*rc = (Uint8)(((float) sample) * ((float) volume / 255.0f))
+ 128;
rc++;
}
Expand Down Expand Up @@ -105,7 +105,7 @@ void *_Eff_build_volume_table_s8(void)
_Eff_volume_table = (void *) rc;
for (volume = 0; volume < 256; volume++) {
for (sample = -128; sample < 128; sample ++) {
*rc = (Sint8)(((float) sample) * ((float) volume / 255.0));
*rc = (Sint8)(((float) sample) * ((float) volume / 255.0f));
rc++;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/effects_internal.h
Expand Up @@ -21,10 +21,10 @@

/* $Id$ */

#ifndef _INCLUDE_EFFECTS_INTERNAL_H_
#define _INCLUDE_EFFECTS_INTERNAL_H_
#ifndef INCLUDE_EFFECTS_INTERNAL_H_
#define INCLUDE_EFFECTS_INTERNAL_H_

#ifndef __MIX_INTERNAL_EFFECT__
#ifndef MIX_INTERNAL_EFFECT__
#error You should not include this file or use these functions.
#endif

Expand Down
14 changes: 7 additions & 7 deletions src/mixer.c
Expand Up @@ -33,7 +33,7 @@
#include "load_aiff.h"
#include "load_voc.h"

#define __MIX_INTERNAL_EFFECT__
#define MIX_INTERNAL_EFFECT__
#include "effects_internal.h"

/* Magic numbers for various audio file formats */
Expand Down Expand Up @@ -130,7 +130,7 @@ void add_chunk_decoder(const char *decoder)
}
}

ptr = SDL_realloc((void *)chunk_decoders, (num_decoders + 1) * sizeof (const char *));
ptr = SDL_realloc((void *)chunk_decoders, (size_t)(num_decoders + 1) * sizeof (const char *));
if (ptr == NULL) {
return; /* oh well, go on without it. */
}
Expand Down Expand Up @@ -236,11 +236,11 @@ static void *Mix_DoEffects(int chan, void *snd, int len)
if (e != NULL) { /* are there any registered effects? */
/* if this is the postmix, we can just overwrite the original. */
if (!posteffect) {
buf = SDL_malloc(len);
buf = SDL_malloc((size_t)len);
if (buf == NULL) {
return(snd);
}
SDL_memcpy(buf, snd, len);
SDL_memcpy(buf, snd, (size_t)len);
}

for (; e != NULL; e = e->next) {
Expand All @@ -267,7 +267,7 @@ mix_channels(void *udata, Uint8 *stream, int len)

#if SDL_VERSION_ATLEAST(1, 3, 0)
/* Need to initialize the stream in SDL 1.3+ */
SDL_memset(stream, mixer.silence, len);
SDL_memset(stream, mixer.silence, (size_t)len);
#endif

/* Mix the music (must be done before the channels are added) */
Expand Down Expand Up @@ -532,7 +532,7 @@ typedef struct _MusicFragment
static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
int i;
Mix_MusicType music_type;
Mix_MusicType music_type;
Mix_MusicInterface *interface = NULL;
void *music = NULL;
Sint64 start;
Expand All @@ -541,7 +541,7 @@ static SDL_AudioSpec *Mix_LoadMusic_RW(SDL_RWops *src, int freesrc, SDL_AudioSpe
int count = 0;
int fragment_size;

music_type = detect_music_type(src);
music_type = detect_music_type(src);
if (!load_music_type(music_type) || !open_music_type(music_type)) {
return NULL;
}
Expand Down
6 changes: 3 additions & 3 deletions src/music.c
Expand Up @@ -153,7 +153,7 @@ static void add_music_decoder(const char *decoder)
}
}

ptr = SDL_realloc((void *)music_decoders, (num_decoders + 1) * sizeof (const char *));
ptr = SDL_realloc((void *)music_decoders, ((size_t)num_decoders + 1) * sizeof (const char *));
if (ptr == NULL) {
return; /* oh well, go on without it. */
}
Expand Down Expand Up @@ -194,7 +194,7 @@ int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
if (volume == MIX_MAX_VOLUME) {
dst = snd;
} else {
dst = SDL_stack_alloc(Uint8, bytes);
dst = SDL_stack_alloc(Uint8, (size_t)bytes);
}
while (len > 0 && !done) {
int consumed = GetSome(context, dst, len, &done);
Expand Down Expand Up @@ -394,7 +394,7 @@ void open_music(const SDL_AudioSpec *spec)
Mix_VolumeMusic(MIX_MAX_VOLUME);

/* Calculate the number of ms for each callback */
ms_per_step = (int) (((float)spec->samples * 1000.0) / spec->freq);
ms_per_step = (int) (((float)spec->samples * 1000.0f) / spec->freq);
}

/* Return SDL_TRUE if the music type is available */
Expand Down

0 comments on commit 840d849

Please sign in to comment.