mirror of https://github.com/mpv-player/mpv
player: fix basic playback
The "buffering" logic was active even if the stream cache was disabled. This is contrary to what the manpage says. It also breaks playback because of another bug: the demuxer cache is smaller than 2 seconds, and thus the resume condition never becomes true. Explicitly run this code only if the stream cache is enabled. Also, fix the underlying problem of the breakage, and resume when the demuxer thread stops reading in any case, not just on EOF. Broken by previous commit. Unbreaks playback of local files.
This commit is contained in:
parent
0b428e4482
commit
dad90f616d
|
@ -1185,7 +1185,7 @@ static int cached_demux_control(struct demux_internal *in, int cmd, void *arg)
|
||||||
r->ts_range[1] = MP_PTS_MIN(r->ts_range[1], ds->last_ts);
|
r->ts_range[1] = MP_PTS_MIN(r->ts_range[1], ds->last_ts);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
r->idle &= !r->underrun;
|
r->idle = (r->idle && !r->underrun) || r->eof;
|
||||||
return DEMUXER_CTRL_OK;
|
return DEMUXER_CTRL_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -525,22 +525,25 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
|
||||||
{.idle = true, .ts_range = {MP_NOPTS_VALUE, MP_NOPTS_VALUE}};
|
{.idle = true, .ts_range = {MP_NOPTS_VALUE, MP_NOPTS_VALUE}};
|
||||||
demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
|
demux_control(mpctx->demuxer, DEMUXER_CTRL_GET_READER_STATE, &s);
|
||||||
|
|
||||||
|
int idle = -1;
|
||||||
|
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
|
||||||
|
|
||||||
double range = -1;
|
double range = -1;
|
||||||
if (s.ts_range[0] != MP_NOPTS_VALUE && s.ts_range[1] != MP_NOPTS_VALUE)
|
if (s.ts_range[0] != MP_NOPTS_VALUE && s.ts_range[1] != MP_NOPTS_VALUE)
|
||||||
range = s.ts_range[1] - s.ts_range[0];
|
range = s.ts_range[1] - s.ts_range[0];
|
||||||
if (range < 0)
|
if (range < 0)
|
||||||
range = 1e20; // unknown/broken timestamps; disable
|
range = 1e20; // unknown/broken timestamps; disable
|
||||||
|
|
||||||
if (mpctx->restart_complete) {
|
if (mpctx->restart_complete && idle != -1) {
|
||||||
if (mpctx->paused && mpctx->paused_for_cache) {
|
if (mpctx->paused && mpctx->paused_for_cache) {
|
||||||
if (!opts->cache_pausing || range >= 2.0 || s.eof) {
|
if (!opts->cache_pausing || range >= 2.0 || s.idle) {
|
||||||
mpctx->paused_for_cache = false;
|
mpctx->paused_for_cache = false;
|
||||||
if (!opts->pause)
|
if (!opts->pause)
|
||||||
unpause_player(mpctx);
|
unpause_player(mpctx);
|
||||||
}
|
}
|
||||||
mpctx->sleeptime = MPMIN(mpctx->sleeptime, 0.2);
|
mpctx->sleeptime = MPMIN(mpctx->sleeptime, 0.2);
|
||||||
} else {
|
} else {
|
||||||
if (opts->cache_pausing && range < 0.5 && !s.eof) {
|
if (opts->cache_pausing && range < 0.5 && !s.idle) {
|
||||||
bool prev_paused_user = opts->pause;
|
bool prev_paused_user = opts->pause;
|
||||||
pause_player(mpctx);
|
pause_player(mpctx);
|
||||||
mpctx->paused_for_cache = true;
|
mpctx->paused_for_cache = true;
|
||||||
|
@ -549,9 +552,6 @@ static void handle_pause_on_low_cache(struct MPContext *mpctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int idle = 1;
|
|
||||||
demux_stream_control(mpctx->demuxer, STREAM_CTRL_GET_CACHE_IDLE, &idle);
|
|
||||||
|
|
||||||
// Also update cache properties.
|
// Also update cache properties.
|
||||||
bool busy = idle == 0 || !s.idle;
|
bool busy = idle == 0 || !s.idle;
|
||||||
if (busy || mpctx->next_cache_update > 0) {
|
if (busy || mpctx->next_cache_update > 0) {
|
||||||
|
|
Loading…
Reference in New Issue