[vlc-commits] access: dvb: scan: move transponders context out of parameters

Francois Cartegnie git at videolan.org
Sun Apr 10 13:56:10 CEST 2016


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Wed Apr  6 14:39:08 2016 +0200| [dd0b8136f2ab7a7c1883226b03065f5c5bf88116] | committer: Francois Cartegnie

access: dvb: scan: move transponders context out of parameters

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

 modules/access/dvb/scan.c |   55 +++++++++++++++++++++++++++------------------
 modules/access/dvb/scan.h |   10 ---------
 2 files changed, 33 insertions(+), 32 deletions(-)

diff --git a/modules/access/dvb/scan.c b/modules/access/dvb/scan.c
index fba66cb..e436f59 100644
--- a/modules/access/dvb/scan.c
+++ b/modules/access/dvb/scan.c
@@ -84,6 +84,14 @@ typedef struct
 
 } scan_service_t;
 
+typedef struct
+{
+    int i_frequency;
+    int i_symbol_rate;
+    int i_fec;
+    char c_polarization;
+} scan_dvbs_transponder_t;
+
 struct scan_t
 {
     vlc_object_t *p_obj;
@@ -94,6 +102,10 @@ struct scan_t
 
     int            i_service;
     scan_service_t **pp_service;
+
+    /* dvbv3 list file */
+    scan_dvbs_transponder_t *p_transponders;
+    unsigned                 i_transponders;
 };
 
 struct scan_session_t
@@ -237,8 +249,6 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
 {
     msg_Dbg( p_scan->p_obj, "Scan index %"PRId64, p_scan->i_index );
 
-    unsigned *pi_count = &p_scan->parameter.sat_info.i_count;
-
     if( !p_scan->parameter.sat_info.psz_name )
     {
         msg_Err( p_scan->p_obj, "no satellite selected" );
@@ -246,7 +256,7 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
     }
 
     /* if there are no transponders in mem, laod from config file */
-    if( !*pi_count )
+    if( p_scan->i_transponders == 0 )
     {
         char *psz_path = NULL;
         char *data_dir = config_GetDataDir();
@@ -277,9 +287,9 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
             {
                 if ( ( res = fscanf( f, "%c %d %c %d %2s\n",
                             &type,
-                            &p_transponders[*pi_count].i_frequency,
-                            &p_transponders[*pi_count].c_polarization,
-                            &p_transponders[*pi_count].i_symbol_rate,
+                            &p_transponders[p_scan->i_transponders].i_frequency,
+                            &p_transponders[p_scan->i_transponders].c_polarization,
+                            &p_transponders[p_scan->i_transponders].i_symbol_rate,
                             psz_fec ) ) != 5 )
                 {
                     msg_Dbg( p_scan->p_obj, "error parsing transponder from file" );
@@ -290,19 +300,19 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
                 char psz_fec_list[] = "1/22/33/44/55/66/77/88/9";
                 char *p_fec = strstr( psz_fec_list, psz_fec );
                 if ( !p_fec )
-                    p_transponders[*pi_count].i_fec = 9;    /* FEC_AUTO */
+                    p_transponders[p_scan->i_transponders].i_fec = 9;    /* FEC_AUTO */
                 else
-                    p_transponders[*pi_count].i_fec = 1 + ( ( p_fec-psz_fec_list ) / 3 );
+                    p_transponders[p_scan->i_transponders].i_fec = 1 + ( ( p_fec-psz_fec_list ) / 3 );
 
-                (*pi_count)++;
+                p_scan->i_transponders++;
 
-                p_transponders = xrealloc(p_transponders, ( *pi_count + 1 ) * sizeof( scan_dvbs_transponder_t ) );
+                p_transponders = xrealloc(p_transponders, ( p_scan->i_transponders + 1 ) * sizeof( scan_dvbs_transponder_t ) );
             } while (res != EOF);
 
-            msg_Dbg( p_scan->p_obj, "parsed %d transponders from config", *pi_count);
+            msg_Dbg( p_scan->p_obj, "parsed %d transponders from config", p_scan->i_transponders);
 
             fclose( f );
-            p_scan->parameter.sat_info.p_transponders = p_transponders;
+            p_scan->p_transponders = p_transponders;
         }
         else
         {
@@ -315,32 +325,33 @@ static int ScanDvbSNextFast( scan_t *p_scan, scan_configuration_t *p_cfg, double
         free( psz_path );
     }
 
-    if( p_scan->i_index < *pi_count )
+    if( p_scan->i_index < p_scan->i_transponders )
     {
         /* setup params for scan */
-        p_cfg->i_symbol_rate = p_scan->parameter.sat_info.p_transponders[p_scan->i_index].i_symbol_rate / 1000;
-        p_cfg->i_frequency = p_scan->parameter.sat_info.p_transponders[p_scan->i_index].i_frequency;
-        p_cfg->i_fec = p_scan->parameter.sat_info.p_transponders[p_scan->i_index].i_fec;
-        p_cfg->c_polarization = p_scan->parameter.sat_info.p_transponders[p_scan->i_index].c_polarization;
+        p_cfg->i_symbol_rate = p_scan->p_transponders[p_scan->i_index].i_symbol_rate / 1000;
+        p_cfg->i_frequency = p_scan->p_transponders[p_scan->i_index].i_frequency;
+        p_cfg->i_fec = p_scan->p_transponders[p_scan->i_index].i_fec;
+        p_cfg->c_polarization = p_scan->p_transponders[p_scan->i_index].c_polarization;
 
         msg_Dbg( p_scan->p_obj,
                  "transponder [%"PRId64"/%d]: frequency=%d, symbolrate=%d, fec=%d, polarization=%c",
                  p_scan->i_index + 1,
-                 *pi_count,
+                 p_scan->i_transponders,
                  p_cfg->i_frequency,
                  p_cfg->i_symbol_rate,
                  p_cfg->i_fec,
                  p_cfg->c_polarization );
 
-        *pf_pos = (double)p_scan->i_index / *pi_count;
+        *pf_pos = (double)p_scan->i_index / p_scan->i_transponders;
 
         return VLC_SUCCESS;
     }
 
-    if( p_scan->parameter.sat_info.p_transponders )
+    if( p_scan->p_transponders )
     {
-        free( p_scan->parameter.sat_info.p_transponders );
-        p_scan->parameter.sat_info.p_transponders = NULL;
+        free( p_scan->p_transponders );
+        p_scan->p_transponders = NULL;
+        p_scan->i_transponders = 0;
     }
 
     return VLC_EGENERIC;
diff --git a/modules/access/dvb/scan.h b/modules/access/dvb/scan.h
index 578413a..d0a8005 100644
--- a/modules/access/dvb/scan.h
+++ b/modules/access/dvb/scan.h
@@ -29,14 +29,6 @@ typedef enum
     SCAN_DVB_C,
 } scan_type_t;
 
-typedef struct
-{
-    int i_frequency;
-    int i_symbol_rate;
-    int i_fec;
-    char c_polarization;
-} scan_dvbs_transponder_t;
-
 typedef struct scan_parameter_t
 {
     scan_type_t type;
@@ -71,8 +63,6 @@ typedef struct scan_parameter_t
     {
         char *psz_name;         /* satellite name */
 
-        scan_dvbs_transponder_t *p_transponders;
-        unsigned i_count;
     } sat_info;
 } scan_parameter_t;
 



More information about the vlc-commits mailing list