From b93ed278362185ff980e0ce8f4ab3029f8fe395f Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Fri, 6 Apr 2012 14:24:26 +0300 Subject: input: stop trying to read terminal input on EOF Stop trying to read terminal input if a read attempt returns EOF. The most important case where this matters is when someone runs the player with stdin redirected from /dev/null and without specifying --no-consolecontrols. This used to cause 100% CPU load while paused, as select() would continuously trigger on stdin (the need for --no-consolecontrols was not apparent to people with older mplayer versions, as input reading was less efficient and latencies like hardcoded sleeps kept CPU use well below 100%). Now this will only cause a "Dead key input" error message. --- mplayer.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'mplayer.c') diff --git a/mplayer.c b/mplayer.c index edeffef9e4..26555e3c20 100644 --- a/mplayer.c +++ b/mplayer.c @@ -3798,8 +3798,9 @@ static void run_playloop(struct MPContext *mpctx) static int read_keys(void *ctx, int fd) { - getch2(ctx); - return MP_INPUT_NOTHING; + if (getch2(ctx)) + return MP_INPUT_NOTHING; + return MP_INPUT_DEAD; } static bool attachment_is_font(struct demux_attachment *att) -- cgit v1.2.3