diff options
author | Guido Cella <guido@guidocella.xyz> | 2023-09-19 21:16:23 +0200 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2023-09-21 14:57:11 +0000 |
commit | 6b09525157cc1c71874bda6256da96cfb830038f (patch) | |
tree | b556f86f47ea4595498b56304690ff7b4f523520 /demux/demux_playlist.c | |
parent | 27f0a35c535d66f4216fc1a4f1d15d10990fb8a0 (diff) | |
download | mpv-6b09525157cc1c71874bda6256da96cfb830038f.tar.bz2 mpv-6b09525157cc1c71874bda6256da96cfb830038f.tar.xz |
demux_playlist: add --directory-mode=auto
This is a more useful default with --shuffle.
Diffstat (limited to 'demux/demux_playlist.c')
-rw-r--r-- | demux/demux_playlist.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/demux/demux_playlist.c b/demux/demux_playlist.c index 8e84129e2c..e41cc35dad 100644 --- a/demux/demux_playlist.c +++ b/demux/demux_playlist.c @@ -37,6 +37,7 @@ #define PROBE_SIZE (8 * 1024) enum dir_mode { + DIR_AUTO, DIR_LAZY, DIR_RECURSIVE, DIR_IGNORE, @@ -50,6 +51,7 @@ struct demux_playlist_opts { struct m_sub_options demux_playlist_conf = { .opts = (const struct m_option[]) { {"directory-mode", OPT_CHOICE(dir_mode, + {"auto", DIR_AUTO}, {"lazy", DIR_LAZY}, {"recursive", DIR_RECURSIVE}, {"ignore", DIR_IGNORE})}, @@ -57,7 +59,7 @@ struct m_sub_options demux_playlist_conf = { }, .size = sizeof(struct demux_playlist_opts), .defaults = &(const struct demux_playlist_opts){ - .dir_mode = DIR_LAZY, + .dir_mode = DIR_AUTO, }, }; @@ -73,6 +75,7 @@ static bool check_mimetype(struct stream *s, const char *const *list) } struct pl_parser { + struct mpv_global *global; struct mp_log *log; struct stream *s; char buffer[2 * 1024 * 1024]; @@ -434,6 +437,12 @@ static int parse_dir(struct pl_parser *p) struct stat dir_stack[MAX_DIR_STACK]; + if (p->opts->dir_mode == DIR_AUTO) { + struct MPOpts *opts = mp_get_config_group(NULL, p->global, &mp_opt_root); + p->opts->dir_mode = opts->shuffle ? DIR_RECURSIVE : DIR_LAZY; + talloc_free(opts); + } + scan_dir(p, path, dir_stack, 0); p->add_base = false; @@ -486,6 +495,7 @@ static int open_file(struct demuxer *demuxer, enum demux_check check) bool force = check < DEMUX_CHECK_UNSAFE || check == DEMUX_CHECK_REQUEST; struct pl_parser *p = talloc_zero(NULL, struct pl_parser); + p->global = demuxer->global; p->log = demuxer->log; p->pl = talloc_zero(p, struct playlist); p->real_stream = demuxer->stream; |