diff options
author | Guido Cella <guido@guidocella.xyz> | 2025-01-24 10:19:27 +0100 |
---|---|---|
committer | Dudemanguy <random342@airmail.cc> | 2025-01-27 19:32:52 +0000 |
commit | 24db17d10f0be1ccd3c03ba4d06c304bc2541561 (patch) | |
tree | e9f5e2395d60f360a0d5c635040a36fd5f762b76 /player | |
parent | 130128762bde05f1bbb5c497d6f3444b52aba9fd (diff) | |
download | mpv-24db17d10f0be1ccd3c03ba4d06c304bc2541561.tar.bz2 mpv-24db17d10f0be1ccd3c03ba4d06c304bc2541561.tar.xz |
loadfile: discard prefetched files if demuxer options changed
When using --prefetch-playlist, if demuxer options are changed in the
time window between the start of prefetching and the playback of the
next file, the old values are used. This includes setting demuxer
options in legacy extension auto profiles.
Fix this by setting a flag when demuxer options change and not using the
prefetched data when that flag is true.
UPDATE_DEMUXER is not added to demux.c's options because those already
support updates while playing.
Diffstat (limited to 'player')
-rw-r--r-- | player/command.c | 3 | ||||
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/loadfile.c | 22 |
3 files changed, 19 insertions, 7 deletions
diff --git a/player/command.c b/player/command.c index 4a3f10f7ce..6e0e1dc864 100644 --- a/player/command.c +++ b/player/command.c @@ -7741,6 +7741,9 @@ void mp_option_change_callback(void *ctx, struct m_config_option *co, int flags, mpctx->stop_play = PT_CURRENT_ENTRY; } + if (flags & UPDATE_DEMUXER) + mpctx->demuxer_changed = true; + if (opt_ptr == &opts->vo->android_surface_size) { if (mpctx->video_out) vo_control(mpctx->video_out, VOCTRL_EXTERNAL_RESIZE, NULL); diff --git a/player/core.h b/player/core.h index d1a1424e3b..560004c360 100644 --- a/player/core.h +++ b/player/core.h @@ -463,6 +463,7 @@ typedef struct MPContext { char *open_format; int open_url_flags; bool open_for_prefetch; + bool demuxer_changed; // --- All fields below are owned by open_thread, unless open_done was set // to true. struct demuxer *open_res_demuxer; diff --git a/player/loadfile.c b/player/loadfile.c index ea6fd5c558..253fdf889f 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1180,6 +1180,7 @@ static void start_open(struct MPContext *mpctx, char *url, int url_flags, mpctx->open_format = talloc_strdup(NULL, mpctx->opts->demuxer_name); mpctx->open_url_flags = url_flags; mpctx->open_for_prefetch = for_prefetch && mpctx->opts->demuxer_thread; + mpctx->demuxer_changed = false; #ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION // Don't allow to open local paths or stdin during fuzzing @@ -1210,16 +1211,23 @@ static void open_demux_reentrant(struct MPContext *mpctx) bool failed = done && !mpctx->open_res_demuxer; bool correct_url = strcmp(mpctx->open_url, url) == 0; - if (correct_url && !failed) { + if (correct_url && !mpctx->demuxer_changed && !failed) { MP_VERBOSE(mpctx, "Using prefetched/prefetching URL.\n"); - } else if (correct_url && failed) { - MP_VERBOSE(mpctx, "Prefetched URL failed, retrying.\n"); - cancel_open(mpctx); } else { - if (done) { - MP_VERBOSE(mpctx, "Dropping finished prefetch of wrong URL.\n"); + if (correct_url && failed) { + MP_VERBOSE(mpctx, "Prefetched URL failed, retrying.\n"); + } else if (mpctx->demuxer_changed) { + if (done) { + MP_VERBOSE(mpctx, "Dropping finished prefetch because demuxer options changed.\n"); + } else { + MP_VERBOSE(mpctx, "Aborting ongoing prefetch because demuxer options changed.\n"); + } } else { - MP_VERBOSE(mpctx, "Aborting ongoing prefetch of wrong URL.\n"); + if (done) { + MP_VERBOSE(mpctx, "Dropping finished prefetch of wrong URL.\n"); + } else { + MP_VERBOSE(mpctx, "Aborting ongoing prefetch of wrong URL.\n"); + } } cancel_open(mpctx); } |