Mercurial > mplayer.hg
changeset 33644:c15dabfa2380
Do a proper calculation of free RAM to be used as V4L buffers.
The code uses sysinfo to query the available RAM, however it used
ancient form available is some early development 2.3.x kernels.
Newer form reports the size in memory units (usually same as page size),
as result the code would fallback to 2 buffers even on multi GB system.
The commit does: Improve the check in configure to ensure that we
do use sysinfo struct with present mem_unit. Use free ram instead of
total ram (to avoid swapping). Tweak memory constants and simplify code.
author | iive |
---|---|
date | Sun, 26 Jun 2011 14:42:35 +0000 |
parents | 311468e8af65 |
children | 4c3bee76ef3b |
files | configure stream/tvi_v4l.c stream/tvi_v4l2.c |
diffstat | 3 files changed, 11 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Sun Jun 26 14:16:40 2011 +0000 +++ b/configure Sun Jun 26 14:42:35 2011 +0000 @@ -3997,7 +3997,7 @@ echocheck "sys/sysinfo.h" _sys_sysinfo=no -statement_check sys/sysinfo.h 'struct sysinfo s_info; sysinfo(&s_info)' && _sys_sysinfo=yes +statement_check sys/sysinfo.h 'struct sysinfo s_info; s_info.mem_unit=0; sysinfo(&s_info)' && _sys_sysinfo=yes if test "$_sys_sysinfo" = yes ; then def_sys_sysinfo_h='#define HAVE_SYS_SYSINFO_H 1' else
--- a/stream/tvi_v4l.c Sun Jun 26 14:16:40 2011 +0000 +++ b/stream/tvi_v4l.c Sun Jun 26 14:42:35 2011 +0000 @@ -760,7 +760,8 @@ static int get_capture_buffer_size(priv_t *priv) { - int bufsize, cnt; + uint64_t bufsize; + int cnt; if (priv->tv_param->buffer_size >= 0) { bufsize = priv->tv_param->buffer_size*1024*1024; @@ -769,14 +770,10 @@ struct sysinfo si; sysinfo(&si); - if (si.totalram<2*1024*1024) { - bufsize = 1024*1024; - } else { - bufsize = si.totalram/2; - } -#else + bufsize = (si.freeram/2)*si.mem_unit; + if (bufsize < 16*1024*1024) +#endif bufsize = 16*1024*1024; -#endif } cnt = bufsize/(priv->height*priv->bytesperline);
--- a/stream/tvi_v4l2.c Sun Jun 26 14:16:40 2011 +0000 +++ b/stream/tvi_v4l2.c Sun Jun 26 14:42:35 2011 +0000 @@ -1376,7 +1376,8 @@ static int get_capture_buffer_size(priv_t *priv) { - int bufsize, cnt; + uint64_t bufsize; + int cnt; if (priv->tv_param->buffer_size >= 0) { bufsize = priv->tv_param->buffer_size*1024*1024; @@ -1385,14 +1386,10 @@ struct sysinfo si; sysinfo(&si); - if (si.totalram<2*1024*1024) { - bufsize = 1024*1024; - } else { - bufsize = si.totalram/2; - } -#else + bufsize = (si.freeram/2)*si.mem_unit; + if ( bufsize < 16*1024*1024) +#endif bufsize = 16*1024*1024; -#endif } cnt = bufsize/priv->format.fmt.pix.sizeimage;