src/codecs/music_flac.c
changeset 1093 6f0bea2ab267
parent 1090 543b77a3c0eb
child 1099 a3c637d1a698
equal deleted inserted replaced
1092:e7e3052b74ae 1093:6f0bea2ab267
   553     }
   553     }
   554 
   554 
   555     if (was_error) {
   555     if (was_error) {
   556         switch (init_stage) {
   556         switch (init_stage) {
   557             case 2:
   557             case 2:
   558                 flac.FLAC__stream_decoder_finish(music->flac_decoder);
   558                 flac.FLAC__stream_decoder_finish(music->flac_decoder); /* fallthrough */
   559             case 1:
   559             case 1:
   560                 flac.FLAC__stream_decoder_delete(music->flac_decoder);
   560                 flac.FLAC__stream_decoder_delete(music->flac_decoder); /* fallthrough */
   561             case 0:
   561             case 0:
   562                 SDL_free(music);
   562                 SDL_free(music);
   563                 break;
   563                 break;
   564         }
   564         }
   565         return NULL;
   565         return NULL;
   566     }
   566     }
   567 
   567 
   568     /* loop_start, loop_end and loop_len get set by metadata callback if tags
   568     /* loop_start, loop_end and loop_len get set by metadata callback if tags
   569      * are present in metadata.
   569      * are present in metadata.
   570      */
   570      */
   571 
       
   572     full_length = flac.FLAC__stream_decoder_get_total_samples(music->flac_decoder);
   571     full_length = flac.FLAC__stream_decoder_get_total_samples(music->flac_decoder);
   573     if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
   572     if (((music->loop_start >= 0) || (music->loop_end > 0)) &&
   574         ((music->loop_start < music->loop_end) || (music->loop_end > 0)) &&
   573         ((music->loop_start < music->loop_end) || (music->loop_end > 0)) &&
   575          (music->loop_start < full_length) &&
   574          (music->loop_start < full_length) &&
   576          (music->loop_end <= full_length)) {
   575          (music->loop_end <= full_length)) {