]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
epggrab: updated to the new mux sub API
authorAdam Sutton <dev@adamsutton.me.uk>
Mon, 2 Sep 2013 10:01:18 +0000 (11:01 +0100)
committerAdam Sutton <dev@adamsutton.me.uk>
Mon, 2 Sep 2013 10:01:18 +0000 (11:01 +0100)
src/epggrab.h
src/epggrab/otamux.c

index 28ea2613cbcb6c8fcd81eab32aeefd5ac40cea08..8c28b7d7474bc9226899f6a42fac4d856ec23026 100644 (file)
@@ -181,6 +181,8 @@ struct epggrab_ota_mux
   int                                om_timeout;      ///< User configurable
   int                                om_interval;
   time_t                             om_when;         ///< Next event time
+
+  struct th_subscription            *om_sub;
   
   LIST_ENTRY(epggrab_ota_mux)        om_q_link;
   RB_ENTRY(epggrab_ota_mux)          om_global_link;
index 47b72cf7dadb2fd8566f1d2961df7f823e32f45c..c2ef847b1ab050fc7c3e64f03c71142e5fb0847e 100644 (file)
@@ -24,6 +24,7 @@
 #include "epggrab.h"
 #include "epggrab/private.h"
 #include "input/mpegts.h"
+#include "subscriptions.h"
 
 RB_HEAD(,epggrab_ota_mux)   epggrab_ota_all;
 LIST_HEAD(,epggrab_ota_mux) epggrab_ota_pending;
@@ -112,12 +113,12 @@ epggrab_ota_done ( epggrab_ota_mux_t *ota, int cancel, int timeout )
     gtimer_disarm(&epggrab_ota_active_timer);
     epggrab_ota_active_timer_cb(NULL);
   }
-  
-  /* Stop mux */
-  if (!cancel) {
-    extern const idclass_t mpegts_mux_class;
-    mpegts_mux_t *mm = mpegts_mux_find(ota->om_mux_uuid);
-    if (mm) mm->mm_stop(mm, ota, 0);
+
+  /* Remove subscription */
+  if (ota->om_sub) {
+    subscription_unsubscribe(ota->om_sub);
+    free(ota->om_sub);
+    ota->om_sub = NULL;
   }
 }
 
@@ -261,14 +262,15 @@ done:
 static void
 epggrab_ota_pending_timer_cb ( void *p )
 {
-  int r;
   epggrab_ota_map_t *map;
   epggrab_ota_mux_t *om = LIST_FIRST(&epggrab_ota_pending);
   mpegts_mux_t *mm;
+  th_subscription_t *s;
 
   lock_assert(&global_lock);
   if (!om)
     return;
+  assert(om->om_sub == NULL);
   
   /* Double check */
   if (om->om_when > dispatch_clock)
@@ -290,9 +292,11 @@ epggrab_ota_pending_timer_cb ( void *p )
   }
 
   /* Subscribe to the mux */
-  r = mm->mm_start(mm, om, "epggrab", 2); // TODO: remove hardcoded
-                                             // TODO: need to add src field
-  if (r) {
+  // TODO: remove hardcoded weight
+  s = subscription_create_from_mux(mm, 2, "epggrab", NULL,
+                                   SUBSCRIPTION_NONE, NULL, NULL, NULL);
+  if (s) {
+    om->om_sub  = s;
     om->om_when = dispatch_clock + epggrab_ota_period(om) / 2;
     LIST_INSERT_SORTED(&epggrab_ota_pending, om, om_q_link, om_time_cmp);
   } else {