From a75e933dac4c6ebfd15c7c7cc0442fb21318df2a Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 22 Sep 2015 11:19:39 +0200 Subject: player: fix excessive CPU usage in audio-only mode Caused by one of the --force-window commits. The unconditional uninit_video_out() call (which normally should be idempotent) raised sporadic MPV_EVENT_VIDEO_RECONFIG events. This is ok, except for the fact that clients (like a Lua script or libmpv users) would cause the event loop to run again after receiving it, triggering a feedback loop. Fix it by sending the events really only on a change. --- player/video.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index de7e601645..97b88de5d2 100644 --- a/player/video.c +++ b/player/video.c @@ -220,10 +220,11 @@ void reset_video_state(struct MPContext *mpctx) void uninit_video_out(struct MPContext *mpctx) { uninit_video_chain(mpctx); - if (mpctx->video_out) + if (mpctx->video_out) { vo_destroy(mpctx->video_out); + mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); + } mpctx->video_out = NULL; - mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); } void uninit_video_chain(struct MPContext *mpctx) @@ -236,8 +237,8 @@ void uninit_video_chain(struct MPContext *mpctx) mpctx->sync_audio_to_video = false; reselect_demux_streams(mpctx); remove_deint_filter(mpctx); + mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); } - mp_notify(mpctx, MPV_EVENT_VIDEO_RECONFIG, NULL); } int reinit_video_chain(struct MPContext *mpctx) -- cgit v1.2.3