mirror of
https://github.com/mpv-player/mpv
synced 2024-12-27 17:42:17 +00:00
player: add --demuxer-cache-wait option
This commit is contained in:
parent
d7c7f80cc1
commit
556e204a11
@ -2995,6 +2995,14 @@ Demuxer
|
||||
requests), seeking will be disabled. This option can forcibly enable it.
|
||||
For seeks within the cache, there's a good chance of success.
|
||||
|
||||
``--demuxer-cache-wait=<yes|no>``
|
||||
Before starting playback, read data until either the end of the file was
|
||||
reached, or the demuxer cache has reached maximum capacity. Only once this
|
||||
is done, playback starts. This intentionally happens before the initial
|
||||
seek triggered with ``--start``. This does not change any runtime behavior
|
||||
after the initial caching. This option is useless if the file cannot be
|
||||
cached completely.
|
||||
|
||||
Input
|
||||
-----
|
||||
|
||||
|
@ -1100,6 +1100,17 @@ void demux_set_wakeup_cb(struct demuxer *demuxer, void (*cb)(void *ctx), void *c
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
}
|
||||
|
||||
void demux_start_prefetch(struct demuxer *demuxer)
|
||||
{
|
||||
struct demux_internal *in = demuxer->in;
|
||||
assert(demuxer == in->d_user);
|
||||
|
||||
pthread_mutex_lock(&in->lock);
|
||||
in->reading = true;
|
||||
pthread_cond_signal(&in->wakeup);
|
||||
pthread_mutex_unlock(&in->lock);
|
||||
}
|
||||
|
||||
const char *stream_type_name(enum stream_type type)
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -260,6 +260,7 @@ struct demuxer *demux_open_url(const char *url,
|
||||
void demux_start_thread(struct demuxer *demuxer);
|
||||
void demux_stop_thread(struct demuxer *demuxer);
|
||||
void demux_set_wakeup_cb(struct demuxer *demuxer, void (*cb)(void *ctx), void *ctx);
|
||||
void demux_start_prefetch(struct demuxer *demuxer);
|
||||
|
||||
bool demux_cancel_test(struct demuxer *demuxer);
|
||||
|
||||
|
@ -460,6 +460,7 @@ const m_option_t mp_opts[] = {
|
||||
OPT_STRING("sub-demuxer", sub_demuxer_name, 0),
|
||||
OPT_FLAG("demuxer-thread", demuxer_thread, 0),
|
||||
OPT_DOUBLE("demuxer-termination-timeout", demux_termination_timeout, 0),
|
||||
OPT_FLAG("demuxer-cache-wait", demuxer_cache_wait, 0),
|
||||
OPT_FLAG("prefetch-playlist", prefetch_open, 0),
|
||||
OPT_FLAG("cache-pause", cache_pause, 0),
|
||||
OPT_FLAG("cache-pause-initial", cache_pause_initial, 0),
|
||||
|
@ -248,6 +248,7 @@ typedef struct MPOpts {
|
||||
char *demuxer_name;
|
||||
int demuxer_thread;
|
||||
double demux_termination_timeout;
|
||||
int demuxer_cache_wait;
|
||||
int prefetch_open;
|
||||
char *audio_demuxer_name;
|
||||
char *sub_demuxer_name;
|
||||
|
@ -1534,6 +1534,19 @@ static void play_current_file(struct MPContext *mpctx)
|
||||
goto terminate_playback;
|
||||
}
|
||||
|
||||
demux_start_prefetch(mpctx->demuxer);
|
||||
|
||||
if (opts->demuxer_cache_wait) {
|
||||
while (!mpctx->stop_play) {
|
||||
struct demux_reader_state s;
|
||||
demux_get_reader_state(mpctx->demuxer, &s);
|
||||
if (s.idle)
|
||||
break;
|
||||
|
||||
mp_idle(mpctx);
|
||||
}
|
||||
}
|
||||
|
||||
double play_start_pts = get_play_start_pts(mpctx);
|
||||
if (play_start_pts != MP_NOPTS_VALUE) {
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user