]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab: tuning and optimizations
authorJaroslav Kysela <perex@perex.cz>
Wed, 14 May 2014 06:35:04 +0000 (08:35 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 14 May 2014 06:37:52 +0000 (08:37 +0200)
- reduce timeout value for nit to 240
- increase interval value for nit to 3600
- process all waiting muxes in one shot
- add the grace value for satellite positioners

src/epggrab/module/eit.c
src/epggrab/otamux.c
src/input/mpegts.h
src/input/mpegts/mpegts_input.c
src/input/mpegts/mpegts_mux.c

index bc45ae7f12b15f0cef8d60230aa54843d289af36..67851e907715f4f8f15790ad7a709f3d95a4dd72 100644 (file)
@@ -573,7 +573,7 @@ _eit_callback
 
   /* Register interest */
   if (tableid >= 0x50)
-    ota = epggrab_ota_register((epggrab_module_ota_t*)mod, mm, 1200, 3600);
+    ota = epggrab_ota_register((epggrab_module_ota_t*)mod, mm, 3600, 240);
 
   /* Begin */
   r = dvb_table_begin(mt, ptr, len, tableid, extraid, 11, &st, &sect, &last, &ver);
index 9a3be5c5757bda6353cea9da125833ca109f8a26..36aa9e3ac2952b0dabb8349181de49185973d2b4 100644 (file)
@@ -60,11 +60,11 @@ om_id_cmp   ( epggrab_ota_mux_t *a, epggrab_ota_mux_t *b )
   return strcmp(a->om_mux_uuid, b->om_mux_uuid);
 }
 
-#define EPGGRAB_OTA_MIN_PERIOD  600
+#define EPGGRAB_OTA_MIN_PERIOD   300
 #define EPGGRAB_OTA_MIN_TIMEOUT  30
 
 static int
-epggrab_ota_period ( epggrab_ota_mux_t *ota )
+epggrab_ota_period ( epggrab_ota_mux_t *ota, int divider )
 {
   int period = 0;
   epggrab_ota_map_t *map;
@@ -77,6 +77,8 @@ epggrab_ota_period ( epggrab_ota_mux_t *ota )
         period = map->om_interval;
   }
 
+  period /= divider;
+
   if (period < EPGGRAB_OTA_MIN_PERIOD)
     period = EPGGRAB_OTA_MIN_PERIOD;
   
@@ -110,7 +112,7 @@ epggrab_ota_done ( epggrab_ota_mux_t *ota, int timeout )
 
   LIST_REMOVE(ota, om_q_link);
   ota->om_active = 0;
-  ota->om_when   = dispatch_clock + epggrab_ota_period(ota);
+  ota->om_when   = dispatch_clock + epggrab_ota_period(ota, 1);
   LIST_INSERT_SORTED(&epggrab_ota_pending, ota, om_q_link, om_time_cmp);
 
   /* Remove subscriber */
@@ -128,10 +130,10 @@ epggrab_ota_done ( epggrab_ota_mux_t *ota, int timeout )
 }
 
 static void
