# HG changeset patch # User reimar # Date 1274644168 0 # Node ID 3b5e8cc5e128cfcc0612f5eea5b6826442a46027 # Parent 5f59f82c599dedbbdbdf290a761373212a22dd31 Add code to wake up cache process when e.g. a seek is needed. Dramatically reduces seeking times with lavf ogg demuxer. Needs a spearate implementation for the thread-based cache implementation. diff -r 5f59f82c599d -r 3b5e8cc5e128 stream/cache2.c --- a/stream/cache2.c Sun May 23 17:05:55 2010 +0000 +++ b/stream/cache2.c Sun May 23 19:49:28 2010 +0000 @@ -90,6 +90,14 @@ int cache_fill_status=0; +static void cache_wakeup(stream_t *s) +{ +#if !defined(__MINGW32__) && !defined(PTHREAD_CACHE) && !defined(__OS2__) + // signal process to wake up immediately + kill(s->cache_pid, SIGUSR1); +#endif +} + static void cache_stats(cache_vars_t *s) { int newb=s->max_filepos-s->read_filepos; // new bytes in the buffer @@ -329,6 +337,9 @@ exit(0); } +static void dummy_sighandler(int x) { +} + /** * \return 1 on success, 0 if the function was interrupted and -1 on error */ @@ -420,6 +431,7 @@ #endif // cache thread mainloop: signal(SIGTERM,exit_sighandler); // kill + signal(SIGUSR1, dummy_sighandler); // wakeup do { if(!cache_fill(s)){ usec_sleep(FILL_USLEEP_TIME); // idle @@ -470,6 +482,7 @@ newpos=pos/s->sector_size; newpos*=s->sector_size; // align stream->pos=s->read_filepos=newpos; s->eof=0; // !!!!!!! + cache_wakeup(stream); cache_stream_fill_buffer(stream); @@ -514,6 +527,7 @@ default: return STREAM_UNSUPPORTED; } + cache_wakeup(stream); while (s->control != -1) usec_sleep(CONTROL_SLEEP_TIME); switch (cmd) {