]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
correctly de-init muxer
authorAndreas Öman <andreas@lonelycoder.com>
Sat, 9 Feb 2008 11:14:39 +0000 (11:14 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Sat, 9 Feb 2008 11:14:39 +0000 (11:14 +0000)
mux.c
transports.c
tsmux.c

diff --git a/mux.c b/mux.c
index 0fc490163e0166d0dc969a213ca50352d092a1c5..d0a3abc6d8a761be87093e49aeb2f875bb63f586 100644 (file)
--- a/mux.c
+++ b/mux.c
@@ -64,8 +64,10 @@ muxer_play(th_muxer_t *tm, int64_t toffset)
 {
   th_subscription_t *s = tm->tm_subscription;
 
-  if(!tm->tm_linked)
+  if(!tm->tm_linked) {
     LIST_INSERT_HEAD(&s->ths_transport->tht_muxers, tm, tm_transport_link);
+    tm->tm_linked = 1;
+  }
 
   if(toffset == AV_NOPTS_VALUE) {
     /* continue from last playback */
@@ -197,7 +199,7 @@ muxer_deinit(th_muxer_t *tm, th_subscription_t *s)
   s->ths_muxer = NULL;
 
   if(tm->tm_linked)
-    LIST_INSERT_HEAD(&s->ths_transport->tht_muxers, tm, tm_transport_link);
+    LIST_REMOVE(tm, tm_transport_link);
 
   while((tms = LIST_FIRST(&tm->tm_streams)) != NULL)
     tms_destroy(tms);
index d853012f84d44dff7706265348f47b82834e62b2..0a94c262d28d66273e3aca69c7466f0babeaf9a9 100644 (file)
@@ -108,8 +108,10 @@ transport_stop(th_transport_t *t, int flush_subscriptions)
     st->st_buffer_ptr = 0;
     st->st_startcode = 0;
 
-    if(st->st_curpkt != NULL)
+    if(st->st_curpkt != NULL) {
       pkt_deref(st->st_curpkt);
+      st->st_curpkt = NULL;
+    }
 
     /* Clear PTS queue */
 
diff --git a/tsmux.c b/tsmux.c
index 2ef07ce2315a4f4eeb3c47287abbb3a5b1a2aeae..59543f854a53bd1dac4dbb412d150db8dba0f51e 100644 (file)
--- a/tsmux.c
+++ b/tsmux.c
@@ -696,9 +696,29 @@ ts_muxer_init(th_subscription_t *s, ts_mux_output_t *output,
 void 
 ts_muxer_deinit(ts_muxer_t *ts, th_subscription_t *s)
 {
-  free(ts->ts_packet);
-  muxer_deinit(ts->ts_muxer, s);
+  th_muxstream_t *tms;
+  th_muxer_t *tm = s->ths_muxer;
+  th_muxpkt_t *f;
+  th_refpkt_t *o;
+
   dtimer_disarm(&ts->ts_patpmt_timer);
+
+  LIST_FOREACH(tms, &tm->tm_streams, tms_muxer_link0) {
+    dtimer_disarm(&tms->tms_mux_timer);
+
+    /* Free mux packets */
+    while((f = tmf_deq(&tms->tms_delivery_fifo)) != NULL)
+      free(f);
+
+    /* Unreference lookahead queue */
+    while((o = TAILQ_FIRST(&tms->tms_lookahead)) != NULL) {
+      pkt_deref(o->trp_pkt);
+      TAILQ_REMOVE(&tms->tms_lookahead, o, trp_link);
+    }
+  }
+
+  free(ts->ts_packet);
+  muxer_deinit(tm, s);
   free(ts);
 }