base: audio fixes

This commit is contained in:
luboslenco
2026-05-31 17:33:00 +02:00
parent 4bfdae9b1f
commit b5b7660281
12 changed files with 201 additions and 356 deletions
+26 -2
View File
@@ -14,6 +14,7 @@ bool path_is_protected_linux = false;
string_array_t *_path_mesh_formats = NULL;
string_array_t *_path_texture_formats = NULL;
string_array_t *_path_audio_formats = NULL;
static string_array_t *_path_base_color_ext = NULL;
static string_array_t *_path_opacity_ext = NULL;
static string_array_t *_path_normal_map_ext = NULL;
@@ -49,6 +50,16 @@ string_array_t *path_texture_formats(void) {
return _path_texture_formats;
}
string_array_t *path_audio_formats(void) {
if (_path_audio_formats == NULL) {
_path_audio_formats = string_array_create(0);
gc_root(_path_audio_formats);
string_array_push(_path_audio_formats, "wav");
string_array_push(_path_audio_formats, "ogg");
}
return _path_audio_formats;
}
string_array_t *path_base_color_ext(void) {
if (_path_base_color_ext == NULL) {
_path_base_color_ext = string_array_create(0);
@@ -240,6 +251,19 @@ bool path_is_texture(char *path) {
return false;
}
bool path_is_audio(char *path) {
char *p = to_lower_case(path);
string_array_t *formats = path_audio_formats();
for (uint32_t i = 0; i < formats->length; ++i) {
char *s = formats->buffer[i];
char *ext = string(".%s", s);
if (ends_with(p, ext)) {
return true;
}
}
return false;
}
bool path_is_font(char *path) {
char *p = to_lower_case(path);
return ends_with(p, ".ttf") || ends_with(p, ".ttc") || ends_with(p, ".otf");
@@ -276,8 +300,8 @@ bool path_is_lut(char *path) {
}
bool path_is_known(char *path) {
return path_is_mesh(path) || path_is_texture(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) || path_is_text(path) ||
path_is_ext_format(path) || path_is_lut(path);
return path_is_mesh(path) || path_is_texture(path) || path_is_audio(path) || path_is_font(path) || path_is_project(path) || path_is_plugin(path) ||
path_is_text(path) || path_is_ext_format(path) || path_is_lut(path);
}
bool path_check_ext(char *p, string_array_t *exts) {