|
Lines 33-38
Link Here
|
| 33 |
int stream_fill_buffer(stream_t *s); |
33 |
int stream_fill_buffer(stream_t *s); |
| 34 |
int stream_seek_long(stream_t *s,off_t pos); |
34 |
int stream_seek_long(stream_t *s,off_t pos); |
| 35 |
|
35 |
|
|
|
36 |
extern float stream_cache_min_percent; |
| 37 |
extern float stream_cache_prefill_percent; |
| 36 |
extern int mp_input_check_interrupt(int time); |
38 |
extern int mp_input_check_interrupt(int time); |
| 37 |
|
39 |
|
| 38 |
typedef struct { |
40 |
typedef struct { |
|
Lines 207-213
Link Here
|
| 207 |
#endif |
209 |
#endif |
| 208 |
s->fill_limit=8*sector; |
210 |
s->fill_limit=8*sector; |
| 209 |
s->back_size=size/2; |
211 |
s->back_size=size/2; |
| 210 |
s->prefill=size/20; // default: 5% |
212 |
s->prefill=size * stream_cache_prefill_percent / 100.0; |
| 211 |
return s; |
213 |
return s; |
| 212 |
} |
214 |
} |
| 213 |
|
215 |
|
|
Lines 265-271
Link Here
|
| 265 |
// wait until cache is filled at least prefill_init % |
267 |
// wait until cache is filled at least prefill_init % |
| 266 |
mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %d [%d] %d pre:%d eof:%d \n", |
268 |
mp_msg(MSGT_CACHE,MSGL_V,"CACHE_PRE_INIT: %d [%d] %d pre:%d eof:%d \n", |
| 267 |
s->min_filepos,s->read_filepos,s->max_filepos,min,s->eof); |
269 |
s->min_filepos,s->read_filepos,s->max_filepos,min,s->eof); |
| 268 |
while(s->read_filepos<s->min_filepos || s->max_filepos-s->read_filepos<min){ |
270 |
|
|
|
271 |
// The buffer is determined to be full in cache_fill() when this condition is true: |
| 272 |
// s->buffer_size - (s->max_filepos - s->read_filepos) < s->fill_limit |
| 273 |
// So we need to make sure that min does not go over s->buffer_size - s->fill_limit |
| 274 |
// ie this needs to be always be true: |
| 275 |
// s->buffer_size - (data_in_buffer) >= s->fill_limit |
| 276 |
// ==> data_in_buffer <= s->buffer_size - s->fill_limit |
| 277 |
// |
| 278 |
// So we need to make sure that our min is safe with this condition or else we |
| 279 |
// will wait forever for cache_fill() to get to min. |
| 280 |
if (min > s->buffer_size - s->fill_limit) { |
| 281 |
min = s->buffer_size - s->fill_limit; |
| 282 |
} |
| 283 |
|
| 284 |
// Keep waiting for the buffer to fill while: |
| 285 |
// We still want to read more: (s->max_filepos - s->read_filepos < min) || (s->read_filepos < s->min_filepos) |
| 286 |
// There is data to read in the file: (!s->eof) |
| 287 |
while( (s->max_filepos - s->read_filepos < min) || |
| 288 |
(s->read_filepos < s->min_filepos)) { |
| 289 |
|
| 269 |
mp_msg(MSGT_CACHE,MSGL_STATUS,"\rCache fill: %5.2f%% (%d bytes) ", |
290 |
mp_msg(MSGT_CACHE,MSGL_STATUS,"\rCache fill: %5.2f%% (%d bytes) ", |
| 270 |
100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size), |
291 |
100.0*(float)(s->max_filepos-s->read_filepos)/(float)(s->buffer_size), |
| 271 |
s->max_filepos-s->read_filepos |
292 |
s->max_filepos-s->read_filepos |