Do a file type check on custom audio

This commit is contained in:
MysterD 2022-05-09 04:12:54 -07:00
parent 493c35fd03
commit 51c301c431
1 changed files with 16 additions and 0 deletions

View File

@ -163,6 +163,22 @@ static bool audio_sanity_check(struct BassAudio* audio, bool isStream, const cha
}
struct BassAudio* audio_load_internal(const char* filename, bool isStream) {
// check file type
bool validFileType = false;
const char* fileTypes[] = { ".mp3", ".aiff", ".ogg", NULL };
const char** ft = fileTypes;
while (*ft != NULL) {
if (str_ends_with((char*)filename, (char*)*ft)) {
validFileType = true;
break;
}
ft++;
}
if (!validFileType) {
LOG_LUA_LINE("Tried to load audio file with invalid file type: %s", filename);
return NULL;
}
// find mod file in mod list
bool foundModFile = false;
struct ModFile* modFile = NULL;