summaryrefslogtreecommitdiffstats
path: root/input/input.c
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-06-25 14:03:56 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-06-25 14:03:56 +0000
commit9e365fd95b412d8c857de7b2279f16b189313988 (patch)
tree60abddffd75461f3f9625358042ffcc9f357e849 /input/input.c
parentee00cceb8bfea7bfbe8f4ee47589105f37f025e4 (diff)
downloadmpv-9e365fd95b412d8c857de7b2279f16b189313988.tar.bz2
mpv-9e365fd95b412d8c857de7b2279f16b189313988.tar.xz
Make sure mp_input_read_key_code always sleeps. Avoids 100% CPU load
during cache fill. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@18814 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'input/input.c')
-rw-r--r--input/input.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/input/input.c b/input/input.c
index eb25eb0af3..ffd599b1ce 100644
--- a/input/input.c
+++ b/input/input.c
@@ -914,11 +914,14 @@ mp_input_read_key_code(int time) {
fd_set fds;
struct timeval tv,*time_val;
#endif
- int i,n=0,max_fd = 0;
+ int i,n=0,max_fd = 0, did_sleep = 0;
static int last_loop = 0;
if(num_key_fd == 0)
+ {
+ usec_sleep(time * 1000);
return MP_INPUT_NOTHING;
+ }
#ifndef HAVE_NO_POSIX_SELECT
FD_ZERO(&fds);
@@ -940,9 +943,6 @@ mp_input_read_key_code(int time) {
n++;
}
- if(num_key_fd == 0)
- return MP_INPUT_NOTHING;
-
#ifndef HAVE_NO_POSIX_SELECT
// if we have fd's without MP_FD_NO_SELECT flag, call select():
if(n>0){
@@ -962,6 +962,7 @@ if(n>0){
}
break;
}
+ did_sleep = 1;
}
#endif
@@ -984,6 +985,7 @@ if(n>0){
code = getch2(time);
if(code < 0)
code = MP_INPUT_NOTHING;
+ did_sleep = 1;
}
else
code = ((mp_key_func_t)key_fds[i].read_func)(key_fds[i].fd);
@@ -998,6 +1000,8 @@ if(n>0){
key_fds[i].flags |= MP_FD_DEAD;
}
}
+ if (!did_sleep)
+ usec_sleep(time * 1000);
return MP_INPUT_NOTHING;
}