]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
make auto error counter reset a global option instead of IPTV-specific
authorTrujulu <trujulu@gmail.com>
Tue, 6 Jan 2026 16:24:23 +0000 (17:24 +0100)
committerFlole <Flole998@users.noreply.github.com>
Fri, 9 Jan 2026 23:39:35 +0000 (00:39 +0100)
src/config.c
src/config.h
src/input/mpegts/iptv/iptv.c
src/input/mpegts/mpegts_mux.c

index c11ef43de11ec4e4b8125b57e17be23feef28b33..3070b5fde8261ee8acfe03e7ad98dd851d9649bb 100644 (file)
@@ -2745,6 +2745,17 @@ const idclass_t config_class = {
       .opts   = PO_EXPERT,
       .group  = 8,
     },
+    {
+      .type   = PT_BOOL,
+      .id     = "auto_clear_input_counters",
+      .name   = N_("Automatically clear input error counters"),
+      .desc   = N_("Periodically resets input error counters "
+                   "(when a new mux starts for the target tuner). "
+                   "Note that previous counters will be lost."),
+      .off    = offsetof(config_t, auto_clear_input_counters),
+      .opts   = PO_EXPERT,
+      .group  = 8,
+    },
     {
       .type   = PT_STR,
       .id     = "muxconfpath",
index cc3afc46a8cf721c9031c82057d8acaf8020cd4f..898729372ea1e2276e3ecf5df8a93db0410b0ea3 100644 (file)
@@ -65,6 +65,7 @@ typedef struct config {
   uint32_t descrambler_buffer;
   int caclient_ui;
   int parser_backlog;
+  int auto_clear_input_counters;
   int epg_compress;
   uint32_t epg_cut_window;
   uint32_t epg_update_window;
index 0fe2949d8d932e2c088b5c9a429476de5561ba29..0a13ed4e4766bcc4d5ea8396b717d47d254c2cd5 100644 (file)
@@ -336,18 +336,10 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi, int weigh
   const char *scheme;
   url_t url;
 
-  /* Already active */
-  if (im->mm_active)
+  /* Active? */
+  if (im->mm_active) {
     return 0;
-
-  /* Reset Error Counters */
-  atomic_set(&mmi->tii_stats.unc, 0);
-  atomic_set(&mmi->tii_stats.cc, 0);
-  tvh_mutex_lock(&mmi->tii_stats_mutex);
-  mmi->tii_stats.te = 0;
-  mmi->tii_stats.ec_block = 0;
-  mmi->tii_stats.tc_block = 0;
-  tvh_mutex_unlock(&mmi->tii_stats_mutex);
+  }
   
   /* Substitute things */
   if (im->mm_iptv_substitute && raw) {
@@ -366,7 +358,7 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi, int weigh
 
   } else
 #endif
-         if (raw && !strncmp(raw, "pipe://", 7)) {
+  if (raw && !strncmp(raw, "pipe://", 7)) {
 
     scheme = "pipe";
 
@@ -399,8 +391,15 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi, int weigh
     return ret;
   }
 
-  /* Start */
   tvh_mutex_lock(&iptv_lock);
+  /* Already active */
+  if (im->mm_active) {
+    tvh_mutex_unlock(&iptv_lock);
+    urlreset(&url);
+    return 0;
+  }
+
+  /* Start */
   s = im->mm_iptv_url_raw;
   im->mm_iptv_url_raw = raw ? strdup(raw) : NULL;
   if (im->mm_iptv_url_raw) {
index 695910a6f96024739cd238dc447775cebd2739ef..bbe290bc7a3661de823e46464063efbd37f86bf2 100644 (file)
@@ -27,6 +27,7 @@
 #include "profile.h"
 #include "dvb_charset.h"
 #include "epggrab.h"
+#include "config.h"
 
 #include <assert.h>
 
@@ -269,6 +270,11 @@ mpegts_mux_instance_start
   mm->mm_start_monoclock = mclk();
   mi->mi_started_mux(mi, mmi);
 
+  /* Reset Error Counters */
+  if (config.auto_clear_input_counters && mmi->tii_clear_stats) {
+    mmi->tii_clear_stats((tvh_input_instance_t *)mmi);
+  }
+
   /* Event handler */
   mpegts_fire_event(mm, ml_mux_start);