diff options
Diffstat (limited to 'stream')
-rw-r--r-- | stream/cache2.c | 8 | ||||
-rw-r--r-- | stream/http.c | 1 | ||||
-rw-r--r-- | stream/network.c | 12 | ||||
-rw-r--r-- | stream/stream.h | 3 |
4 files changed, 17 insertions, 7 deletions
diff --git a/stream/cache2.c b/stream/cache2.c index 77c74d3b19..9161027ee3 100644 --- a/stream/cache2.c +++ b/stream/cache2.c @@ -434,6 +434,14 @@ static void cache_mainloop(cache_vars_t *s) { } while (cache_execute_control(s)); } +int stream_enable_cache_percent(stream_t *stream, int64_t stream_cache_size, + float stream_cache_min_percent, float stream_cache_seek_min_percent) +{ + return stream_enable_cache(stream, stream_cache_size * 1024, + stream_cache_size * 1024 * (stream_cache_min_percent / 100.0), + stream_cache_size * 1024 * (stream_cache_seek_min_percent / 100.0)); +} + /** * \return 1 on success, 0 if the function was interrupted and -1 on error */ diff --git a/stream/http.c b/stream/http.c index cd68029025..8d930c6460 100644 --- a/stream/http.c +++ b/stream/http.c @@ -45,7 +45,6 @@ #include <libavutil/avutil.h> -extern int stream_cache_size; extern int network_bandwidth; typedef struct { diff --git a/stream/network.c b/stream/network.c index 87b295e7e6..7d45ca71d9 100644 --- a/stream/network.c +++ b/stream/network.c @@ -29,6 +29,7 @@ #include <ctype.h> #include "config.h" +#include "options.h" #include "mp_msg.h" @@ -47,8 +48,6 @@ #include "cookies.h" #include "url.h" -extern int stream_cache_size; - /* Variables for the command line option -user, -passwd, -bandwidth, -user-agent and -nocookies */ @@ -461,13 +460,14 @@ nop_streaming_seek( int fd, off_t pos, streaming_ctrl_t *stream_ctrl ) { void fixup_network_stream_cache(stream_t *stream) { + struct MPOpts *opts = stream->opts; if(stream->streaming_ctrl->buffering) { - if(stream_cache_size<0) { + if(opts->stream_cache_size<0) { // cache option not set, will use our computed value. // buffer in KBytes, *5 because the prefill is 20% of the buffer. - stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5; - if( stream_cache_size<64 ) stream_cache_size = 64; // 16KBytes min buffer + opts->stream_cache_size = (stream->streaming_ctrl->prebuffer_size/1024)*5; + if( opts->stream_cache_size<64 ) opts->stream_cache_size = 64; // 16KBytes min buffer } - mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", stream_cache_size); + mp_tmsg(MSGT_NETWORK,MSGL_INFO,"Cache size set to %d KBytes\n", opts->stream_cache_size); } } diff --git a/stream/stream.h b/stream/stream.h index eeb2f769bd..0cee8498eb 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -184,6 +184,8 @@ int stream_fill_buffer(stream_t *s); int stream_seek_long(stream_t *s, off_t pos); #ifdef CONFIG_STREAM_CACHE +int stream_enable_cache_percent(stream_t *stream, int64_t stream_cache_size, + float stream_cache_min_percent, float stream_cache_seek_min_percent); int stream_enable_cache(stream_t *stream,int64_t size,int64_t min,int64_t prefill); int cache_stream_fill_buffer(stream_t *s); int cache_stream_seek_long(stream_t *s,int64_t pos); @@ -192,6 +194,7 @@ int cache_stream_seek_long(stream_t *s,int64_t pos); #define cache_stream_fill_buffer(x) stream_fill_buffer(x) #define cache_stream_seek_long(x,y) stream_seek_long(x,y) #define stream_enable_cache(x,y,z,w) 1 +#define stream_enable_cache_percent(x,y,z,w) 1 #endif int stream_write_buffer(stream_t *s, unsigned char *buf, int len); |