Travers muxer list in a safe manner

This commit is contained in:
Andreas Öman 2008-05-04 15:52:49 +00:00
parent 0b35fe7342
commit 546dd71627

View file

@ -768,7 +768,7 @@ parser_compute_duration(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
static void
parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
{
th_muxer_t *tm;
th_muxer_t *tm, *next;
int64_t dts, pts, ptsoff;
assert(pkt->pkt_dts != AV_NOPTS_VALUE);
@ -821,10 +821,13 @@ parser_deliver(th_transport_t *t, th_stream_t *st, th_pkt_t *pkt)
avgstat_add(&st->st_rate, pkt->pkt_payloadlen, dispatch_clock);
/* Alert all muxers tied to us that a new packet has arrived */
LIST_FOREACH(tm, &t->tht_muxers, tm_transport_link)
/* Alert all muxers tied to us that a new packet has arrived.
Muxers may remove themself as a direct action of receiving a packet
(serviceprober), so we need to traverse in a safe manner */
for(tm = LIST_FIRST(&t->tht_muxers); tm != NULL; tm = next) {
next = LIST_NEXT(tm, tm_transport_link);
tm->tm_new_pkt(tm, st, pkt);
}
/* Unref (and possibly free) the packet, muxers are supposed
to increase refcount or copy packet if they need anything */