[MPlayer-dev-eng] Problem with mplayer - -cache
Jim Hawkins
mplayer at jawkins.com
Sun Apr 3 17:04:26 CEST 2005
Hi,
I'm experiencing high CPU usage during cache prefilling when piping data
to mplayer via stdin. This seems to be caused by libmpdemux/cache2.c's use
of mp_input_check_interrupt() to sleep during the prefill stage. When
taking data from stdin, mp_input_check_interrupt() does not have any fds
to check for input and so returns without calling select(), which makes
the CPU spin rather than sleep.
The following should highlight the difference in exhibited behaviour:
wget 'http://movies.apple.com/movies/miramax/sin_city/sin_city_m480.mov' \
--quiet -O - | mplayer - -cache 999999
mplayer 'http://movies.apple.com/movies/miramax/sin_city/sin_city_m480.mov' \
-cache 999999
I've fixed this by making cache2.c always use usec_sleep() (patch
attached) but I'm not sure if that's the best way to do it. Perhaps
input.c should be changed instead.
Jim
-------------- next part --------------
Index: libmpdemux/cache2.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/cache2.c,v
retrieving revision 1.26
diff -u -r1.26 cache2.c
--- libmpdemux/cache2.c 26 Jul 2004 22:06:30 -0000 1.26
+++ libmpdemux/cache2.c 3 Apr 2005 14:40:37 -0000
@@ -8,7 +8,7 @@
#define READ_USLEEP_TIME 10000
#define FILL_USLEEP_TIME 50000
-#define PREFILL_SLEEP_TIME 200
+#define PREFILL_USLEEP_TIME 200000
#include <stdio.h>
#include <stdlib.h>
@@ -295,8 +295,9 @@
s->max_filepos-s->read_filepos
);
if(s->eof) break; // file is smaller than prefill size
- if(mp_input_check_interrupt(PREFILL_SLEEP_TIME))
+ if(mp_input_check_interrupt(0))
return 0;
+ usec_sleep(PREFILL_USLEEP_TIME);
}
return 1; // parent exits
}
More information about the MPlayer-dev-eng
mailing list