]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
SAT>IP: improve mux stop
authorJaroslav Kysela <perex@perex.cz>
Wed, 14 May 2014 07:31:18 +0000 (09:31 +0200)
committerJaroslav Kysela <perex@perex.cz>
Wed, 14 May 2014 07:31:18 +0000 (09:31 +0200)
src/input/mpegts/satip/satip_frontend.c
src/input/mpegts/satip/satip_private.h

index 5726f2ec1a019fb9e5f0581a9d13a22cacbe7f66..386e477e39ac59cfc58b88432b00177f1c1bbdf7 100644 (file)
@@ -390,12 +390,10 @@ satip_frontend_stop_mux
   mmi->mmi_mux->mm_display_name(mmi->mmi_mux, buf2, sizeof(buf2));
   tvhdebug("satip", "%s - stopping %s", buf1, buf2);
 
-  lfe->sf_running   = 0;
-  lfe->sf_mmi       = NULL;
-
   gtimer_disarm(&lfe->sf_monitor_timer);
 
   /* Stop thread */
+  lfe->sf_shutdown = 1;
   if (lfe->sf_dvr_pipe.wr > 0) {
     tvh_write(lfe->sf_dvr_pipe.wr, "", 1);
     tvhtrace("satip", "%s - waiting for dvr thread", buf1);
@@ -403,6 +401,10 @@ satip_frontend_stop_mux
     tvh_pipe_close(&lfe->sf_dvr_pipe);
     tvhdebug("satip", "%s - stopped dvr thread", buf1);
   }
+  lfe->sf_shutdown = 0;
+
+  lfe->sf_running  = 0;
+  lfe->sf_mmi      = NULL;
 
   udp_close(lfe->sf_rtp);   lfe->sf_rtp        = NULL;
   udp_close(lfe->sf_rtcp);  lfe->sf_rtcp       = NULL;
@@ -751,7 +753,7 @@ satip_frontend_pid_changed( http_client_t *rtsp,
   int deleted;
   int max_pids_len = lfe->sf_device->sd_pids_len;
 
-  if (!lfe->sf_running)
+  if (!lfe->sf_running || lfe->sf_shutdown)
     return;
 
   pthread_mutex_lock(&lfe->sf_dvr_lock);
@@ -1212,6 +1214,7 @@ satip_frontend_tune0
 
   assert(lfe->sf_pids == NULL);
   assert(lfe->sf_pids_tuned == NULL);
+
   lfe->sf_pids_count      = 0;
   lfe->sf_pids_tcount     = 0;
   lfe->sf_pids_size       = 512;
@@ -1221,20 +1224,20 @@ satip_frontend_tune0
   lfe->sf_pids_any_tuned  = 0;
   lfe->sf_status          = SIGNAL_NONE;
 
+  lfe->sf_mmi             = mmi;
+  lfe->sf_running         = 1;
+
   tvhtrace("satip", "%s - local RTP port %i RTCP port %i",
                     lfe->mi_name,
                     ntohs(IP_PORT(lfe->sf_rtp->ip)),
                     ntohs(IP_PORT(lfe->sf_rtcp->ip)));
 
-  lfe->sf_mmi = mmi;
-
   tvh_pipe(O_NONBLOCK, &lfe->sf_dvr_pipe);
   tvhthread_create(&lfe->sf_dvr_thread, NULL,
                    satip_frontend_input_thread, lfe, 0);
 
   gtimer_arm_ms(&lfe->sf_monitor_timer, satip_frontend_signal_cb, lfe, 250);
 
-  lfe->sf_running = 1;
   return 0;
 }
 
index 79df20b047d10a595c63d3f174650ef527488255..9972e7b8a36335b63eea3aa4d0b5bc265a35e30d 100644 (file)
@@ -120,6 +120,7 @@ struct satip_frontend
   int                        sf_pids_count;
   int                        sf_pids_tcount;     /*< tuned count */
   int                        sf_running;
+  int                        sf_shutdown;
   int                        sf_position;
   udp_connection_t          *sf_rtp;
   udp_connection_t          *sf_rtcp;