From ad2199128da4a689be374e92aab57ac2c9fa76b9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 21 Dec 2013 20:45:19 +0100 Subject: path lookup functions: mp_msg conversions There's a single mp_msg() in path.c, but all path lookup functions seem to depend on it, so we get a rat-tail of stuff we have to change. This is probably a good thing though, because we can have the path lookup functions also access options, so we could allow overriding the default config path, or ignore the MPV_HOME environment variable, and such things. Also take the chance to consistently add talloc_ctx parameters to the path lookup functions. Also, this change causes a big mess on configfiles.c. It's the same issue: everything suddenly needs a (different) context argument. Make it less wild by providing a mp_load_auto_profiles() function, which isolates most of it to configfiles.c. --- input/input.c | 4 +- options/path.c | 40 +++++++++++--------- options/path.h | 15 +++++--- osdep/path-macosx.m | 5 ++- osdep/path.h | 5 ++- player/command.c | 2 +- player/configfiles.c | 101 +++++++++++++++++++++++++++++---------------------- player/core.h | 15 +++----- player/loadfile.c | 13 +------ player/lua.c | 3 +- player/main.c | 2 +- player/screenshot.c | 2 +- stream/stream_dvb.c | 3 -- sub/ass_mp.c | 18 ++++----- sub/find_subfiles.c | 2 +- video/out/gl_lcms.c | 2 +- 16 files changed, 122 insertions(+), 110 deletions(-) diff --git a/input/input.c b/input/input.c index 8756985793..fc3e282287 100644 --- a/input/input.c +++ b/input/input.c @@ -2202,7 +2202,7 @@ static int parse_config_file(struct input_ctx *ictx, char *file, bool warn) void *tmp = talloc_new(NULL); stream_t *s = NULL; - file = mp_get_user_path(tmp, file); + file = mp_get_user_path(tmp, ictx->global, file); if (!mp_path_exists(file)) { MP_MSG(ictx, warn ? MSGL_ERR : MSGL_V, "Input config file %s not found.\n", file); @@ -2418,7 +2418,7 @@ struct input_ctx *mp_input_init(struct mpv_global *global) config_ok = parse_config_file(ictx, input_conf->config_file, true); if (!config_ok && global->opts->load_config) { // Try global conf dir - char *file = mp_find_config_file("input.conf"); + char *file = mp_find_config_file(NULL, global, "input.conf"); config_ok = file && parse_config_file(ictx, file, false); talloc_free(file); } diff --git a/options/path.c b/options/path.c index 43c2c0fb80..17d6245582 100644 --- a/options/path.c +++ b/options/path.c @@ -33,13 +33,14 @@ #include #include #include "config.h" +#include "common/global.h" #include "common/msg.h" #include "options/path.h" #include "talloc.h" #include "osdep/io.h" #include "osdep/path.h" -typedef char *(*lookup_fun)(const char *); +typedef char *(*lookup_fun)(void *tctx, struct mpv_global *global, const char *); static const lookup_fun config_lookup_functions[] = { mp_find_user_config_file, #if HAVE_COCOA @@ -49,10 +50,11 @@ static const lookup_fun config_lookup_functions[] = { NULL }; -char *mp_find_config_file(const char *filename) +char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename) { for (int i = 0; config_lookup_functions[i] != NULL; i++) { - char *path = config_lookup_functions[i](filename); + char *path = config_lookup_functions[i](talloc_ctx, global, filename); if (!path) continue; if (mp_path_exists(path)) @@ -63,7 +65,8 @@ char *mp_find_config_file(const char *filename) return NULL; } -char *mp_find_user_config_file(const char *filename) +char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename) { char *homedir = getenv("MPV_HOME"); char *configdir = NULL; @@ -71,7 +74,7 @@ char *mp_find_user_config_file(const char *filename) if (!homedir) { #ifdef _WIN32 - result = mp_get_win_config_path(filename); + result = talloc_steal(talloc_ctx, mp_get_win_config_path(filename)); #endif homedir = getenv("HOME"); configdir = ".mpv"; @@ -79,25 +82,27 @@ char *mp_find_user_config_file(const char *filename) if (!result && homedir) { char *temp = mp_path_join(NULL, bstr0(homedir), bstr0(configdir)); - result = mp_path_join(NULL, bstr0(temp), bstr0(filename)); + result = mp_path_join(talloc_ctx, bstr0(temp), bstr0(filename)); talloc_free(temp); } - mp_msg(MSGT_GLOBAL, MSGL_V, "mp_find_user_config_file('%s') -> '%s'\n", - filename ? filename : "(NULL)", result ? result : "(NULL)"); + MP_VERBOSE(global, "mp_find_user_config_file('%s') -> '%s'\n", + filename ? filename : "(NULL)", result ? result : "(NULL)"); return result; } -char *mp_find_global_config_file(const char *filename) +char *mp_find_global_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename) { if (filename) { - return mp_path_join(NULL, bstr0(MPLAYER_CONFDIR), bstr0(filename)); + return mp_path_join(talloc_ctx, bstr0(MPLAYER_CONFDIR), bstr0(filename)); } else { - return talloc_strdup(NULL, MPLAYER_CONFDIR); + return talloc_strdup(talloc_ctx, MPLAYER_CONFDIR); } } -char *mp_get_user_path(void *talloc_ctx, const char *path) +char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, + const char *path) { if (!path) return NULL; @@ -108,10 +113,11 @@ char *mp_get_user_path(void *talloc_ctx, const char *path) if (bstr_split_tok(bpath, "/", &prefix, &rest)) { const char *rest0 = rest.start; // ok in this case char *res = NULL; - if (bstr_equals0(prefix, "~")) - res = talloc_steal(talloc_ctx, mp_find_user_config_file(rest0)); - if (bstr_equals0(prefix, "")) + if (bstr_equals0(prefix, "~")) { + res = mp_find_user_config_file(talloc_ctx, global, rest0); + } else if (bstr_equals0(prefix, "")) { res = mp_path_join(talloc_ctx, bstr0(getenv("HOME")), rest); + } if (res) return res; } @@ -225,10 +231,10 @@ bool mp_is_url(bstr path) return true; } -void mp_mk_config_dir(char *subdir) +void mp_mk_config_dir(struct mpv_global *global, char *subdir) { void *tmp = talloc_new(NULL); - char *confdir = talloc_steal(tmp, mp_find_user_config_file("")); + char *confdir = mp_find_user_config_file(tmp, global, ""); if (confdir) { if (subdir) confdir = mp_path_join(tmp, bstr0(confdir), bstr0(subdir)); diff --git a/options/path.h b/options/path.h index e3de212ef3..0e1744bbd0 100644 --- a/options/path.h +++ b/options/path.h @@ -24,22 +24,27 @@ #include #include "bstr/bstr.h" +struct mpv_global; // Search for the input filename in several paths. These include user and global // config locations by default. Some platforms may implement additional platform // related lookups (i.e.: OSX inside an application bundle). -char *mp_find_config_file(const char *filename); +char *mp_find_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename); // Search for the input filename in the global configuration location. -char *mp_find_global_config_file(const char *filename); +char *mp_find_global_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename); // Search for the input filename in the user configuration location. -char *mp_find_user_config_file(const char *filename); +char *mp_find_user_config_file(void *talloc_ctx, struct mpv_global *global, + const char *filename); // Normally returns a talloc_strdup'ed copy of the path, except for special // paths starting with '~'. Used to allow the user explicitly reference a // file from the user's home or mpv config directory. -char *mp_get_user_path(void *talloc_ctx, const char *path); +char *mp_get_user_path(void *talloc_ctx, struct mpv_global *global, + const char *path); // Return pointer to filename part of path @@ -70,6 +75,6 @@ bool mp_path_isdir(const char *path); bool mp_is_url(bstr path); -void mp_mk_config_dir(char *subdir); +void mp_mk_config_dir(struct mpv_global *global, char *subdir); #endif /* MPLAYER_PATH_H */ diff --git a/osdep/path-macosx.m b/osdep/path-macosx.m index d4c5020da1..543b248c14 100644 --- a/osdep/path-macosx.m +++ b/osdep/path-macosx.m @@ -20,11 +20,12 @@ #include "options/path.h" #include "osdep/path.h" -char *mp_get_macosx_bundled_path(const char *file) +char *mp_get_macosx_bundled_path(void *talloc_ctx, struct mpv_global *global, + const char *filename) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *path = [[NSBundle mainBundle] resourcePath]; - char *rv = mp_path_join(NULL, bstr0([path UTF8String]), bstr0(file)); + char *rv = mp_path_join(talloc_ctx, bstr0([path UTF8String]), bstr0(file)); [pool release]; return rv; } diff --git a/osdep/path.h b/osdep/path.h index 6ad4ebad8a..91afbce604 100644 --- a/osdep/path.h +++ b/osdep/path.h @@ -1,9 +1,12 @@ #ifndef OSDEP_PATH_H #define OSDEP_PATH_H +struct mpv_global; + char *mp_get_win_config_path(const char *filename); // Returns absolute path of a resource file in a Mac OS X application bundle. -char *mp_get_macosx_bundled_path(const char *filename); +char *mp_get_macosx_bundled_path(void *talloc_ctx, struct mpv_global *global, + const char *filename); #endif diff --git a/player/command.c b/player/command.c index b5f5a059e5..a7ded72836 100644 --- a/player/command.c +++ b/player/command.c @@ -2801,7 +2801,7 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd) if (!append && mpctx->playlist->first) { struct playlist_entry *e = - mp_resume_playlist(mpctx->playlist, opts); + mp_check_playlist_resume(mpctx, mpctx->playlist); mp_set_playlist_entry(mpctx, e ? e : mpctx->playlist->first); } } else { diff --git a/player/configfiles.c b/player/configfiles.c index 37d081b953..87da9d9260 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -55,8 +55,8 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx) return true; if (!m_config_parse_config_file(conf, MPLAYER_CONFDIR "/mpv.conf", 0) < 0) return false; - mp_mk_config_dir(NULL); - if ((conffile = mp_find_user_config_file("config")) == NULL) + mp_mk_config_dir(mpctx->global, NULL); + if (!(conffile = mp_find_user_config_file(NULL, mpctx->global, "config"))) MP_ERR(mpctx, "mp_find_user_config_file(\"config\") problem\n"); else { int fd = open(conffile, O_CREAT | O_EXCL | O_WRONLY | O_CLOEXEC, 0666); @@ -78,9 +78,10 @@ bool mp_parse_cfgfiles(struct MPContext *mpctx) #define PROFILE_CFG_PROTOCOL "protocol." -void mp_load_per_protocol_config(m_config_t *conf, const char * const file) +static void mp_load_per_protocol_config(struct MPContext *mpctx) { char *str; + const char *file = mpctx->filename; char protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) + 1]; m_profile_t *p; @@ -93,19 +94,19 @@ void mp_load_per_protocol_config(m_config_t *conf, const char * const file) sprintf(protocol, "%s%s", PROFILE_CFG_PROTOCOL, file); protocol[strlen(PROFILE_CFG_PROTOCOL) + strlen(file) - strlen(str)] = '\0'; - p = m_config_get_profile0(conf, protocol); + p = m_config_get_profile0(mpctx->mconfig, protocol); if (p) { - mp_msg(MSGT_CPLAYER, MSGL_INFO, - "Loading protocol-related profile '%s'\n", protocol); - m_config_set_profile(conf, p, FILE_LOCAL_FLAGS); + MP_INFO(mpctx, "Loading protocol-related profile '%s'\n", protocol); + m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS); } } #define PROFILE_CFG_EXTENSION "extension." -void mp_load_per_extension_config(m_config_t *conf, const char * const file) +static void mp_load_per_extension_config(struct MPContext *mpctx) { char *str; + const char *file = mpctx->filename; char extension[strlen(PROFILE_CFG_EXTENSION) + 8]; m_profile_t *p; @@ -116,15 +117,14 @@ void mp_load_per_extension_config(m_config_t *conf, const char * const file) sprintf(extension, PROFILE_CFG_EXTENSION); strncat(extension, ++str, 7); - p = m_config_get_profile0(conf, extension); + p = m_config_get_profile0(mpctx->mconfig, extension); if (p) { - mp_msg(MSGT_CPLAYER, MSGL_INFO, - "Loading extension-related profile '%s'\n", extension); - m_config_set_profile(conf, p, FILE_LOCAL_FLAGS); + MP_INFO(mpctx, "Loading extension-related profile '%s'\n", extension); + m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS); } } -void mp_load_per_output_config(m_config_t *conf, char *cfg, char *out) +static void mp_load_per_output_config(struct MPContext *mpctx, char *cfg, char *out) { char profile[strlen(cfg) + strlen(out) + 1]; m_profile_t *p; @@ -133,54 +133,68 @@ void mp_load_per_output_config(m_config_t *conf, char *cfg, char *out) return; sprintf(profile, "%s%s", cfg, out); - p = m_config_get_profile0(conf, profile); + p = m_config_get_profile0(mpctx->mconfig, profile); if (p) { - mp_msg(MSGT_CPLAYER, MSGL_INFO, - "Loading extension-related profile '%s'\n", profile); - m_config_set_profile(conf, p, FILE_LOCAL_FLAGS); + MP_INFO(mpctx, "Loading extension-related profile '%s'\n", profile); + m_config_set_profile(mpctx->mconfig, p, FILE_LOCAL_FLAGS); } } +void mp_load_auto_profiles(struct MPContext *mpctx) +{ + struct MPOpts *opts = mpctx->opts; + + mp_load_per_protocol_config(mpctx); + mp_load_per_extension_config(mpctx); + mp_load_per_file_config(mpctx); + + if (opts->vo.video_driver_list) + mp_load_per_output_config(mpctx, "vo.", opts->vo.video_driver_list[0].name); + if (opts->audio_driver_list) + mp_load_per_output_config(mpctx, "ao.", opts->audio_driver_list[0].name); +} + /** * Tries to load a config file (in file local mode) * @return 0 if file was not found, 1 otherwise */ -static int try_load_config(m_config_t *conf, const char *file, int flags) +static int try_load_config(struct MPContext *mpctx, const char *file, int flags) { if (!mp_path_exists(file)) return 0; - mp_msg(MSGT_CPLAYER, MSGL_INFO, "Loading config '%s'\n", file); - m_config_parse_config_file(conf, file, flags); + MP_INFO(mpctx, "Loading config '%s'\n", file); + m_config_parse_config_file(mpctx->mconfig, file, flags); return 1; } -void mp_load_per_file_config(m_config_t *conf, const char * const file, - bool search_file_dir) +void mp_load_per_file_config(struct MPContext *mpctx) { + struct MPOpts *opts = mpctx->opts; char *confpath; char cfg[MP_PATH_MAX]; const char *name; + const char *file = mpctx->filename; if (strlen(file) > MP_PATH_MAX - 14) { - mp_msg(MSGT_CPLAYER, MSGL_WARN, "Filename is too long, " + MP_WARN(mpctx, "Filename is too long, " "can not load file or directory specific config files\n"); return; } sprintf(cfg, "%s.conf", file); name = mp_basename(cfg); - if (search_file_dir) { + if (opts->use_filedir_conf) { char dircfg[MP_PATH_MAX]; strcpy(dircfg, cfg); strcpy(dircfg + (name - cfg), "mpv.conf"); - try_load_config(conf, dircfg, FILE_LOCAL_FLAGS); + try_load_config(mpctx, dircfg, FILE_LOCAL_FLAGS); - if (try_load_config(conf, cfg, FILE_LOCAL_FLAGS)) + if (try_load_config(mpctx, cfg, FILE_LOCAL_FLAGS)) return; } - if ((confpath = mp_find_user_config_file(name)) != NULL) { - try_load_config(conf, confpath, FILE_LOCAL_FLAGS); + if ((confpath = mp_find_user_config_file(NULL, mpctx->global, name))) { + try_load_config(mpctx, confpath, FILE_LOCAL_FLAGS); talloc_free(confpath); } @@ -188,8 +202,8 @@ void mp_load_per_file_config(m_config_t *conf, const char * const file, #define MP_WATCH_LATER_CONF "watch_later" -char *mp_get_playback_resume_config_filename(const char *fname, - struct MPOpts *opts) +static char *mp_get_playback_resume_config_filename(struct mpv_global *global, + const char *fname) { char *res = NULL; void *tmp = talloc_new(NULL); @@ -218,7 +232,7 @@ char *mp_get_playback_resume_config_filename(const char *fname, conf = talloc_asprintf(tmp, "%s/%s", MP_WATCH_LATER_CONF, conf); - res = mp_find_user_config_file(conf); + res = mp_find_user_config_file(NULL, global, conf); exit: talloc_free(tmp); @@ -284,10 +298,10 @@ void mp_write_watch_later_conf(struct MPContext *mpctx) if (pos == MP_NOPTS_VALUE) goto exit; - mp_mk_config_dir(MP_WATCH_LATER_CONF); + mp_mk_config_dir(mpctx->global, MP_WATCH_LATER_CONF); - char *conffile = mp_get_playback_resume_config_filename(mpctx->filename, - mpctx->opts); + char *conffile = mp_get_playback_resume_config_filename(mpctx->global, + mpctx->filename); talloc_steal(tmp, conffile); if (!conffile) goto exit; @@ -318,15 +332,15 @@ exit: talloc_free(tmp); } -void mp_load_playback_resume(m_config_t *conf, const char *file) +void mp_load_playback_resume(struct MPContext *mpctx, const char *file) { - char *fname = mp_get_playback_resume_config_filename(file, conf->optstruct); + char *fname = mp_get_playback_resume_config_filename(mpctx->global, file); if (fname && mp_path_exists(fname)) { // Never apply the saved start position to following files - m_config_backup_opt(conf, "start"); - mp_msg(MSGT_CPLAYER, MSGL_INFO, "Resuming playback. This behavior can " + m_config_backup_opt(mpctx->mconfig, "start"); + MP_INFO(mpctx, "Resuming playback. This behavior can " "be disabled with --no-resume-playback.\n"); - try_load_config(conf, fname, M_SETOPT_PRESERVE_CMDLINE); + try_load_config(mpctx, fname, M_SETOPT_PRESERVE_CMDLINE); unlink(fname); } talloc_free(fname); @@ -337,13 +351,14 @@ void mp_load_playback_resume(m_config_t *conf, const char *file) // resume file for them, this is simpler, and also has the nice property // that appending to a playlist doesn't interfere with resuming (especially // if the playlist comes from the command line). -struct playlist_entry *mp_resume_playlist(struct playlist *playlist, - struct MPOpts *opts) +struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx, + struct playlist *playlist) { - if (!opts->position_resume) + if (!mpctx->opts->position_resume) return NULL; for (struct playlist_entry *e = playlist->first; e; e = e->next) { - char *conf = mp_get_playback_resume_config_filename(e->filename, opts); + char *conf = mp_get_playback_resume_config_filename(mpctx->global, + e->filename); bool exists = conf && mp_path_exists(conf); talloc_free(conf); if (exists) diff --git a/player/core.h b/player/core.h index 4aafc53d5b..ad3d121aa7 100644 --- a/player/core.h +++ b/player/core.h @@ -348,17 +348,12 @@ void clear_audio_decode_buffers(struct MPContext *mpctx); // configfiles.c bool mp_parse_cfgfiles(struct MPContext *mpctx); -char *mp_get_playback_resume_config_filename(const char *fname, - struct MPOpts *opts); -void mp_load_per_protocol_config(struct m_config *conf, const char * const file); -void mp_load_per_extension_config(struct m_config *conf, const char * const file); -void mp_load_per_output_config(struct m_config *conf, char *cfg, char *out); -void mp_load_per_file_config(struct m_config *conf, const char * const file, - bool search_file_dir); -void mp_load_playback_resume(struct m_config *conf, const char *file); +void mp_load_auto_profiles(struct MPContext *mpctx); +void mp_load_per_file_config(struct MPContext *mpctx); +void mp_load_playback_resume(struct MPContext *mpctx, const char *file); void mp_write_watch_later_conf(struct MPContext *mpctx); -struct playlist_entry *mp_resume_playlist(struct playlist *playlist, - struct MPOpts *opts); +struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx, + struct playlist *playlist); // dvdnav.c void mp_nav_init(struct MPContext *mpctx); diff --git a/player/loadfile.c b/player/loadfile.c index deda26ee2a..31ac4b3c4c 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1001,19 +1001,10 @@ static void play_current_file(struct MPContext *mpctx) } } - mp_load_per_protocol_config(mpctx->mconfig, mpctx->filename); - mp_load_per_extension_config(mpctx->mconfig, mpctx->filename); - mp_load_per_file_config(mpctx->mconfig, mpctx->filename, opts->use_filedir_conf); - - if (opts->vo.video_driver_list) - mp_load_per_output_config(mpctx->mconfig, "vo.", - opts->vo.video_driver_list[0].name); - if (opts->audio_driver_list) - mp_load_per_output_config(mpctx->mconfig, "ao.", - opts->audio_driver_list[0].name); + mp_load_auto_profiles(mpctx); if (opts->position_resume) - mp_load_playback_resume(mpctx->mconfig, mpctx->filename); + mp_load_playback_resume(mpctx, mpctx->filename); load_per_file_options(mpctx->mconfig, mpctx->playlist->current->params, mpctx->playlist->current->num_params); diff --git a/player/lua.c b/player/lua.c index 87b13e3c09..a3e119a76a 100644 --- a/player/lua.c +++ b/player/lua.c @@ -297,8 +297,9 @@ static int script_log(lua_State *L) static int script_find_config_file(lua_State *L) { + struct MPContext *mpctx = get_mpctx(L); const char *s = luaL_checkstring(L, 1); - char *path = mp_find_user_config_file(s); + char *path = mp_find_user_config_file(NULL, mpctx->global, s); if (path) { lua_pushstring(L, path); } else { diff --git a/player/main.c b/player/main.c index 71ce31e082..30263a0649 100644 --- a/player/main.c +++ b/player/main.c @@ -423,7 +423,7 @@ static int mpv_main(int argc, char *argv[]) if (opts->merge_files) merge_playlist_files(mpctx->playlist); - mpctx->playlist->current = mp_resume_playlist(mpctx->playlist, opts); + mpctx->playlist->current = mp_check_playlist_resume(mpctx, mpctx->playlist); if (!mpctx->playlist->current) mpctx->playlist->current = mpctx->playlist->first; diff --git a/player/screenshot.c b/player/screenshot.c index 70a85bc80b..7336c64e97 100644 --- a/player/screenshot.c +++ b/player/screenshot.c @@ -234,7 +234,7 @@ static char *create_fname(struct MPContext *mpctx, char *template, res = talloc_strdup_append(res, template); res = talloc_asprintf_append(res, ".%s", file_ext); - char *fname = mp_get_user_path(NULL, res); + char *fname = mp_get_user_path(NULL, mpctx->global, res); talloc_free(res); return fname; diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index aabe7170a9..fb247753d7 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -740,9 +740,6 @@ dvb_config_t *dvb_get_config(stream_t *stream) continue; } -// rebase hack -#define mp_find_user_config_file(a,b,c) mp_find_user_config_file(c) -#define mp_find_global_config_file(a, b, c) mp_find_global_config_file(c) void *talloc_ctx = talloc_new(NULL); conf_file = mp_find_user_config_file(talloc_ctx, global, "channels.conf"); switch(type) { diff --git a/sub/ass_mp.c b/sub/ass_mp.c index 39737824a2..e77ce298dd 100644 --- a/sub/ass_mp.c +++ b/sub/ass_mp.c @@ -153,20 +153,18 @@ void mp_ass_configure(ASS_Renderer *priv, struct MPOpts *opts, void mp_ass_configure_fonts(ASS_Renderer *priv, struct osd_style_opts *opts, struct mpv_global *global, struct mp_log *log) { - char *default_font = mp_find_user_config_file("subfont.ttf"); - char *config = mp_find_config_file("fonts.conf"); + void *tmp = talloc_new(NULL); + char *default_font = mp_find_user_config_file(tmp, global, "subfont.ttf"); + char *config = mp_find_config_file(tmp, global, "fonts.conf"); - if (default_font && !mp_path_exists(default_font)) { - talloc_free(default_font); + if (default_font && !mp_path_exists(default_font)) default_font = NULL; - } - mp_msg(MSGT_ASS, MSGL_V, "Setting up fonts...\n"); + mp_verbose(log, "Setting up fonts...\n"); ass_set_fonts(priv, default_font, opts->font, 1, config, 1); - mp_msg(MSGT_ASS, MSGL_V, "Done.\n"); + mp_verbose(log, "Done.\n"); - talloc_free(default_font); - talloc_free(config); + talloc_free(tmp); } void mp_ass_render_frame(ASS_Renderer *renderer, ASS_Track *track, double time, @@ -228,7 +226,7 @@ static void message_callback(int level, const char *format, va_list va, void *ct ASS_Library *mp_ass_init(struct mpv_global *global, struct mp_log *log) { - char *path = mp_find_user_config_file("fonts"); + char *path = mp_find_user_config_file(NULL, global, "fonts"); ASS_Library *priv = ass_library_init(); if (!priv) abort(); diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c index 84b7cd1bfe..e5577c3912 100644 --- a/sub/find_subfiles.c +++ b/sub/find_subfiles.c @@ -237,7 +237,7 @@ struct subfn *find_text_subtitles(struct mpv_global *global, const char *fname) } // Load subtitles in ~/.mpv/sub limiting sub fuzziness - char *mp_subdir = mp_find_user_config_file("sub/"); + char *mp_subdir = mp_find_user_config_file(NULL, global, "sub/"); if (mp_subdir) append_dir_subtitles(global, &slist, &n, bstr0(mp_subdir), fname, 1); talloc_free(mp_subdir); diff --git a/video/out/gl_lcms.c b/video/out/gl_lcms.c index 5da2411c4c..da6d520fa0 100644 --- a/video/out/gl_lcms.c +++ b/video/out/gl_lcms.c @@ -94,7 +94,7 @@ static struct bstr load_file(void *talloc_ctx, const char *filename, struct mpv_global *global) { struct bstr res = {0}; - char *fname = mp_get_user_path(NULL, filename); + char *fname = mp_get_user_path(NULL, global, filename); stream_t *s = stream_open(fname, global); if (s) { res = stream_read_complete(s, talloc_ctx, 1000000000); -- cgit v1.2.3