summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-23 21:53:48 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2010-05-23 21:53:48 +0000
commit2ced41082c0bc3135063c2e0ef5ac8ea2837bbc0 (patch)
tree753a1ae359ae147db985d7cdc8d12b1c33281749 /stream
parentcc7a2d3287d4bf08a3e85a4bddc41cdfaf55ace7 (diff)
downloadmpv-2ced41082c0bc3135063c2e0ef5ac8ea2837bbc0.tar.bz2
mpv-2ced41082c0bc3135063c2e0ef5ac8ea2837bbc0.tar.xz
Optimize cache behaviour for the many-consecutive-seeks case.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@31199 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'stream')
-rw-r--r--stream/cache2.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/stream/cache2.c b/stream/cache2.c
index 98268cf46b..48ebe50123 100644
--- a/stream/cache2.c
+++ b/stream/cache2.c
@@ -23,6 +23,10 @@
// TODO: seeking, data consistency checking
#define READ_USLEEP_TIME 10000
+// These defines are used to reduce the cost of many succesive
+// seeks (e.g. when a file has no index) by spinning quickly at first.
+#define INITIAL_FILL_USLEEP_TIME 1000
+#define INITIAL_FILL_USLEEP_COUNT 10
#define FILL_USLEEP_TIME 50000
#define PREFILL_SLEEP_TIME 200
#define CONTROL_SLEEP_TIME 0
@@ -432,10 +436,17 @@ static void ThreadProc( void *s ){
// cache thread mainloop:
signal(SIGTERM,exit_sighandler); // kill
signal(SIGUSR1, dummy_sighandler); // wakeup
+ {
+ int sleep_count = 0;
do {
if(!cache_fill(s)){
+ if (sleep_count < INITIAL_FILL_USLEEP_COUNT) {
+ sleep_count++;
+ usec_sleep(INITIAL_FILL_USLEEP_TIME);
+ } else
usec_sleep(FILL_USLEEP_TIME); // idle
- }
+ } else
+ sleep_count = 0;
// cache_stats(s->cache_data);
} while (cache_execute_control(s));
#if defined(__MINGW32__) || defined(__OS2__)
@@ -446,6 +457,7 @@ static void ThreadProc( void *s ){
// make sure forked code never leaves this function
exit(0);
#endif
+ }
}
int cache_stream_fill_buffer(stream_t *s){