summaryrefslogtreecommitdiffstats
path: root/options/options.h
diff options
context:
space:
mode:
authorDudemanguy <random342@airmail.cc>2023-08-10 17:36:22 -0500
committerDudemanguy <random342@airmail.cc>2023-08-26 00:33:00 +0000
commit32be72623b1d43027f2d97c15fcf604d8c328e00 (patch)
tree7d58216175bb08fc77ae746d19902194bdbfa43f /options/options.h
parentafdd2fa5656140c55a0b685e498a89a2249a623a (diff)
downloadmpv-32be72623b1d43027f2d97c15fcf604d8c328e00.tar.bz2
mpv-32be72623b1d43027f2d97c15fcf604d8c328e00.tar.xz
player: make all autoload extensions configurable
--audio-file-auto, --cover-art-auto, and --sub-auto all work by using an internally hardcoded list that determine what file extensions get recognized. This is fine and people periodically update it, but we can actually expose this as a stringlist option instead. This way users can add or remove any file extension for any type. For the most part, this is pretty pretty easy and involves making sub_exts, etc. the defaults for the new options (--audio-file-auto-exts, --cover-art-auto-exts, and --sub-auto-exts). There's actually one slight complication however. The input code uses mp_might_be_subtitle_file which guesses if the file drag and dropped file is a subtitle. The input ctx has no access to mpctx so we have to be clever here. For this, the trick is to recognize that we can leverage the m_option_change_callback. We add a new flag, UPDATE_SUB_EXTS, which fires when the player starts up. Then in the callback, we can set the value of sub_exts in external_files to opts->sub_auto_exts. Whenever the option updates, the callback is fired again and sub_exts updates. That way mp_might_be_subtitle_file can just operate off of this global variable instead of trying to mess with the core mpv state directly. Fixes #12000.
Diffstat (limited to 'options/options.h')
-rw-r--r--options/options.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/options/options.h b/options/options.h
index fac88dd939..6f8c8a5998 100644
--- a/options/options.h
+++ b/options/options.h
@@ -309,8 +309,11 @@ typedef struct MPOpts {
char **external_files;
bool autoload_files;
int sub_auto;
+ char **sub_auto_exts;
int audiofile_auto;
+ char **audiofile_auto_exts;
int coverart_auto;
+ char **coverart_auto_exts;
bool coverart_whitelist;
bool osd_bar_visible;