From 098a389db82a610047caac635cc482471b3bd9d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20=C3=96man?= Date: Sat, 11 Aug 2007 06:19:59 +0000 Subject: [PATCH] simplify --- transports.c | 76 +++++++++++++++++++++++++++------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) diff --git a/transports.c b/transports.c index 1ef21d45..c60760c0 100644 --- a/transports.c +++ b/transports.c @@ -320,50 +320,52 @@ transport_compute_weight(struct th_transport_list *head) void transport_recv_tsb(th_transport_t *t, int pid, uint8_t *tsb) { - pidinfo_t *pi; + pidinfo_t *pi = NULL; th_subscription_t *s; th_channel_t *ch; int i, cc, err = 0; for(i = 0; i < t->tht_npids; i++) { - - pi = t->tht_pids + i; - - if(pi->pid != pid) - continue; - - cc = tsb[3] & 0xf; - - if(tsb[3] & 0x10) { - if(pi->cc_valid && cc != pi->cc) { - /* Incorrect CC */ - avgstat_add(&t->tht_cc_errors, 1, dispatch_clock); - err = 1; - } - pi->cc_valid = 1; - pi->cc = (cc + 1) & 0xf; + if(t->tht_pids[i].pid == pid) { + pi = t->tht_pids + i; + break; } - - avgstat_add(&t->tht_rate, 188, dispatch_clock); - - ch = t->tht_channel; - - if(pi->type == HTSTV_TELETEXT) { - /* teletext */ - teletext_input(t, tsb); - continue; - } - - tsb[0] = pi->type; - - pthread_mutex_lock(&subscription_mutex); - - LIST_FOREACH(s, &t->tht_subscriptions, ths_transport_link) { - s->ths_total_err += err; - s->ths_callback(s, tsb, pi, i); - } - pthread_mutex_unlock(&subscription_mutex); } + + if(pi == NULL) + return; + + cc = tsb[3] & 0xf; + + if(tsb[3] & 0x10) { + if(pi->cc_valid && cc != pi->cc) { + /* Incorrect CC */ + avgstat_add(&t->tht_cc_errors, 1, dispatch_clock); + err = 1; + } + pi->cc_valid = 1; + pi->cc = (cc + 1) & 0xf; + } + + avgstat_add(&t->tht_rate, 188, dispatch_clock); + + ch = t->tht_channel; + + if(pi->type == HTSTV_TELETEXT) { + /* teletext */ + teletext_input(t, tsb); + return; + } + + tsb[0] = pi->type; + + pthread_mutex_lock(&subscription_mutex); + + LIST_FOREACH(s, &t->tht_subscriptions, ths_transport_link) { + s->ths_total_err += err; + s->ths_callback(s, tsb, pi, i); + } + pthread_mutex_unlock(&subscription_mutex); }