[vlc-commits] dvb: refactor dvb-c scanning code out from scan_Next()

Ilkka Ollakka git at videolan.org
Thu Mar 10 12:33:15 CET 2011


vlc | branch: master | Ilkka Ollakka <ileoo at videolan.org> | Thu Mar 10 12:29:54 2011 +0200| [d22d955d046f921940de46f4dcf317094557d182] | committer: Ilkka Ollakka

dvb: refactor dvb-c scanning code out from scan_Next()

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

 modules/access/dvb/scan.c |   91 +++++++++++++++++++++++----------------------
 1 files changed, 47 insertions(+), 44 deletions(-)

diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index a1bd3f9..b23142f 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -479,6 +479,52 @@ static int ScanDvbTNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
 
 static int ScanDvbCNext( scan_t *p_scan, scan_configuration_t *p_cfg, double *pf_pos )
 {
+    bool b_servicefound = false;
+    for( int i = 0; i < p_scan->i_service; i++ )
+    {
+        b_servicefound = (p_scan->pp_service[i]->type != SERVICE_UNKNOWN);
+        if( b_servicefound )
+            break;
+    }
+    if( !b_servicefound )
+    {
+        bool b_rotate=true;
+        if( !p_scan->parameter.b_modulation_set )
+        {
+            p_scan->parameter.i_modulation = (p_scan->parameter.i_modulation << 1 ) % 512;
+            /* if we iterated all modulations, move on */
+            if( !p_scan->parameter.i_modulation )
+            {
+                p_scan->parameter.i_modulation = 16;
+            } else {
+                b_rotate=false;
+            }
+            msg_Dbg( p_scan->p_obj, "modulation %d ", p_scan->parameter.i_modulation);
+        }
+        if( !p_scan->parameter.b_symbolrate_set )
+        {
+            /* symbol rates from dvb-tools dvb-c files */
+            static const unsigned short symbolrates[] = {
+             6900, 6875, 6950, 7000, 3450, 6111,
+             6428, 6952, 5900, 5000 };
+
+            enum { num_symbols = (sizeof(symbolrates)/sizeof(*symbolrates)) };
+
+            /* if we rotated modulations, rotate symbolrate */
+            if( b_rotate )
+               p_scan->parameter.i_symbolrate = (++p_scan->parameter.i_symbolrate % num_symbols );
+            p_cfg->i_symbolrate = 1000 * (symbolrates[ p_scan->parameter.i_symbolrate ] );
+            msg_Dbg( p_scan->p_obj, "symbolrate %d", p_cfg->i_symbolrate );
+            if( p_scan->parameter.i_symbolrate )
+                b_rotate=false;
+        }
+        if( !b_rotate && p_scan->i_index )
+            p_scan->i_index--;
+    }
+    p_cfg->i_modulation = p_scan->parameter.i_modulation;
+    if( !p_cfg->i_symbolrate )
+        p_cfg->i_symbolrate = var_GetInteger( p_scan->p_obj, "dvb-srate" );
+
     if( p_scan->parameter.b_exhaustive )
         return ScanDvbNextExhaustive( p_scan, p_cfg, pf_pos );
     else
@@ -554,50 +600,7 @@ int scan_Next( scan_t *p_scan, scan_configuration_t *p_cfg )
         free( psz_text );
     }
 
-    if( i_service == 0 &&
-        p_scan->parameter.type == SCAN_DVB_C )
-    {
-        bool b_rotate=true;
-        if( !p_scan->parameter.b_modulation_set )
-        {
-            p_scan->parameter.i_modulation = (p_scan->parameter.i_modulation << 1 ) % 512;
-            /* if we iterated all modulations, move on */
-            if( !p_scan->parameter.i_modulation )
-            {
-                p_scan->parameter.i_modulation = 16;
-            } else {
-                b_rotate=false;
-            }
-            msg_Dbg( p_scan->p_obj, "modulation %d ", p_scan->parameter.i_modulation);
-        }
-        if( !p_scan->parameter.b_symbolrate_set )
-        {
-            /* symbol rates from dvb-tools dvb-c files */
-            static const unsigned short symbolrates[] = {
-             6900, 6875, 6950, 7000, 3450, 6111,
-             6428, 6952, 5900, 5000 };
-
-            enum { num_symbols = (sizeof(symbolrates)/sizeof(*symbolrates)) };
-
-            /* if we rotated modulations, rotate symbolrate */
-            if( b_rotate )
-               p_scan->parameter.i_symbolrate = (++p_scan->parameter.i_symbolrate % num_symbols );
-            p_cfg->i_symbolrate = 1000 * (symbolrates[ p_scan->parameter.i_symbolrate ] );
-            msg_Dbg( p_scan->p_obj, "symbolrate %d", p_cfg->i_symbolrate );
-            if( p_scan->parameter.i_symbolrate )
-                b_rotate=false;
-        }
-        if( b_rotate )
-            p_scan->i_index++;
-    } else {
-       p_scan->i_index++;
-    }
-    if( p_scan->parameter.type == SCAN_DVB_C )
-    {
-       p_cfg->i_modulation = p_scan->parameter.i_modulation;
-       if( !p_cfg->i_symbolrate )
-           p_cfg->i_symbolrate = var_GetInteger( p_scan->p_obj, "dvb-srate" );
-    }
+    p_scan->i_index++;
     return VLC_SUCCESS;
 }
 



More information about the vlc-commits mailing list