[dvblast-devel] Make DVR buffer size configurable.

Stas Sergeev git at videolan.org
Tue Oct 29 09:42:22 CET 2013


dvblast | branch: master | Stas Sergeev <stsp at users.sourceforge.net> | Mon Oct 28 13:21:26 2013 +0400| [d5180ba1374ce45461c6d9008a638c6ce340bf3c] | committer: Georgi Chorbadzhiyski

Make DVR buffer size configurable.

Currently DVR_BUFFER_SIZE is set to over 7Mb, which may be too much for
some uses.

This patch allows adds -2 <size> / --dvr-buf-size <size> parameter to
control how much the buffer takes.

> http://git.videolan.org/gitweb.cgi/dvblast.git/?a=commit;h=d5180ba1374ce45461c6d9008a638c6ce340bf3c
---

 dvb.c     |    4 +++-
 dvblast.1 |    4 ++++
 dvblast.c |   15 +++++++++++++--
 dvblast.h |    1 +
 4 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/dvb.c b/dvb.c
index b4af191..24333ad 100644
--- a/dvb.c
+++ b/dvb.c
@@ -68,6 +68,8 @@
 #define MAX_READ_ONCE 50
 #define DVR_BUFFER_SIZE 40*188*1024 /* bytes */
 
+int i_dvr_buffer_size = DVR_BUFFER_SIZE;
+
 static int i_frontend, i_dvr;
 static fe_status_t i_last_status;
 static mtime_t i_frontend_timeout;
@@ -112,7 +114,7 @@ void dvb_Open( void )
         exit(1);
     }
 
-    if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, DVR_BUFFER_SIZE ) < 0 )
+    if ( ioctl( i_dvr, DMX_SET_BUFFER_SIZE, i_dvr_buffer_size ) < 0 )
     {
         msg_Warn( NULL, "couldn't set %s buffer size (%s)", psz_tmp,
                  strerror(errno) );
diff --git a/dvblast.1 b/dvblast.1
index 537e299..7fedb60 100644
--- a/dvblast.1
+++ b/dvblast.1
@@ -13,6 +13,7 @@ DVBlast \- Simple and powerful dvb streaming application
 [\fI-z\fR] [\fI-C\fR] [\fI-e\fR] [\fI-M <network_name>\fR] [\fI-N <network_ID>\fR] [\fI-T\fR] [\fI-j <system_charset>\fR]
 [\fI-W\fR] [\fI-Y\fR] [\fI-l\fR] [\fI-g <logger ident>\fR] [\fI-Z <mrtg_file>\fR] [\fI-V\fR] [\fI-h\fR]
 [\fI-J <DVB_charset>\fR] [\fI-B <provider_name>\fR] [\fI-Q <quit_timeout>\fR] [\fI-x <text|xml>\fR]
+[\fI-2 <size>\fR]
 .SH DESCRIPTION
 DVBlast is a simple and powerful streaming application based on the linux-dvb
 API. It opens a DVB device, tunes it, places PID filters, configures a CAM
@@ -137,6 +138,9 @@ The frontend number
 \fB\-y\fR, \fB\-\-ca\-number\fR <ca_dev_number>
 CA device number. Default: 0
 .TP
+\fB\-2\fR, \fB\-\-dvr\-buf\-size\fR <size>
+Sets the size of the DVR TS buffer in bytes.
+.TP
 \fB\-N\fR, \fB\-\-network-id\fR <ID>
 DVB network ID to declare in the NIT
 .TP
diff --git a/dvblast.c b/dvblast.c
index e2357a3..1792316 100644
--- a/dvblast.c
+++ b/dvblast.c
@@ -542,6 +542,7 @@ void usage()
     msg_Raw( NULL, "  -w --select-pmts      set a PID filter on all PMTs (auto on, when config file is used)" );
     msg_Raw( NULL, "  -O --lock-timeout     timeout for the lock operation (in ms)" );
     msg_Raw( NULL, "  -y --ca-number <ca_device_number>" );
+    msg_Raw( NULL, "  -2 --dvr-buf-size <size> set the size of the DVR TS buffer in bytes (default: %d)", i_dvr_buffer_size);
 #endif
 
     msg_Raw( NULL, "Output:" );
@@ -598,7 +599,7 @@ int main( int i_argc, char **pp_argv )
         usage();
 
     /*
-     * The only short options left are: 2346789
+     * The only short options left are: 346789
      * Use them wisely.
      */
     static const struct option long_options[] =
@@ -658,10 +659,11 @@ int main( int i_argc, char **pp_argv )
         { "mrtg-file",       required_argument, NULL, 'Z' },
         { "ca-number",       required_argument, NULL, 'y' },
         { "pidmap",          required_argument, NULL, '0' },
+        { "dvr-buf-size",    required_argument, NULL, '2' },
         { 0, 0, 0, 0 }
     };
 
-    while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:5:f:F:R:s:S:k:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:D:A:lg:zCWYeM:N:j:J:B:x:Q:hVZ:y:0:1:", long_options, NULL)) != -1 )
+    while ( (c = getopt_long(i_argc, pp_argv, "q::c:r:t:o:i:a:n:5:f:F:R:s:S:k:v:pb:I:m:P:K:G:H:X:O:uwUTL:E:d:D:A:lg:zCWYeM:N:j:J:B:x:Q:hVZ:y:0:1:2:", long_options, NULL)) != -1 )
     {
         switch ( c )
         {
@@ -990,6 +992,15 @@ int main( int i_argc, char **pp_argv )
             b_do_remap = true;
             break;
         }
+        case '2':
+            i_dvr_buffer_size = strtol( optarg, NULL, 0 );
+            if (!i_dvr_buffer_size)
+                usage();	// it exits
+            /* roundup to packet size */
+            i_dvr_buffer_size += TS_SIZE - 1;
+            i_dvr_buffer_size /= TS_SIZE;
+            i_dvr_buffer_size *= TS_SIZE;
+            break;
         case 'h':
         default:
             usage();
diff --git a/dvblast.h b/dvblast.h
index 8a08bd2..fbd62a8 100644
--- a/dvblast.h
+++ b/dvblast.h
@@ -201,6 +201,7 @@ extern int i_adapter;
 extern int i_fenum;
 extern int i_canum;
 extern char *psz_delsys;
+extern int i_dvr_buffer_size;
 extern int i_frequency;
 extern int i_srate;
 extern int i_satnum;



More information about the dvblast-devel mailing list