{
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 */
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);
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 */
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);
}