Skip to content

Commit 43a8d0c

Browse files
committed
music.c: Move MP3 detection code down
1 parent 7ac7a98 commit 43a8d0c

File tree

1 file changed

+21
-22
lines changed

1 file changed

+21
-22
lines changed

src/music.c

+21-22
Original file line numberDiff line numberDiff line change
@@ -676,28 +676,6 @@ Mix_MusicType detect_music_type(SDL_RWops *src)
676676
return MUS_MID;
677677
}
678678

679-
#ifdef ID3_EXTRA_FORMAT_CHECKS
680-
if (SDL_memcmp(magic, "ID3", 3) == 0) {
681-
id3len = get_id3v2_length(src);
682-
683-
/* Check if there is something not an MP3, however, also has ID3 tag */
684-
if (id3len > 0) {
685-
SDL_RWseek(src, id3len, SDL_RW_SEEK_CUR);
686-
readlen = SDL_RWread(src, submagic, 4);
687-
SDL_RWseek(src, start, SDL_RW_SEEK_SET);
688-
689-
if (readlen == 4) {
690-
if (SDL_memcmp(submagic, "fLaC", 4) == 0)
691-
return MUS_FLAC;
692-
}
693-
}
694-
}
695-
696-
/* Detect MP3 format by frame header [needs scanning of bigger part of the file] */
697-
if (detect_mp3(submagic, src, start, id3len)) {
698-
return MUS_MP3;
699-
}
700-
701679
/* GME Specific files */
702680
if (SDL_memcmp(magic, "ZXAY", 4) == 0)
703681
return MUS_GME;
@@ -724,6 +702,27 @@ Mix_MusicType detect_music_type(SDL_RWops *src)
724702
if (SDL_memcmp(magic, "\x1f\x8b", 2) == 0)
725703
return MUS_GME;
726704

705+
if (SDL_memcmp(magic, "ID3", 3) == 0) {
706+
id3len = get_id3v2_length(src);
707+
708+
/* Check if there is something not an MP3, however, also has ID3 tag */
709+
if (id3len > 0) {
710+
SDL_RWseek(src, id3len, SDL_RW_SEEK_CUR);
711+
readlen = SDL_RWread(src, submagic, 4);
712+
SDL_RWseek(src, start, SDL_RW_SEEK_SET);
713+
714+
if (readlen == 4) {
715+
if (SDL_memcmp(submagic, "fLaC", 4) == 0)
716+
return MUS_FLAC;
717+
}
718+
}
719+
}
720+
721+
/* Detect MP3 format by frame header [needs scanning of bigger part of the file] */
722+
if (detect_mp3(submagic, src, start, id3len)) {
723+
return MUS_MP3;
724+
}
725+
727726
/* Assume MOD format.
728727
*
729728
* Apparently there is no way to check if the file is really a MOD,

0 commit comments

Comments
 (0)