From 236577af09149eb59e13b5ce325809a48ac93088 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sat, 25 May 2013 15:03:30 +0200 Subject: cache: use threads instead of fork() Basically rewrite all the code supporting the cache (i.e. anything other than the ringbuffer logic). The underlying design is untouched. Note that the old cache2.c (on which this code is based) already had a threading implementation. This was mostly unused on Linux, and had some problems, such as using shared volatile variables for communication and uninterruptible timeouts, instead of using locks for synchronization. This commit does use proper locking, while still retaining the way the old cache worked. It's basically a big refactor. Simplify the code too. Since we don't need to copy stream ctrl args anymore (we're always guaranteed a shared address space now), lots of annoying code just goes away. Likewise, we don't need to care about sector sizes. The cache uses the high-level stream API to read from other streams, and sector sizes are handled transparently. --- stream/stream.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'stream/stream.h') diff --git a/stream/stream.h b/stream/stream.h index 68e22725b6..f86e64d431 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -174,7 +174,7 @@ typedef struct stream { int uncached_type; // like (uncached_stream ? uncached_stream->type : type) int flags; // MP_STREAM_SEEK_* or'ed flags int sector_size; // sector size (seek will be aligned on this size if non 0) - int read_chunk; // maximum amount of data to read at once to limit latency (0 for default) + int read_chunk; // maximum amount of data to read at once to limit latency unsigned int buf_pos, buf_len; int64_t pos, start_pos, end_pos; int eof; @@ -205,7 +205,6 @@ int stream_fill_buffer(stream_t *s); void stream_unread_buffer(stream_t *s, void *buffer, size_t buffer_size); void stream_set_capture_file(stream_t *s, const char *filename); -void stream_capture_write(stream_t *s); int stream_enable_cache_percent(stream_t **stream, int64_t stream_cache_size, float stream_cache_min_percent, @@ -330,9 +329,6 @@ void stream_set_interrupt_callback(int (*cb)(struct input_ctx *, int), /// wait for time milliseconds int stream_check_interrupt(int time); -int stream_read_unbuffered(stream_t *s, void *buf, int len); -int stream_seek_unbuffered(stream_t *s, int64_t newpos); - bool stream_manages_timeline(stream_t *s); extern int dvd_title; -- cgit v1.2.3