music_flac.c: warning fixes from Vitaly Novichkov.
authorOzkan Sezer
Tue, 17 Dec 2019 18:50:10 +0300
changeset 1088840f92752d54
parent 1087 2019adc079cc
child 1089 6c766242c751
music_flac.c: warning fixes from Vitaly Novichkov.
src/codecs/music_flac.c
     1.1 --- a/src/codecs/music_flac.c	Tue Dec 17 15:55:02 2019 +0300
     1.2 +++ b/src/codecs/music_flac.c	Tue Dec 17 18:50:10 2019 +0300
     1.3 @@ -173,6 +173,8 @@
     1.4  {
     1.5      FLAC_Music *data = (FLAC_Music*)client_data;
     1.6  
     1.7 +    (void)decoder;
     1.8 +
     1.9      /* make sure there is something to be reading */
    1.10      if (*bytes > 0) {
    1.11          *bytes = SDL_RWread (data->src, buffer, sizeof (FLAC__byte), *bytes);
    1.12 @@ -194,7 +196,9 @@
    1.13  {
    1.14      FLAC_Music *data = (FLAC_Music*)client_data;
    1.15  
    1.16 -    if (SDL_RWseek(data->src, absolute_byte_offset, RW_SEEK_SET) < 0) {
    1.17 +    (void)decoder;
    1.18 +
    1.19 +    if (SDL_RWseek(data->src, (Sint64)absolute_byte_offset, RW_SEEK_SET) < 0) {
    1.20          return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
    1.21      } else {
    1.22          return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
    1.23 @@ -210,6 +214,8 @@
    1.24  
    1.25      Sint64 pos = SDL_RWtell(data->src);
    1.26  
    1.27 +    (void)decoder;
    1.28 +
    1.29      if (pos < 0) {
    1.30          return FLAC__STREAM_DECODER_TELL_STATUS_ERROR;
    1.31      } else {
    1.32 @@ -228,6 +234,8 @@
    1.33      Sint64 pos = SDL_RWtell(data->src);
    1.34      Sint64 length = SDL_RWseek(data->src, 0, RW_SEEK_END);
    1.35  
    1.36 +    (void)decoder;
    1.37 +
    1.38      if (SDL_RWseek(data->src, pos, RW_SEEK_SET) != pos || length < 0) {
    1.39          /* there was an error attempting to return the stream to the original
    1.40           * position, or the length was invalid. */
    1.41 @@ -247,6 +255,8 @@
    1.42      Sint64 pos = SDL_RWtell(data->src);
    1.43      Sint64 end = SDL_RWseek(data->src, 0, RW_SEEK_END);
    1.44  
    1.45 +    (void)decoder;
    1.46 +
    1.47      /* was the original position equal to the end (a.k.a. the seek didn't move)? */
    1.48      if (pos == end) {
    1.49          /* must be EOF */
    1.50 @@ -269,6 +279,8 @@
    1.51      unsigned int i, j, channels;
    1.52      int shift_amount = 0, amount;
    1.53  
    1.54 +    (void)decoder;
    1.55 +
    1.56      if (!music->stream) {
    1.57          return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
    1.58      }
    1.59 @@ -303,8 +315,8 @@
    1.60      if (music->channels == 3) {
    1.61          Sint16 *dst = data;
    1.62          for (i = 0; i < frame->header.blocksize; ++i) {
    1.63 -            Sint16 FL = (buffer[0][i] >> shift_amount);
    1.64 -            Sint16 FR = (buffer[1][i] >> shift_amount);
    1.65 +            Sint16 FL = (Sint16)(buffer[0][i] >> shift_amount);
    1.66 +            Sint16 FR = (Sint16)(buffer[1][i] >> shift_amount);
    1.67              Sint16 FCmix = (Sint16)((buffer[2][i] >> shift_amount) * 0.5f);
    1.68              int sample;
    1.69  
    1.70 @@ -314,7 +326,7 @@
    1.71              } else if (sample < SDL_MIN_SINT16) {
    1.72                  *dst = SDL_MIN_SINT16;
    1.73              } else {
    1.74 -                *dst = sample;
    1.75 +                *dst = (Sint16)sample;
    1.76              }
    1.77              ++dst;
    1.78  
    1.79 @@ -324,7 +336,7 @@
    1.80              } else if (sample < SDL_MIN_SINT16) {
    1.81                  *dst = SDL_MIN_SINT16;
    1.82              } else {
    1.83 -                *dst = sample;
    1.84 +                *dst = (Sint16)sample;
    1.85              }
    1.86              ++dst;
    1.87          }
    1.88 @@ -332,13 +344,13 @@
    1.89          for (i = 0; i < channels; ++i) {
    1.90              Sint16 *dst = data + i;
    1.91              for (j = 0; j < frame->header.blocksize; ++j) {
    1.92 -                *dst = (buffer[i][j] >> shift_amount);
    1.93 +                *dst = (Sint16)(buffer[i][j] >> shift_amount);
    1.94                  dst += channels;
    1.95              }
    1.96          }
    1.97      }
    1.98 -    amount = frame->header.blocksize * channels * sizeof(*data);
    1.99 -    music->pcm_pos += frame->header.blocksize;
   1.100 +    amount = (int)(frame->header.blocksize * channels * sizeof(*data));
   1.101 +    music->pcm_pos += (FLAC__uint64) frame->header.blocksize;
   1.102      if ((music->loop == 1) && (music->play_count != 1) &&
   1.103          (music->pcm_pos >= music->loop_end)) {
   1.104          amount -= (music->pcm_pos - music->loop_end) * channels * sizeof(*data);
   1.105 @@ -396,6 +408,8 @@
   1.106      char *param, *argument, *value;
   1.107      SDL_bool is_loop_length = SDL_FALSE;
   1.108  
   1.109 +    (void)decoder;
   1.110 +
   1.111      if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) {
   1.112          music->sample_rate = metadata->data.stream_info.sample_rate;
   1.113          music->channels = metadata->data.stream_info.channels;
   1.114 @@ -408,15 +422,15 @@
   1.115          if (music->channels == 3) {
   1.116              channels = 2;
   1.117          } else {
   1.118 -            channels = music->channels;
   1.119 +            channels = (int)music->channels;
   1.120          }
   1.121  
   1.122          /* We check for NULL stream later when we get data */
   1.123          SDL_assert(!music->stream);
   1.124 -        music->stream = SDL_NewAudioStream(AUDIO_S16SYS, channels, music->sample_rate,
   1.125 +        music->stream = SDL_NewAudioStream(AUDIO_S16SYS, (Uint8)channels, (int)music->sample_rate,
   1.126                                            music_spec.format, music_spec.channels, music_spec.freq);
   1.127      } else if (metadata->type == FLAC__METADATA_TYPE_VORBIS_COMMENT) {
   1.128 -        int i;
   1.129 +        FLAC__uint32 i;
   1.130  
   1.131          vc  = &metadata->data.vorbis_comment;
   1.132          rate = music->sample_rate;
   1.133 @@ -446,8 +460,8 @@
   1.134                  music->loop_len = SDL_strtoull(value, NULL, 10);
   1.135                  is_loop_length = SDL_TRUE;
   1.136              } else if (SDL_strcasecmp(argument, "LOOPEND") == 0) {
   1.137 +                music->loop_end = parse_time(value, rate);
   1.138                  is_loop_length = SDL_FALSE;
   1.139 -                music->loop_end = parse_time(value, rate);
   1.140              }
   1.141              SDL_free(param);
   1.142          }
   1.143 @@ -465,6 +479,9 @@
   1.144                  FLAC__StreamDecoderErrorStatus status,
   1.145                  void *client_data)
   1.146  {
   1.147 +    (void)decoder;
   1.148 +    (void)client_data;
   1.149 +
   1.150      /* print an SDL error based on the error status */
   1.151      switch (status) {
   1.152      case FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: