]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP: Do not mix the RTSP commands (PLAY - change pids)
authorJaroslav Kysela <perex@perex.cz>
Mon, 19 May 2014 19:42:09 +0000 (21:42 +0200)
committerJaroslav Kysela <perex@perex.cz>
Mon, 19 May 2014 19:43:04 +0000 (21:43 +0200)
src/input/mpegts/satip/satip_frontend.c

index 1ba8df792be58e3c11997db621945285e8f0ce37..5fe6aa9f425e5943d4fc6d3ace6a44464377a4f6 100644 (file)
@@ -777,7 +777,7 @@ satip_frontend_store_pids(char *buf, uint16_t *pids, int count)
   }
 }
 
-static void
+static int
 satip_frontend_pid_changed( http_client_t *rtsp,
                             satip_frontend_t *lfe, const char *name )
 {
@@ -787,7 +787,7 @@ satip_frontend_pid_changed( http_client_t *rtsp,
   int max_pids_len = lfe->sf_device->sd_pids_len;
 
   if (!lfe->sf_running || lfe->sf_shutdown)
-    return;
+    return 0;
 
   pthread_mutex_lock(&lfe->sf_dvr_lock);
 
@@ -798,7 +798,7 @@ satip_frontend_pid_changed( http_client_t *rtsp,
 
     if (lfe->sf_pids_any_tuned) {
       pthread_mutex_unlock(&lfe->sf_dvr_lock);
-      return;
+      return 0;
     }
     lfe->sf_pids_any_tuned = 1;
     memcpy(lfe->sf_pids_tuned, lfe->sf_pids,
@@ -807,6 +807,7 @@ satip_frontend_pid_changed( http_client_t *rtsp,
     pthread_mutex_unlock(&lfe->sf_dvr_lock);
 
     r = satip_rtsp_play(rtsp,  "all", NULL, NULL, max_pids_len);
+    r = r == 0 ? 1 : r;
 
   } else if (!lfe->sf_device->sd_pids_deladd ||
              lfe->sf_pids_any_tuned ||
@@ -827,6 +828,7 @@ satip_frontend_pid_changed( http_client_t *rtsp,
     pthread_mutex_unlock(&lfe->sf_dvr_lock);
 
     r = satip_rtsp_play(rtsp, add, NULL, NULL, max_pids_len);
+    r = r == 0 ? 1 : r;
 
   } else {
 
@@ -891,14 +893,16 @@ satip_frontend_pid_changed( http_client_t *rtsp,
     lfe->sf_pids_tcount = lfe->sf_pids_count;
     pthread_mutex_unlock(&lfe->sf_dvr_lock);
 
-    if (add[0] != '\0' || del[0] != '\0')
-      r = satip_rtsp_play(rtsp, NULL, add, del, max_pids_len);
-    else
-      r = 0;
+    if (add[0] == '\0' && del[0] == '\0')
+      return 0;
+
+    r = satip_rtsp_play(rtsp, NULL, add, del, max_pids_len);
+    r = r == 0 ? 1 : r;
   }
 
   if (r < 0)
     tvherror("satip", "%s - failed to modify pids: %s", name, strerror(-r));
+  return r;
 }
 
 static void *
@@ -1059,14 +1063,16 @@ satip_frontend_input_thread ( void *aux )
               }
               continue;
             } else {
-              satip_frontend_pid_changed(rtsp, lfe, buf);
+              if (satip_frontend_pid_changed(rtsp, lfe, buf) > 0)
+                continue;
             }
           }
           break;
         case RTSP_CMD_PLAY:
           if (rtsp->hc_code == 200 && play2) {
-            satip_frontend_pid_changed(rtsp, lfe, buf);
             play2 = 0;
+            if (satip_frontend_pid_changed(rtsp, lfe, buf) > 0)
+              continue;
           }
           /* fall thru */
         default: