mirror of
https://github.com/mpv-player/mpv
synced 2024-12-22 14:52:43 +00:00
libarchive: some shitty hack to make opening slightly faster
See manpage additions. The libarchive behavior mentioned in the last paragraph there is technically unrelated, but makes this new option mostly pointless. See: #7182
This commit is contained in:
parent
4231ce6f5f
commit
1b283f6b60
@ -3458,6 +3458,18 @@ Demuxer
|
||||
after the initial caching. This option is useless if the file cannot be
|
||||
cached completely.
|
||||
|
||||
``--rar-list-all-volumes=<yes|no>``
|
||||
When opening multi-volume rar files, open all volumes to create a full list
|
||||
of contained files (default: no). If disabled, only the archive entries
|
||||
whose headers are located within the first volume are listed (and thus
|
||||
played when opening a .rar file with mpv). Doing so speeds up opening, and
|
||||
the typical idiotic use-case of playing uncompressed multi-volume rar files
|
||||
that contain a single media file is made faster.
|
||||
|
||||
Opening is still slow, because for unknown, idiotic, and unnecessary reasons
|
||||
libarchive opens all volumes anyway when playing the main file, even though
|
||||
mpv iterated no archive entries yet.
|
||||
|
||||
Input
|
||||
-----
|
||||
|
||||
|
@ -20,12 +20,17 @@
|
||||
|
||||
#include "common/common.h"
|
||||
#include "common/playlist.h"
|
||||
#include "options/m_config.h"
|
||||
#include "stream/stream.h"
|
||||
#include "misc/natural_sort.h"
|
||||
#include "demux.h"
|
||||
|
||||
#include "stream/stream_libarchive.h"
|
||||
|
||||
struct demux_libarchive_opts {
|
||||
int rar_list_all_volumes;
|
||||
};
|
||||
|
||||
static int cmp_filename(const void *a, const void *b)
|
||||
{
|
||||
return mp_natural_sort_cmp(*(char **)a, *(char **)b);
|
||||
@ -57,6 +62,12 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
if (!ok)
|
||||
return -1;
|
||||
|
||||
struct demux_libarchive_opts *opts =
|
||||
mp_get_config_group(demuxer, demuxer->global, demuxer->desc->options);
|
||||
|
||||
if (!opts->rar_list_all_volumes)
|
||||
flags |= MP_ARCHIVE_FLAG_NO_RAR_VOLUMES;
|
||||
|
||||
mpa = mp_archive_new(demuxer->log, demuxer->stream, flags, 0);
|
||||
if (!mpa)
|
||||
return -1;
|
||||
@ -93,8 +104,17 @@ static int open_file(struct demuxer *demuxer, enum demux_check check)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define OPT_BASE_STRUCT struct demux_libarchive_opts
|
||||
|
||||
const struct demuxer_desc demuxer_desc_libarchive = {
|
||||
.name = "libarchive",
|
||||
.desc = "libarchive wrapper",
|
||||
.open = open_file,
|
||||
.options = &(const struct m_sub_options){
|
||||
.opts = (const struct m_option[]) {
|
||||
OPT_FLAG("rar-list-all-volumes", rar_list_all_volumes, 0),
|
||||
{0}
|
||||
},
|
||||
.size = sizeof(OPT_BASE_STRUCT),
|
||||
},
|
||||
};
|
||||
|
@ -264,9 +264,11 @@ struct mp_archive *mp_archive_new(struct mp_log *log, struct stream *src,
|
||||
if (!add_volume(mpa, src, src->url, 0))
|
||||
goto err;
|
||||
|
||||
// try to open other volumes
|
||||
if (!find_volumes(mpa))
|
||||
goto err;
|
||||
if (!(flags & MP_ARCHIVE_FLAG_NO_RAR_VOLUMES)) {
|
||||
// try to open other volumes
|
||||
if (!find_volumes(mpa))
|
||||
goto err;
|
||||
}
|
||||
|
||||
locale_t oldlocale = uselocale(mpa->locale);
|
||||
|
||||
|
@ -24,7 +24,8 @@ struct mp_archive {
|
||||
|
||||
void mp_archive_free(struct mp_archive *mpa);
|
||||
|
||||
#define MP_ARCHIVE_FLAG_UNSAFE 1
|
||||
#define MP_ARCHIVE_FLAG_UNSAFE (1 << 0)
|
||||
#define MP_ARCHIVE_FLAG_NO_RAR_VOLUMES (1 << 1)
|
||||
struct mp_archive *mp_archive_new(struct mp_log *log, struct stream *src,
|
||||
int flags, int max_volumes);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user