summaryrefslogtreecommitdiffstats
path: root/stream/stream.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-11-17 19:12:13 +0200
committerwm4 <wm4@nowhere>2012-12-03 21:08:51 +0100
commit2d58234c86e59298de52fec12d1eb59086d68763 (patch)
treed11ec050f30e1fa47cbf30475e6d84adf8080468 /stream/stream.c
parentc082240c62cb8855e55c0dbe88b8591458599ce9 (diff)
downloadmpv-2d58234c86e59298de52fec12d1eb59086d68763.tar.bz2
mpv-2d58234c86e59298de52fec12d1eb59086d68763.tar.xz
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).
Diffstat (limited to 'stream/stream.c')
-rw-r--r--stream/stream.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/stream/stream.c b/stream/stream.c
index 94a7c4cf6d..bd87448fac 100644
--- a/stream/stream.c
+++ b/stream/stream.c
@@ -182,6 +182,16 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
free(s);
return NULL;
}
+
+ s->cache_size = 0;
+ if (s->streaming_ctrl && s->streaming_ctrl->buffering) {
+ // Set default cache size to use if user does not specify it.
+ // buffer in KBytes, *5 assuming the prefill is 20% of the buffer.
+ s->cache_size = s->streaming_ctrl->prebuffer_size / 1024 * 5;
+ if (s->cache_size < 64)
+ s->cache_size = 64;
+ }
+
if(s->type <= -2)
mp_msg(MSGT_OPEN,MSGL_WARN, "Warning streams need a type !!!!\n");
if(s->flags & MP_STREAM_SEEK && !s->seek)
@@ -200,8 +210,8 @@ static stream_t *open_stream_plugin(const stream_info_t *sinfo,
}
-stream_t *open_stream_full(const char *filename, int mode,
- struct MPOpts *options, int *file_format)
+static stream_t *open_stream_full(const char *filename, int mode,
+ struct MPOpts *options, int *file_format)
{
int i,j,l,r;
const stream_info_t* sinfo;