]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
capmt linuxdvb: some minor tweaks to ensure only necessary are enabled
authorAdam Sutton <dev@adamsutton.me.uk>
Sat, 9 Nov 2013 13:15:21 +0000 (13:15 +0000)
committerAdam Sutton <dev@adamsutton.me.uk>
Sat, 9 Nov 2013 13:15:21 +0000 (13:15 +0000)
Only adapters that have active frontends will be enabled in capmt. In
addition to this I've also fixed code so it will actually honour the port
configuration (which was being ignored in OSCAM mode).

src/descrambler/capmt.c
src/input/mpegts/linuxdvb/linuxdvb_adapter.c
src/input/mpegts/linuxdvb/linuxdvb_private.h

index 0670319e7ebaa02a9ab13164b005b871c0720ac6..de54a3a609492eac07510a62964bfefa7d5737d7 100644 (file)
@@ -576,25 +576,24 @@ capmt_thread(void *aux)
 
       /* open connection to emulated ca0 device */
       if (!capmt->capmt_oscam) {
-        bind_ok = capmt_create_udp_socket(&capmt->capmt_sock_ca0[0], capmt->capmt_port);
+        bind_ok = capmt_create_udp_socket(&capmt->capmt_sock_ca0[0],
+                                          capmt->capmt_port);
       } else {
-        int i;
+        int i, n;
         extern const idclass_t linuxdvb_adapter_class;
         linuxdvb_adapter_t *la;
         idnode_set_t *is = idnode_find_all(&linuxdvb_adapter_class);
         for (i = 0; i < is->is_count; i++) {
           la = (linuxdvb_adapter_t*)is->is_array[i];
-#if TODO_FIXME
-          if (!la || !la->mi_is_enabled) continue;
-          if (!la->mi_is_enabled((mpegts_input_t*)la)) continue;
-#endif
-          if (la->la_dvb_number > MAX_CA) {
+         if (!la || !la->la_is_enabled(la)) continue;
+          n = la->la_dvb_number;
+          if (n < 0 || n > MAX_CA) {
             tvhlog(LOG_ERR, "capmt", "adapter number > MAX_CA");
             continue;
           }
-          tvhlog(LOG_INFO, "capmt", "Creating capmt UDP socket for adapter %d",
-                 la->la_dvb_number);
-          bind_ok = capmt_create_udp_socket(&capmt->capmt_sock_ca0[la->la_dvb_number], 9000 + la->la_dvb_number);
+          tvhlog(LOG_INFO, "capmt", "created UDP socket %d", n);
+          bind_ok = capmt_create_udp_socket(&capmt->capmt_sock_ca0[n],
+                                            capmt->capmt_port + n);
         }
       }
       if (bind_ok)
index 5b20fd145b6031411c5a77ab8cce221f9ba77366..959da4fae0fff25fcd33b5d8876a93c58efa11fa 100644 (file)
@@ -103,6 +103,20 @@ linuxdvb_adapter_save ( linuxdvb_adapter_t *la, htsmsg_t *m )
   htsmsg_add_msg(m, "frontends", l);
 }
 
+/*
+ * Check if enabled
+ */
+static int
+linuxdvb_adapter_is_enabled ( linuxdvb_adapter_t *la )
+{
+  linuxdvb_frontend_t *lfe;
+  LIST_FOREACH(lfe, &la->la_frontends, lfe_link) {
+    if (lfe->mi_is_enabled((mpegts_input_t*)lfe))
+      return 1;
+  }
+  return 0;
+}
+
 /*
  * Create
  */
@@ -124,6 +138,7 @@ linuxdvb_adapter_create0
   LIST_INSERT_HEAD(&ld->ld_adapters, la, la_link);
   la->la_device     = ld;
   la->la_dvb_number = -1;
+  la->la_is_enabled = linuxdvb_adapter_is_enabled;
 
   /* No conf */
   if (!conf)
index fa3450f022dc30f8c5a450496671f7d7abd88947..1e04039687b516abaad1f2a90e5c1801eb8f056c 100644 (file)
@@ -92,6 +92,11 @@ struct linuxdvb_adapter
    * Frontends
    */
   LIST_HEAD(,linuxdvb_frontend) la_frontends;
+
+  /*
+  * Functions
+  */
+  int (*la_is_enabled) ( linuxdvb_adapter_t *la );
 };
 
 struct linuxdvb_frontend