]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP: another improvement for the close pid callback
authorJaroslav Kysela <perex@perex.cz>
Sun, 18 May 2014 19:40:34 +0000 (21:40 +0200)
committerJaroslav Kysela <perex@perex.cz>
Sun, 18 May 2014 19:40:34 +0000 (21:40 +0200)
src/input/mpegts/satip/satip_frontend.c

index 4fea22f463891009830d997822d12e30b7e6725c..1ba8df792be58e3c11997db621945285e8f0ce37 100644 (file)
@@ -551,21 +551,23 @@ satip_frontend_close_pid
 {
   satip_frontend_t *lfe = (satip_frontend_t*)mi;
   int change = 0;
-  int mid, div;
+  int mid, div, cnt;
 
   /* remove PID */
-  if (pid == MPEGTS_FULLMUX_PID && lfe->sf_device->sd_fullmux_ok) {
-    if (lfe->sf_pids_any) {
-      lfe->sf_pids_any = 0;
-      change = 1;
+  if (pid == MPEGTS_FULLMUX_PID) {
+    if (lfe->sf_device->sd_fullmux_ok) {
+      if (lfe->sf_pids_any) {
+        lfe->sf_pids_any = 0;
+        change = 1;
+      }
     }
     goto finish;
   }
 
   pthread_mutex_lock(&lfe->sf_dvr_lock);
   if (lfe->sf_pids) {
-    mid = div = lfe->sf_pids_count / 2;
-    while (1) {
+    mid = div = (cnt = lfe->sf_pids_count) / 2;
+    while (cnt > 0) {
       if (div > 1)
         div /= 2;
       if (lfe->sf_pids[mid] == pid) {
@@ -588,6 +590,7 @@ satip_frontend_close_pid
           break;
         mid -= div;
       }
+      cnt--;
     }
   }
   pthread_mutex_unlock(&lfe->sf_dvr_lock);