From 2d58234c86e59298de52fec12d1eb59086d68763 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 17 Nov 2012 19:12:13 +0200 Subject: cache: refactor how cache enabling is done Code enabling the cache by default for network streams did that by modifying the value of the "cache" option. This wasn't sane, as multiple streams may be created and all share the same options. Change the code to not modify options but store data in the stream instance instead. Conflicts: core/mplayer.c demux/demux.c stream/cache2.c stream/network.c stream/network.h stream/pnm.c stream/stream.c stream/stream_rtp.c Merged from mplayer2 commit e26070. Note that this doesn't solve any actual bug, as the playlist crashing bug has been fixed before. Since the global cache size option value is not overwritten anymore, the option doesn't need to be restored on end of playback (M_OPT_LOCAL). --- stream/cache2.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'stream/cache2.c') diff --git a/stream/cache2.c b/stream/cache2.c index d547f9e5ea..27147d00fb 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -452,7 +452,14 @@ int stream_enable_cache_percent(stream_t *stream, int64_t stream_cache_size, /** * \return 1 on success, 0 if the function was interrupted and -1 on error */ -int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_limit){ +int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_limit) +{ + if (size < 0) + size = stream->cache_size * 1024; + if (!size) + return 1; + mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %"PRId64" KiB\n", size / 1024); + int ss = stream->sector_size ? stream->sector_size : STREAM_BUFFER_SIZE; int res = -1; cache_vars_t* s; @@ -521,6 +528,7 @@ int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t seek_l } } mp_msg(MSGT_CACHE,MSGL_STATUS,"\n"); + stream->cached = true; return 1; // parent exits err_out: -- cgit v1.2.3