mirror of https://github.com/mpv-player/mpv
cache min fill adjustment, based on patch by Jeremy Huddleston
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12836 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
parent
eb75e9bfde
commit
9b0d8c680f
|
@ -10,8 +10,10 @@
|
|||
// ------------------------- stream options --------------------
|
||||
|
||||
#ifdef USE_STREAM_CACHE
|
||||
{"cache", &stream_cache_size, CONF_TYPE_INT, CONF_RANGE, 4, 65536, NULL},
|
||||
{"cache", &stream_cache_size, CONF_TYPE_INT, CONF_RANGE, 32, 1048576, NULL},
|
||||
{"nocache", &stream_cache_size, CONF_TYPE_FLAG, 0, 1, 0, NULL},
|
||||
{"cache-min", &stream_cache_min_percent, CONF_TYPE_FLOAT, CONF_RANGE, 0, 99, NULL},
|
||||
{"cache-prefill", &stream_cache_prefill_percent, CONF_TYPE_FLOAT, CONF_RANGE, 0, 99, NULL},
|
||||
#else
|
||||
{"cache", "MPlayer was compiled without cache2 support.\n", CONF_TYPE_PRINT, CONF_NOCFG, 0, 0, NULL},
|
||||
#endif
|
||||
|
|
|
@ -116,6 +116,8 @@ framedrop = yes # drop frames, when not in sync (slow CPU, videocard,
|
|||
# etc)
|
||||
|
||||
cache = 8192 # use 8Mb input cache by default
|
||||
cache_min = 20.0 # Prefill 20% of the cache before initially playing
|
||||
cache_prefill = 5.0 # Prefill 5% of the cache before restarting playback if it empties
|
||||
|
||||
# slang = en # DVD : display english subtitles if available
|
||||
# alang = en # DVD : play english audio tracks if available
|
||||
|
|
|
@ -198,6 +198,9 @@ cache_vars_t* cache_init(int size,int sector){
|
|||
#endif
|
||||
memset(s,0,sizeof(cache_vars_t));
|
||||
num=size/sector;
|
||||
if(num < 16){
|
||||
num = 16;
|
||||
}//32kb min_size
|
||||
s->buffer_size=num*sector;
|
||||
s->sector_size=sector;
|
||||
#ifndef WIN32
|
||||
|
@ -206,8 +209,7 @@ cache_vars_t* cache_init(int size,int sector){
|
|||
s->buffer=malloc(s->buffer_size);
|
||||
#endif
|
||||
s->fill_limit=8*sector;
|
||||
s->back_size=size/2;
|
||||
s->prefill=size/20; // default: 5%
|
||||
s->back_size=s->buffer_size/2;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -246,11 +248,20 @@ int stream_enable_cache(stream_t *stream,int size,int min,int prefill){
|
|||
return 1;
|
||||
}
|
||||
|
||||
if(size<32*1024) size=32*1024; // 32kb min
|
||||
s=cache_init(size,ss);
|
||||
stream->cache_data=s;
|
||||
s->stream=stream; // callback
|
||||
s->prefill=size*prefill;
|
||||
s->prefill=prefill;
|
||||
|
||||
|
||||
//make sure that we won't wait from cache_fill
|
||||
//more data than it is alowed to fill
|
||||
if (s->prefill > s->buffer_size - s->fill_limit ){
|
||||
s->prefill = s->buffer_size - s->fill_limit;
|
||||
}
|
||||
if (min > s->buffer_size - s->fill_limit) {
|
||||
min = s->buffer_size - s->fill_limit;
|
||||
}
|
||||
|
||||
#ifndef WIN32
|
||||
if((stream->cache_pid=fork())){
|
||||
|
|
|
@ -1374,6 +1374,9 @@ int audio_stream_cache = 0;
|
|||
|
||||
extern int hr_mp3_seek;
|
||||
|
||||
extern float stream_cache_min_percent;
|
||||
extern float stream_cache_prefill_percent;
|
||||
|
||||
demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int dvdsub_id,char* filename){
|
||||
stream_t *as = NULL,*ss = NULL;
|
||||
demuxer_t *vd,*ad = NULL,*sd = NULL;
|
||||
|
@ -1386,8 +1389,8 @@ demuxer_t* demux_open(stream_t *vs,int file_format,int audio_id,int video_id,int
|
|||
return NULL;
|
||||
}
|
||||
if(audio_stream_cache) {
|
||||
if(!stream_enable_cache(as,audio_stream_cache*1024,audio_stream_cache*1024/5,
|
||||
audio_stream_cache*1024/20)) {
|
||||
if(!stream_enable_cache(as,audio_stream_cache*1024,audio_stream_cache*1024*(stream_cache_min_percent / 100.0),
|
||||
audio_stream_cache*1024*(stream_cache_prefill_percent / 100.0))) {
|
||||
free_stream(as);
|
||||
mp_msg(MSGT_DEMUXER,MSGL_ERR,"Can't enable audio stream cache\n");
|
||||
return NULL;
|
||||
|
|
|
@ -105,6 +105,9 @@ int forced_subs_only=0;
|
|||
int stream_cache_size=-1;
|
||||
#ifdef USE_STREAM_CACHE
|
||||
extern int cache_fill_status;
|
||||
|
||||
float stream_cache_min_percent=20.0;
|
||||
float stream_cache_prefill_percent=5.0;
|
||||
#else
|
||||
#define cache_fill_status 0
|
||||
#endif
|
||||
|
|
|
@ -255,6 +255,9 @@ int forced_subs_only=0;
|
|||
int stream_cache_size=-1;
|
||||
#ifdef USE_STREAM_CACHE
|
||||
extern int cache_fill_status;
|
||||
|
||||
float stream_cache_min_percent=20.0;
|
||||
float stream_cache_prefill_percent=5.0;
|
||||
#else
|
||||
#define cache_fill_status 0
|
||||
#endif
|
||||
|
@ -1375,7 +1378,7 @@ goto_enable_cache:
|
|||
#endif
|
||||
if(stream_cache_size>0){
|
||||
current_module="enable_cache";
|
||||
if(!stream_enable_cache(stream,stream_cache_size*1024,stream_cache_size*1024/5,stream_cache_size*1024/20))
|
||||
if(!stream_enable_cache(stream,stream_cache_size*1024,stream_cache_size*1024*(stream_cache_min_percent / 100.0),stream_cache_size*1024*(stream_cache_prefill_percent / 100.0)))
|
||||
if((eof = libmpdemux_was_interrupted(PT_NEXT_ENTRY))) goto goto_next_file;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue