flac, ogg, opus: no reason initializing music->loop to -1 in CreateFromRW
authorOzkan Sezer
Fri, 20 Dec 2019 11:50:05 +0300
changeset 11012e69576079bd
parent 1100 ba8b8227a7bd
child 1102 91dc8a87aaee
flac, ogg, opus: no reason initializing music->loop to -1 in CreateFromRW
src/codecs/music_flac.c
src/codecs/music_ogg.c
src/codecs/music_opus.c
     1.1 --- a/src/codecs/music_flac.c	Fri Dec 20 11:50:05 2019 +0300
     1.2 +++ b/src/codecs/music_flac.c	Fri Dec 20 11:50:05 2019 +0300
     1.3 @@ -352,7 +352,7 @@
     1.4      }
     1.5      amount = (int)(frame->header.blocksize * channels * sizeof(*data));
     1.6      music->pcm_pos += (FLAC__int64) frame->header.blocksize;
     1.7 -    if ((music->loop == 1) && (music->play_count != 1) &&
     1.8 +    if (music->loop && (music->play_count != 1) &&
     1.9          (music->pcm_pos >= music->loop_end)) {
    1.10          amount -= (music->pcm_pos - music->loop_end) * channels * sizeof(*data);
    1.11          music->loop_flag = SDL_TRUE;
    1.12 @@ -419,7 +419,7 @@
    1.13          music->sample_rate = metadata->data.stream_info.sample_rate;
    1.14          music->channels = metadata->data.stream_info.channels;
    1.15          music->bits_per_sample = metadata->data.stream_info.bits_per_sample;
    1.16 -      /*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/
    1.17 +        /*printf("FLAC: Sample rate = %d, channels = %d, bits_per_sample = %d\n", music->sample_rate, music->channels, music->bits_per_sample);*/
    1.18  
    1.19          /* SDL's channel mapping and FLAC channel mapping are the same,
    1.20             except for 3 channels: SDL is FL FR LFE and FLAC is FL FR FC
    1.21 @@ -527,7 +527,6 @@
    1.22      }
    1.23      music->src = src;
    1.24      music->volume = MIX_MAX_VOLUME;
    1.25 -    music->loop = -1;
    1.26  
    1.27      music->flac_decoder = flac.FLAC__stream_decoder_new();
    1.28      if (music->flac_decoder) {
     2.1 --- a/src/codecs/music_ogg.c	Fri Dec 20 11:50:05 2019 +0300
     2.2 +++ b/src/codecs/music_ogg.c	Fri Dec 20 11:50:05 2019 +0300
     2.3 @@ -279,7 +279,6 @@
     2.4      music->src = src;
     2.5      music->volume = MIX_MAX_VOLUME;
     2.6      music->section = -1;
     2.7 -    music->loop = -1;
     2.8  
     2.9      SDL_zero(callbacks);
    2.10      callbacks.read_func = sdl_read_func;
    2.11 @@ -404,7 +403,7 @@
    2.12      }
    2.13  
    2.14      pcmPos = vorbis.ov_pcm_tell(&music->vf);
    2.15 -    if ((music->loop == 1) && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
    2.16 +    if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
    2.17          amount -= (int)((pcmPos - music->loop_end) * music->vi.channels) * (int)sizeof(Sint16);
    2.18          result = vorbis.ov_pcm_seek(&music->vf, music->loop_start);
    2.19          if (result < 0) {
     3.1 --- a/src/codecs/music_opus.c	Fri Dec 20 11:50:05 2019 +0300
     3.2 +++ b/src/codecs/music_opus.c	Fri Dec 20 11:50:05 2019 +0300
     3.3 @@ -270,7 +270,6 @@
     3.4      music->src = src;
     3.5      music->volume = MIX_MAX_VOLUME;
     3.6      music->section = -1;
     3.7 -    music->loop = -1;
     3.8  
     3.9      SDL_zero(callbacks);
    3.10      callbacks.read = sdl_read_func;
    3.11 @@ -399,7 +398,7 @@
    3.12      }
    3.13  
    3.14      pcmPos = opus.op_pcm_tell(music->of);
    3.15 -    if ((music->loop == 1) && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
    3.16 +    if (music->loop && (music->play_count != 1) && (pcmPos >= music->loop_end)) {
    3.17          samples -= (int)((pcmPos - music->loop_end) * music->op_info->channel_count) * (int)sizeof(Sint16);
    3.18          result = opus.op_pcm_seek(music->of, music->loop_start);
    3.19          if (result < 0) {
    3.20 @@ -447,8 +446,7 @@
    3.21  static int OPUS_Seek(void *context, double time)
    3.22  {
    3.23      OPUS_music *music = (OPUS_music *)context;
    3.24 -    int result;
    3.25 -    result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000));
    3.26 +    int result = opus.op_pcm_seek(music->of, (ogg_int64_t)(time * 48000));
    3.27      if (result < 0) {
    3.28          return set_op_error("op_pcm_seek", result);
    3.29      }