access: dvb: scan: set probing timeout per delivery
authorFrancois Cartegnie <fcvlcdev@free.fr>
Wed, 13 Apr 2016 12:18:48 +0000 (14:18 +0200)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Wed, 13 Apr 2016 18:35:10 +0000 (20:35 +0200)
does not wait for lock and starts probing timeout
when packets are received.

modules/access/dvb/access.c
modules/access/dvb/scan.c
modules/access/dvb/scan.h

index df1f0ab..2114895 100644 (file)
@@ -262,6 +262,7 @@ static block_t *BlockScan( access_t *p_access )
 
     /* */
     int64_t i_scan_start = mdate();
+    int64_t i_probe_start = 0;
 
     bool b_has_dvb_signal = false;
     bool b_has_lock = false;
@@ -278,18 +279,23 @@ static block_t *BlockScan( access_t *p_access )
     for ( ; ; )
     {
         frontend_status_t status;
-
         FrontendGetStatus( p_access, &status );
         b_has_dvb_signal |= status.b_has_carrier;
         b_has_lock |= status.b_has_lock;
 
-        int64_t i_scan_end = i_scan_start;
-        if( !b_has_dvb_signal )
-            i_scan_end += DVB_SCAN_MAX_SIGNAL_TIME;
-        else if( !b_has_lock )
-            i_scan_end += DVB_SCAN_MAX_LOCK_TIME;
+        int64_t i_scan_end;
+        if( i_probe_start )
+        {
+            i_scan_end = i_probe_start + scan_session_GetTablesTimeout( session );
+        }
         else
-            i_scan_end += DVB_SCAN_MAX_PROBE_TIME;
+        {
+            i_scan_end = i_scan_start;
+            if( !b_has_dvb_signal )
+                i_scan_end += DVB_SCAN_MAX_SIGNAL_TIME;
+            else if( !b_has_lock )
+                i_scan_end += DVB_SCAN_MAX_LOCK_TIME;
+        }
 
         /* Find if some data is available */
         int i_ret;
@@ -344,6 +350,9 @@ static block_t *BlockScan( access_t *p_access )
 
         if ( ufds[0].revents )
         {
+            if( i_probe_start == 0 )
+                i_probe_start = mdate();
+
             const int i_read_once = 1;
             block_t *p_block = block_Alloc( i_read_once * TS_PACKET_SIZE );
 
index d13cbec..db3a3c9 100644 (file)
@@ -126,6 +126,7 @@ struct scan_session_t
         size_t i_nit;
     } others;
 
+    scan_type_t type;
     bool b_use_nit;
     uint16_t i_nit_pid;
 
@@ -1155,6 +1156,7 @@ scan_session_t *scan_session_New( scan_t *p_scan, const scan_tuner_config_t *p_c
     p_session->local.p_nit = NULL;
     p_session->i_nit_pid = -1;
     p_session->b_use_nit = p_scan->parameter.b_use_nit;
+    p_session->type = p_scan->parameter.type;
     p_session->others.i_nit = 0;
     p_session->others.i_sdt = 0;
     p_session->others.pp_nit = NULL;
@@ -1464,3 +1466,25 @@ void scan_session_SetSNR( scan_session_t *p_session, int i_snr )
 {
     p_session->i_snr = i_snr;
 }
+
+unsigned scan_session_GetTablesTimeout( const scan_session_t *p_session )
+{
+    unsigned i_time = 0;
+    if( !p_session->local.p_pat )
+    {
+        i_time = 500;
+    }
+    else if( !p_session->local.p_sdt )
+    {
+        i_time = 2*1000;
+    }
+    else if( !p_session->local.p_nit && p_session->b_use_nit )
+    {
+        if( p_session->type == SCAN_DVB_T )
+            i_time = 6000;
+        else
+            i_time = 5000;
+    }
+
+    return i_time * 2 * 1000;
+}
index 26d0338..6b4a306 100644 (file)
@@ -92,4 +92,4 @@ scan_session_t *scan_session_New( scan_t *, const scan_tuner_config_t * );
 void scan_session_Destroy( scan_t *, scan_session_t * );
 bool scan_session_Push( scan_session_t *p_scan, block_t *p_block );
 void scan_session_SetSNR( scan_session_t *p_scan, int i_snr );
-
+unsigned scan_session_GetTablesTimeout( const scan_session_t * );