Skip to content

Commit

Permalink
disable several MS Visual Studio warnings
Browse files Browse the repository at this point in the history
 and fix those ones in example programs.
  • Loading branch information
sezero committed Dec 25, 2024
1 parent 0a935e0 commit 5d983db
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
12 changes: 6 additions & 6 deletions examples/playsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ static volatile playsound_global_state global_state;
static Uint32 cvtMsToBytePos(Sound_AudioInfo *info, Uint32 ms)
{
/* "frames" == "sample frames" */
float frames_per_ms = ((float) info->rate) / 1000.0;
float frames_per_ms = ((float) info->rate) / 1000.0f;
Uint32 frame_offset = (Uint32) (frames_per_ms * ((float) ms));
Uint32 frame_size = (Uint32) ((info->format & 0xFF) / 8) * info->channels;
return(frame_offset * frame_size);
Expand Down Expand Up @@ -276,7 +276,7 @@ static int read_more_data(Sound_Sample *sample)
} /* if */

if ((global_state.bytes_before_next_seek >= 0) &&
(global_state.decoded_bytes > global_state.bytes_before_next_seek))
(global_state.decoded_bytes > (Uint32)global_state.bytes_before_next_seek))
{
global_state.decoded_bytes = global_state.bytes_before_next_seek;
} /* if */
Expand Down Expand Up @@ -476,8 +476,8 @@ static void SDLCALL audio_callback(void *userdata, Uint8 *stream, int len)
/* decoded_bytes and decoder_ptr are updated as necessary... */

cpysize = len - bw;
if (cpysize > global_state.decoded_bytes)
cpysize = global_state.decoded_bytes;
if (cpysize > (Sint32)global_state.decoded_bytes)
cpysize = (Sint32)global_state.decoded_bytes;

if (cpysize > 0)
{
Expand Down Expand Up @@ -829,8 +829,8 @@ int main(int argc, char **argv)

else if (SDL_strcmp(argv[i], "--volume") == 0 && argc > i + 1)
{
global_state.volume = SDL_atof(argv[++i]);
if (global_state.volume != 1.0)
global_state.volume = (float)SDL_atof(argv[++i]);
if (global_state.volume != 1.0f)
global_state.wants_volume_change = 1;
} /* else if */

Expand Down
5 changes: 2 additions & 3 deletions examples/playsound_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ static void SDLCALL audio_callback(void *userdata, Uint8 *stream, int len)

/* we have data decoded and ready to write to the device... */
cpysize = len - bw; /* len - bw == amount device still wants. */
if (cpysize > data->decoded_bytes)
cpysize = data->decoded_bytes; /* clamp to what we have left. */
if (cpysize > (Sint32)data->decoded_bytes)
cpysize = (Sint32)data->decoded_bytes; /* clamp to what we have left. */

/* if it's 0, next iteration will decode more or decide we're done. */
if (cpysize > 0)
Expand All @@ -96,7 +96,6 @@ static void SDLCALL audio_callback(void *userdata, Uint8 *stream, int len)
} /* audio_callback */



static void playOneSoundFile(const char *fname)
{
PlaysoundAudioCallbackData data;
Expand Down
11 changes: 11 additions & 0 deletions src/SDL_sound_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@
#define SNDDBG(x)
#endif

/* disable several MS Visual Studio warnings: */
#ifdef _MSC_VER
#pragma warning(disable:4100) /* unreferenced formal parameter */
#pragma warning(disable:4389) /* signed/unsigned mismatch ( <, <=, >, >= ) */
#pragma warning(disable:4018) /* signed/unsigned mismatch ( ==, != ) */
#pragma warning(disable:4127) /* conditional expression is constant. */
#pragma warning(disable:4761) /* integral size mismatch in argument; conversion supplied (for MSVC6 and older.) */
#pragma warning(disable:4244) /* conversion from 'type' to 'int', possible loss of data */
#pragma warning(disable:4267) /* conversion from 'size_t' to 'type', possible loss of data */
#endif

#ifndef SOUND_SUPPORTS_MIDI
#define SOUND_SUPPORTS_MIDI 1
#endif
Expand Down

0 comments on commit 5d983db

Please sign in to comment.