Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loadfile: discard prefetched files if demuxer options changed #15456

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

guidocella
Copy link
Contributor

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.

Copy link

github-actions bot commented Dec 8, 2024

Download the artifacts for this pull request:

Windows
macOS

@@ -443,7 +443,8 @@ char *format_file_size(int64_t size);
#define UPDATE_VIDEO (1 << 15) // force redraw if needed
#define UPDATE_VO (1 << 16) // reinit the VO
#define UPDATE_CLIPBOARD (1 << 17) // reinit the clipboard
#define UPDATE_OPT_LAST (1 << 17)
#define UPDATE_DEMUXER (1 << 18) // invalidate prefetched files
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this invalidate prefetched files or all demuxer cache? The name is ambiguous.

} else {
if (done) {
if (correct_url && !mpctx->demuxer_changed && failed) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hard to read for me. Not sure I get it right, but I would try to reduce demuxer_changed checks,

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");
    } 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 {
        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);
}

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants