diff --git a/audio/out/ao_pcm.c b/audio/out/ao_pcm.c index ce55e70f03..cf13c478ac 100644 --- a/audio/out/ao_pcm.c +++ b/audio/out/ao_pcm.c @@ -28,7 +28,6 @@ #include "mpv_talloc.h" #include "options/m_option.h" -#include "options/path.h" #include "audio/format.h" #include "ao.h" #include "internal.h" @@ -110,7 +109,7 @@ static int init(struct ao *ao) { struct priv *priv = ao->priv; - char *outputfilename = mp_get_user_path(priv, ao->global, priv->outputfilename); + char *outputfilename = priv->outputfilename; if (!outputfilename) { outputfilename = talloc_strdup(priv, priv->waveheader ? "audiodump.wav" : "audiodump.pcm"); diff --git a/common/encode_lavc.c b/common/encode_lavc.c index 4772759ee3..11fc46627f 100644 --- a/common/encode_lavc.c +++ b/common/encode_lavc.c @@ -31,7 +31,6 @@ #include "options/m_config.h" #include "options/m_option.h" #include "options/options.h" -#include "options/path.h" #include "osdep/timer.h" #include "video/out/vo.h" #include "mpv_talloc.h" @@ -134,9 +133,7 @@ struct encode_lavc_context *encode_lavc_init(struct mpv_global *global) p->muxer->oformat = ctx->oformat; - char *path = mp_get_user_path(NULL, global, filename); - p->muxer->url = av_strdup(path); - talloc_free(path); + p->muxer->url = av_strdup(filename); MP_HANDLE_OOM(p->muxer->url); return ctx; diff --git a/common/playlist.c b/common/playlist.c index 6d03c030c2..eec7e665b9 100644 --- a/common/playlist.c +++ b/common/playlist.c @@ -404,12 +404,11 @@ struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel, struct mp_log *log = mp_log_new(NULL, global->log, "!playlist_parser"); mp_verbose(log, "Parsing playlist file %s...\n", file); - char *path = mp_get_user_path(NULL, global, file); struct demuxer_params p = { .force_format = "playlist", .stream_flags = STREAM_ORIGIN_DIRECT, }; - struct demuxer *d = demux_open_url(path, &p, cancel, global); + struct demuxer *d = demux_open_url(file, &p, cancel, global); struct playlist *ret = NULL; if (!d) goto done; @@ -436,7 +435,6 @@ struct playlist *playlist_parse_file(const char *file, struct mp_cancel *cancel, done: talloc_free(log); - talloc_free(path); return ret; } diff --git a/options/path.c b/options/path.c index 8be6303b3b..a199c89a9a 100644 --- a/options/path.c +++ b/options/path.c @@ -115,7 +115,7 @@ void mp_init_paths(struct mpv_global *global, struct MPOpts *opts) if (!opts->load_config) force_configdir = ""; - global->configdir = mp_get_user_path(global, global, force_configdir); + global->configdir = talloc_strdup(global, force_configdir); } char *mp_find_user_file(void *talloc_ctx, struct mpv_global *global, diff --git a/player/loadfile.c b/player/loadfile.c index f9b653185b..748b3f5731 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -857,11 +857,8 @@ int mp_add_external_file(struct MPContext *mpctx, char *filename, mp_core_unlock(mpctx); - char *path = mp_get_user_path(NULL, mpctx->global, filename); struct demuxer *demuxer = - demux_open_url(path, ¶ms, cancel, mpctx->global); - talloc_free(path); - + demux_open_url(filename, ¶ms, cancel, mpctx->global); if (demuxer) enable_demux_thread(mpctx, demuxer); @@ -1079,7 +1076,7 @@ static void load_chapters(struct MPContext *mpctx) bool free_src = false; char *chapter_file = mpctx->opts->chapter_file; if (chapter_file && chapter_file[0]) { - chapter_file = mp_get_user_path(NULL, mpctx->global, chapter_file); + chapter_file = talloc_strdup(NULL, chapter_file); mp_core_unlock(mpctx); struct demuxer_params p = { .stream_flags = STREAM_ORIGIN_DIRECT, diff --git a/player/misc.c b/player/misc.c index 09054b22f0..1c9efdf2dc 100644 --- a/player/misc.c +++ b/player/misc.c @@ -31,7 +31,6 @@ #include "options/options.h" #include "options/m_property.h" #include "options/m_config.h" -#include "options/path.h" #include "common/common.h" #include "common/encode.h" #include "common/playlist.h" @@ -270,7 +269,6 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename) struct MPOpts *opts = mpctx->opts; bool ok = false; - char *filename = mp_get_user_path(NULL, mpctx->global, opts->stream_dump); stream_t *stream = stream_create(source_filename, STREAM_ORIGIN_DIRECT | STREAM_READ, mpctx->playback_abort, mpctx->global); @@ -279,7 +277,7 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename) int64_t size = stream_get_size(stream); - FILE *dest = fopen(filename, "wb"); + FILE *dest = fopen(opts->stream_dump, "wb"); if (!dest) { MP_ERR(mpctx, "Error opening dump file: %s\n", mp_strerror(errno)); goto done; @@ -307,7 +305,6 @@ int stream_dump(struct MPContext *mpctx, const char *source_filename) ok &= fclose(dest) == 0; done: free_stream(stream); - talloc_free(filename); return ok ? 0 : -1; } diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 965be2943f..83b206a286 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -431,9 +431,7 @@ static int bluray_stream_open_internal(stream_t *s) bd_set_debug_mask(0); /* open device */ - char *device_tmp = mp_get_user_path(NULL, s->global, device); - BLURAY *bd = bd_open(device_tmp, NULL); - talloc_free(device_tmp); + BLURAY *bd = bd_open(device, NULL); if (!bd) { MP_ERR(s, "Couldn't open Blu-ray device: %s\n", device); ret = STREAM_UNSUPPORTED; diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index e5dfef5131..22a3f720b1 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -38,7 +38,6 @@ #include "options/m_option.h" #include "options/m_config.h" #include "options/options.h" -#include "options/path.h" #if !HAVE_GPL #error GPL only @@ -254,11 +253,11 @@ static int open_cdda(stream_t *st) int last_track; if (st->path[0]) { - p->device = talloc_strdup(priv, st->path); + p->device = st->path; } else if (p->cdda_device && p->cdda_device[0]) { - p->device = mp_get_user_path(priv, st->global, p->cdda_device); + p->device = p->cdda_device; } else { - p->device = talloc_strdup(priv, DEFAULT_OPTICAL_DEVICE); + p->device = DEFAULT_OPTICAL_DEVICE; } #if defined(__NetBSD__) diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index f9c33aaf87..0bbcf5e3ae 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -1118,11 +1118,12 @@ dvb_state_t *dvb_get_state(stream_t *stream) continue; } - void *talloc_ctx = talloc_new(NULL); + void *talloc_ctx = NULL; char *conf_file; if (priv->opts->cfg_file && priv->opts->cfg_file[0]) { - conf_file = mp_get_user_path(talloc_ctx, global, priv->opts->cfg_file); + conf_file = priv->opts->cfg_file; } else { + talloc_ctx = talloc_new(NULL); conf_file = mp_find_config_file(talloc_ctx, global, conf_file_name); if (conf_file) { mp_verbose(log, "Ignoring other channels.conf files.\n"); diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 88195b5e5f..accaf9b302 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -552,7 +552,7 @@ static struct priv *new_dvdnav_stream(stream_t *stream, char *filename) if (!filename) return NULL; - if (!(priv->filename = mp_get_user_path(priv, stream->global, filename))) + if (!(priv->filename = talloc_strdup(priv, filename))) return NULL; priv->dvd_speed = priv->opts->speed; diff --git a/sub/sd_ass.c b/sub/sd_ass.c index 15d4db7d0b..d56facdbde 100644 --- a/sub/sd_ass.c +++ b/sub/sd_ass.c @@ -29,7 +29,6 @@ #include "config.h" #include "options/m_config.h" #include "options/options.h" -#include "options/path.h" #include "common/common.h" #include "common/msg.h" #include "demux/demux.h" @@ -109,14 +108,11 @@ static const struct sd_filter_functions *const filters[] = { // Add default styles, if the track does not have any styles yet. // Apply style overrides if the user provides any. -static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp_subtitle_opts *opts, - struct mp_subtitle_shared_opts *shared_opts) +static void mp_ass_add_default_styles(ASS_Track *track, struct mp_subtitle_opts *opts, + struct mp_subtitle_shared_opts *shared_opts, int order) { - if (opts->ass_styles_file && shared_opts->ass_style_override[sd->order]) { - char *file = mp_get_user_path(NULL, sd->global, opts->ass_styles_file); - ass_read_styles(track, file, NULL); - talloc_free(file); - } + if (opts->ass_styles_file && shared_opts->ass_style_override[order]) + ass_read_styles(track, opts->ass_styles_file, NULL); if (track->n_styles == 0) { if (!track->PlayResY) { @@ -131,7 +127,7 @@ static void mp_ass_add_default_styles(struct sd *sd, ASS_Track *track, struct mp mp_ass_set_style(style, track->PlayResY, opts->sub_style); } - if (shared_opts->ass_style_override[sd->order]) + if (shared_opts->ass_style_override[order]) ass_process_force_style(track); } @@ -260,7 +256,7 @@ static void assobjects_init(struct sd *sd) ctx->shadow_track = ass_new_track(ctx->ass_library); ctx->shadow_track->PlayResX = MP_ASS_FONT_PLAYRESX; ctx->shadow_track->PlayResY = MP_ASS_FONT_PLAYRESY; - mp_ass_add_default_styles(sd, ctx->shadow_track, opts, shared_opts); + mp_ass_add_default_styles(ctx->shadow_track, opts, shared_opts, sd->order); char *extradata = sd->codec->extradata; int extradata_size = sd->codec->extradata_size; @@ -271,7 +267,7 @@ static void assobjects_init(struct sd *sd) if (extradata) ass_process_codec_private(ctx->ass_track, extradata, extradata_size); - mp_ass_add_default_styles(sd, ctx->ass_track, opts, shared_opts); + mp_ass_add_default_styles(ctx->ass_track, opts, shared_opts, sd->order); #if LIBASS_VERSION >= 0x01302000 ass_set_check_readorder(ctx->ass_track, sd->opts->sub_clear_on_seek ? 0 : 1); diff --git a/video/out/drm_common.c b/video/out/drm_common.c index ffc5ebfbad..6dff794613 100644 --- a/video/out/drm_common.c +++ b/video/out/drm_common.c @@ -44,7 +44,6 @@ #include "common/msg.h" #include "misc/ctype.h" #include "options/m_config.h" -#include "options/path.h" #include "osdep/io.h" #include "osdep/poll_wrapper.h" #include "osdep/timer.h" @@ -944,7 +943,7 @@ static bool card_has_connection(const char *path) static void get_primary_device_path(struct vo_drm_state *drm) { if (drm->opts->device_path) { - drm->card_path = mp_get_user_path(drm, drm->vo->global, drm->opts->device_path); + drm->card_path = talloc_strdup(drm, drm->opts->device_path); return; } diff --git a/video/out/vo_image.c b/video/out/vo_image.c index f1fbb26c24..29bd775113 100644 --- a/video/out/vo_image.c +++ b/video/out/vo_image.c @@ -66,16 +66,13 @@ struct priv { struct vo_image_opts *opts; struct mp_image *current; - char *dir; int frame; }; static bool checked_mkdir(struct vo *vo, const char *buf) { - struct priv *p = vo->priv; - p->dir = mp_get_user_path(vo, vo->global, buf); - MP_INFO(vo, "Creating output directory '%s'...\n", p->dir); - if (mkdir(p->dir, 0755) < 0) { + MP_INFO(vo, "Creating output directory '%s'...\n", buf); + if (mkdir(buf, 0755) < 0) { char *errstr = mp_strerror(errno); if (errno == EEXIST) { struct stat stat_p; @@ -120,8 +117,8 @@ static void flip_page(struct vo *vo) char *filename = talloc_asprintf(t, "%08d.%s", p->frame, image_writer_file_ext(p->opts->opts)); - if (p->dir && strlen(p->dir)) - filename = mp_path_join(t, p->dir, filename); + if (p->opts->outdir && strlen(p->opts->outdir)) + filename = mp_path_join(t, p->opts->outdir, filename); MP_INFO(vo, "Saving %s\n", filename); write_image(p->current, p->opts->opts, filename, vo->global, vo->log, true);