diff options
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 4 | ||||
-rw-r--r-- | player/external_files.c | 39 | ||||
-rw-r--r-- | player/external_files.h | 1 |
3 files changed, 23 insertions, 21 deletions
diff --git a/player/command.c b/player/command.c index a00b42ca8c..0a45469308 100644 --- a/player/command.c +++ b/player/command.c @@ -33,6 +33,7 @@ #include "mpv_talloc.h" #include "client.h" +#include "external_files.h" #include "common/av_common.h" #include "common/codecs.h" #include "common/msg.h" @@ -6946,6 +6947,9 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, if (flags & UPDATE_INPUT) mp_input_update_opts(mpctx->input); + if (flags & UPDATE_SUB_EXTS) + mp_update_subtitle_exts(mpctx->opts); + if (init || opt_ptr == &opts->ipc_path || opt_ptr == &opts->ipc_client) { mp_uninit_ipc(mpctx->ipc_ctx); mpctx->ipc_ctx = mp_init_ipc(mpctx->clients, mpctx->global); diff --git a/player/external_files.c b/player/external_files.c index 451f05bcfb..000fafc82c 100644 --- a/player/external_files.c +++ b/player/external_files.c @@ -32,20 +32,6 @@ #include "options/path.h" #include "external_files.h" -static const char *const sub_exts[] = {"ass", "idx", "lrc", "mks", "pgs", "rt", - "sbv", "scc", "smi", "srt", "ssa", "sub", - "sup", "utf", "utf-8", "utf8", "vtt", - NULL}; - -static const char *const audio_exts[] = {"aac", "ac3", "dts", "eac3", "flac", - "m4a", "mka", "mp3", "ogg", "opus", - "thd", "wav", "wv", - NULL}; - -static const char *const image_exts[] = {"avif", "bmp", "gif", "jpeg", "jpg", - "jxl", "png", "tif", "tiff", "webp", - NULL}; - // Stolen from: vlc/-/blob/master/modules/meta_engine/folder.c#L40 // sorted by priority (descending) static const char *const cover_files[] = { @@ -92,22 +78,28 @@ static const char *const cover_files[] = { NULL }; -static bool test_ext_list(bstr ext, const char *const *list) +// Needed for mp_might_be_subtitle_file +char **sub_exts; + +static bool test_ext_list(bstr ext, char **list) { + if (!list) + goto done; for (int n = 0; list[n]; n++) { if (bstrcasecmp(bstr0(list[n]), ext) == 0) return true; } +done: return false; } -static int test_ext(bstr ext) +static int test_ext(MPOpts *opts, bstr ext) { - if (test_ext_list(ext, sub_exts)) + if (test_ext_list(ext, opts->sub_auto_exts)) return STREAM_SUB; - if (test_ext_list(ext, audio_exts)) + if (test_ext_list(ext, opts->audiofile_auto_exts)) return STREAM_AUDIO; - if (test_ext_list(ext, image_exts)) + if (test_ext_list(ext, opts->coverart_auto_exts)) return STREAM_VIDEO; return -1; } @@ -124,7 +116,12 @@ static int test_cover_filename(bstr fname) bool mp_might_be_subtitle_file(const char *filename) { - return test_ext(bstr_get_ext(bstr0(filename))) == STREAM_SUB; + return test_ext_list(bstr_get_ext(bstr0(filename)), sub_exts); +} + +void mp_update_subtitle_exts(struct MPOpts *opts) +{ + sub_exts = opts->sub_auto_exts; } static int compare_sub_filename(const void *a, const void *b) @@ -220,7 +217,7 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, talloc_steal(tmpmem2, dename.start); // check what it is (most likely) - int type = test_ext(tmp_fname_ext); + int type = test_ext(opts, tmp_fname_ext); char **langs = NULL; int fuzz = -1; switch (type) { diff --git a/player/external_files.h b/player/external_files.h index e64f249c6d..20b37c3705 100644 --- a/player/external_files.h +++ b/player/external_files.h @@ -33,5 +33,6 @@ struct subfn *find_external_files(struct mpv_global *global, const char *fname, struct MPOpts *opts); bool mp_might_be_subtitle_file(const char *filename); +void mp_update_subtitle_exts(struct MPOpts *opts); #endif /* MPLAYER_FINDFILES_H */ |