-epggrab_ota_start ( epggrab_ota_mux_t *om )
+epggrab_ota_start ( epggrab_ota_mux_t *om, int grace )
 {
   epggrab_ota_map_t *map;
-  om->om_when   = dispatch_clock + epggrab_ota_timeout(om);
+  om->om_when   = dispatch_clock + epggrab_ota_timeout(om) + grace;
   om->om_active = 1;
   LIST_INSERT_SORTED(&epggrab_ota_active, om, om_q_link, om_time_cmp);
   if (LIST_FIRST(&epggrab_ota_active) == om)
@@ -242,6 +244,7 @@ epggrab_ota_complete
 {
   int done = 1;
   epggrab_ota_map_t *map;
+  lock_assert(&global_lock);
   tvhdebug(mod->id, "grab complete");
 
   /* Test for completion */
@@ -292,15 +295,18 @@ epggrab_ota_pending_timer_cb ( void *p )
   epggrab_ota_map_t *map;
   epggrab_ota_mux_t *om = LIST_FIRST(&epggrab_ota_pending);
   mpegts_mux_t *mm;
+  int extra = 0;
+
   gtimer_disarm(&epggrab_ota_pending_timer);
 
   lock_assert(&global_lock);
   if (!om)
     return;
-  
+
   /* Double check */
   if (om->om_when > dispatch_clock)
     goto done;
+next_one:
   LIST_REMOVE(om, om_q_link);
 
   /* Find the mux */
@@ -326,31 +332,31 @@ epggrab_ota_pending_timer_cb ( void *p )
     char name[256];
     mm->mm_display_name(mm, name, sizeof(name));
     tvhdebug("epggrab", "no modules attached to %s, check again later", name);
-    om->om_when = dispatch_clock + epggrab_ota_period(om) / 2;
+    om->om_when = dispatch_clock + epggrab_ota_period(om, 4);
     LIST_INSERT_SORTED(&epggrab_ota_pending, om, om_q_link, om_time_cmp);
     goto done;
   }
 
-  /* Insert into active (assume success) */
-  // Note: if we don't do this the subscribe below can result in a mux
-  //       start call which means we call it a second time below
-  epggrab_ota_start(om);
-
   /* Subscribe to the mux */
   if (mpegts_mux_subscribe(mm, "epggrab", SUBSCRIPTION_PRIO_EPG)) {
-    LIST_REMOVE(om, om_q_link);
     om->om_active = 0;
-    om->om_when   = dispatch_clock + epggrab_ota_period(om) / 2;
+    om->om_when   = dispatch_clock + epggrab_ota_period(om, 4) + extra;
     LIST_INSERT_SORTED(&epggrab_ota_pending, om, om_q_link, om_time_cmp);
   } else {
-    epggrab_mux_start0(mm, 1);
+    mpegts_mux_instance_t *mmi = mm->mm_active;
+    epggrab_ota_start(om, mpegts_input_grace(mmi->mmi_input, mm));
   }
 
 done:
   om = LIST_FIRST(&epggrab_ota_pending);
-  if (om)
+  if (om) {
+    if (om->om_when <= dispatch_clock) {
+      extra += 60; /* differentiate the mux busy requests */
+      goto next_one;
+    }
     gtimer_arm_abs(&epggrab_ota_pending_timer, epggrab_ota_pending_timer_cb,
                    NULL, om->om_when);
+  }
 }
 
 /* **************************************************************************
index ffc0fe1ca0f8d970a8d658f22aefbc06eeafb65d..37a62b2f2e910def6c9d758a17bd6f85edd2c958 100644 (file)
@@ -574,6 +574,8 @@ void mpegts_input_close_service ( mpegts_input_t *mi, mpegts_service_t *s );
 
 void mpegts_input_status_timer ( void *p );
 
+int mpegts_input_grace ( mpegts_input_t * mi, mpegts_mux_t * mm );
+
 /* TODO: exposing these class methods here is a bit of a hack */
 const void *mpegts_input_class_network_get  ( void *o );
 int         mpegts_input_class_network_set  ( void *o, const void *p );
index 8a14cc846961d826af02f08ef4f83a368338d069..f28264115eac7e3dae397e1083f372f7b2f49a98 100644 (file)
@@ -1047,6 +1047,16 @@ mpegts_input_set_networks ( mpegts_input_t *mi, htsmsg_t *msg )
   return save;
 }
 
+int mpegts_input_grace( mpegts_input_t *mi, mpegts_mux_t *mm )
+{
+  /* Get timeout */
+  int t = 0;
+  if (mi && mi->mi_get_grace)
+    t = mi->mi_get_grace(mi, mm);
+  if (t < 5) t = 5; // lower bound
+  return t;
+}
+
 /******************************************************************************
  * Editor Configuration
  *
index a1c96d252c85fdf3625ca4c7358fcfd122022877..3358fa82f6885ac07d3d2a70e787834094f3afcc 100644 (file)
@@ -92,10 +92,7 @@ mpegts_mux_add_to_current
                       mm_initial_scan_link);
 
     /* Get timeout */
-    t = 0;
-    if (mi && mi->mi_get_grace)
-      t = mi->mi_get_grace(mi, mm);
-    if (t < 5) t = 5; // lower bound
+    t = mpegts_input_grace(mi, mm);
   
     /* Setup timeout */
     gtimer_arm(&mm->mm_initial_scan_timeout,