From b6346cd0bafc6a56c29b9c6c56e612e32295ea98 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 9 May 2015 16:21:44 +0200 Subject: player: make resuming playlists less noisy in verbose mode mp_find_config_file() will print the filename lookup and its result in verbose mode. This is wanted, but gets inconvenient when it is done for every playlist entry (for resuming). Lookup the watch_later subdir only once and cache the result instead. This drops the logic for loading the resume file from other locations, which should generally be unnecessary, though might lead to confusion if the user has mixed old and new config paths (which the user shouldn't). Also add a mp_find_user_config_file() function for a more straightforward and reliable way to get actual local configpaths, instead of possibly global and unwritable locations. Also, for symmetry, check the resume option in mp_load_playback_resume() just like mp_check_playlist_resume() does. --- player/configfiles.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'player/configfiles.c') diff --git a/player/configfiles.c b/player/configfiles.c index 6806938a1a..0cd1d0d523 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -166,10 +166,10 @@ void mp_load_auto_profiles(struct MPContext *mpctx) #define MP_WATCH_LATER_CONF "watch_later" -static char *mp_get_playback_resume_config_filename(struct mpv_global *global, +static char *mp_get_playback_resume_config_filename(struct MPContext *mpctx, const char *fname) { - struct MPOpts *opts = global->opts; + struct MPOpts *opts = mpctx->opts; char *res = NULL; void *tmp = talloc_new(NULL); const char *realpath = fname; @@ -195,15 +195,14 @@ static char *mp_get_playback_resume_config_filename(struct mpv_global *global, for (int i = 0; i < 16; i++) conf = talloc_asprintf_append(conf, "%02X", md5[i]); - res = talloc_asprintf(tmp, MP_WATCH_LATER_CONF "/%s", conf); - res = mp_find_config_file(NULL, global, res); - - if (!res) { - res = mp_find_config_file(tmp, global, MP_WATCH_LATER_CONF); - if (res) - res = talloc_asprintf(NULL, "%s/%s", res, conf); + if (!mpctx->cached_watch_later_configdir) { + mpctx->cached_watch_later_configdir = + mp_find_user_config_file(mpctx, mpctx->global, MP_WATCH_LATER_CONF); } + if (mpctx->cached_watch_later_configdir) + res = mp_path_join(NULL, mpctx->cached_watch_later_configdir, conf); + exit: talloc_free(tmp); return res; @@ -298,7 +297,7 @@ void mp_write_watch_later_conf(struct MPContext *mpctx) mp_mk_config_dir(mpctx->global, MP_WATCH_LATER_CONF); - conffile = mp_get_playback_resume_config_filename(mpctx->global, filename); + conffile = mp_get_playback_resume_config_filename(mpctx, filename); if (!conffile) goto exit; @@ -342,7 +341,9 @@ exit: void mp_load_playback_resume(struct MPContext *mpctx, const char *file) { - char *fname = mp_get_playback_resume_config_filename(mpctx->global, file); + if (!mpctx->opts->position_resume) + return; + char *fname = mp_get_playback_resume_config_filename(mpctx, file); if (fname && mp_path_exists(fname)) { // Never apply the saved start position to following files m_config_backup_opt(mpctx->mconfig, "start"); @@ -365,8 +366,7 @@ struct playlist_entry *mp_check_playlist_resume(struct MPContext *mpctx, 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(mpctx->global, - e->filename); + char *conf = mp_get_playback_resume_config_filename(mpctx, e->filename); bool exists = conf && mp_path_exists(conf); talloc_free(conf); if (exists) -- cgit v1.2.3