mirror of
https://github.com/mpv-player/mpv
synced 2024-11-14 22:48:35 +01:00
player: avoid underrun wakeup loop
The VO underrun detection (just a weak heuristic) added in commit f26dfb flagged the underrun state every time it was checked, and since the check happened in every playloop iteration, this caused the playloop to wake up itself on every iteration. It burned an entire core while in this state. Fix this by flagging this condition only once (as it should be), and requiring that a frame is displayed to trigger it again. This makes it work similar as the audio underrun check. The bug report referenced below says --demuxer-thread=no avoided this. This is because the demuxer layer doesn't do proper underrun reporting if the reader thread is disabled. Fixes: #7259
This commit is contained in:
parent
31eb2f9f33
commit
76a92fd30b
@ -184,6 +184,7 @@ struct vo_chain {
|
||||
bool is_sparse;
|
||||
|
||||
bool underrun;
|
||||
bool underrun_signaled;
|
||||
};
|
||||
|
||||
// Like vo_chain, for audio.
|
||||
|
@ -92,6 +92,7 @@ static void vo_chain_reset_state(struct vo_chain *vo_c)
|
||||
{
|
||||
vo_seek_reset(vo_c->vo);
|
||||
vo_c->underrun = false;
|
||||
vo_c->underrun_signaled = false;
|
||||
}
|
||||
|
||||
void reset_video_state(struct MPContext *mpctx)
|
||||
@ -1013,8 +1014,12 @@ void write_video(struct MPContext *mpctx)
|
||||
|
||||
if (r == VD_WAIT) {
|
||||
// Heuristic to detect underruns.
|
||||
if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo))
|
||||
if (mpctx->video_status == STATUS_PLAYING && !vo_still_displaying(vo) &&
|
||||
!vo_c->underrun_signaled)
|
||||
{
|
||||
vo_c->underrun = true;
|
||||
vo_c->underrun_signaled = true;
|
||||
}
|
||||
// Demuxer will wake us up for more packets to decode.
|
||||
return;
|
||||
}
|
||||
@ -1217,6 +1222,8 @@ void write_video(struct MPContext *mpctx)
|
||||
mpctx->max_frames--;
|
||||
}
|
||||
|
||||
vo_c->underrun_signaled = false;
|
||||
|
||||
screenshot_flip(mpctx);
|
||||
|
||||
mp_wakeup_core(mpctx);
|
||||
|
Loading…
Reference in New Issue
Block a user