diff options
-rwxr-xr-x | configure | 2 | ||||
-rw-r--r-- | stream/tvi_v4l.c | 13 | ||||
-rw-r--r-- | stream/tvi_v4l2.c | 13 |
3 files changed, 11 insertions, 17 deletions
@@ -3551,7 +3551,7 @@ fi #if sunos 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 diff --git a/stream/tvi_v4l.c b/stream/tvi_v4l.c index bbf290eeaf..31f767850b 100644 --- a/stream/tvi_v4l.c +++ b/stream/tvi_v4l.c @@ -760,7 +760,8 @@ static int uninit(priv_t *priv) 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 @@ static int get_capture_buffer_size(priv_t *priv) struct sysinfo si; sysinfo(&si); - if (si.totalram<2*1024*1024) { - bufsize = 1024*1024; - } else { - bufsize = si.totalram/2; - } -#else - bufsize = 16*1024*1024; + bufsize = (si.freeram/2)*si.mem_unit; + if (bufsize < 16*1024*1024) #endif + bufsize = 16*1024*1024; } cnt = bufsize/(priv->height*priv->bytesperline); diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c index 234a5ac019..a3be9e799a 100644 --- a/stream/tvi_v4l2.c +++ b/stream/tvi_v4l2.c @@ -1376,7 +1376,8 @@ static int init(priv_t *priv) 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 @@ static int get_capture_buffer_size(priv_t *priv) struct sysinfo si; sysinfo(&si); - if (si.totalram<2*1024*1024) { - bufsize = 1024*1024; - } else { - bufsize = si.totalram/2; - } -#else - bufsize = 16*1024*1024; + bufsize = (si.freeram/2)*si.mem_unit; + if ( bufsize < 16*1024*1024) #endif + bufsize = 16*1024*1024; } cnt = bufsize/priv->format.fmt.pix.sizeimage; |