cwc: cleanups and better debug logging

This commit is contained in:
xhaggi 2013-02-21 12:48:34 +01:00
parent 667e1c2bad
commit 14a470efd1

View file

@ -774,15 +774,10 @@ handle_ecm_reply(cwc_service_t *ct, ecm_section_t *es, uint8_t *msg,
char chaninfo[32];
int i;
int64_t delay = (getmonoclock() - es->es_time) / 1000LL; // in ms
if(es->es_channel != -1) {
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", es->es_channel);
} else {
chaninfo[0] = 0;
}
es->es_pending = 0;
snprintf(chaninfo, sizeof(chaninfo), " (PID %d)", es->es_channel);
if(len < 19) {
/* ERROR */
@ -845,9 +840,9 @@ forbid:
} else {
ct->cs_okchannel = es->es_channel;
tvhlog(LOG_DEBUG, "cwc", "es->es_nok %d, t->tht_prefcapid %d", es->es_nok, t->s_prefcapid);
if(es->es_nok == 1 || t->s_prefcapid == 0) {
t->s_prefcapid = ct->cs_okchannel;
tvhlog(LOG_DEBUG, "cwc", "Saving prefered PID %d", t->s_prefcapid);
service_request_save(t, 0);
}
es->es_nok = 0;
@ -897,7 +892,7 @@ forbid:
for(i = 0; i < 256; i++)
free(ep->ep_sections[i]);
LIST_REMOVE(ep, ep_link);
tvhlog(LOG_WARNING, "cwc", "Delete ECMpid %d", ep->ep_pid);
tvhlog(LOG_WARNING, "cwc", "Delete ECM (PID %d) for service \"%s\"", ep->ep_pid, t->s_svcname);
free(ep);
ep = epn;
}
@ -1637,14 +1632,14 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
if (ct->cs_okchannel == -2) {
t->s_prefcapid = 0;
ct->cs_okchannel = -1;
tvhlog(LOG_DEBUG, "cwc", "Insert after unexpected reply");
tvhlog(LOG_DEBUG, "cwc", "Reset after unexpected reply for service \"%s\"", t->s_svcname);
}
if (ct->cs_okchannel == -3 && t->s_prefcapid != 0) {
ep = calloc(1, sizeof(ecm_pid_t));
ep->ep_pid = t->s_prefcapid;
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
tvhlog(LOG_DEBUG, "cwc", "Insert only one new ECM channel %d for service id %d", t->s_prefcapid, sid);
tvhlog(LOG_DEBUG, "cwc", "Insert prefered ECM (PID %d) for service \"%s\"", t->s_prefcapid, t->s_svcname);
ct->cs_okchannel = -4;
}
@ -1652,7 +1647,7 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
ep = calloc(1, sizeof(ecm_pid_t));
ep->ep_pid = st->es_pid;
LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link);
tvhlog(LOG_DEBUG, "cwc", "Insert new ECM channel %d", st->es_pid);
tvhlog(LOG_DEBUG, "cwc", "Insert new ECM (PID %d) for service \"%s\"", st->es_pid, t->s_svcname);
}
else {
return;
@ -1677,19 +1672,15 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
/* ECM */
if(cwc->cwc_caid >> 8 == 6) {
channel = data[6] << 8 | data[7];
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", channel);
ep->ep_last_section = data[5];
section = data[4];
} else {
channel = -1;
chaninfo[0] = 0;
ep->ep_last_section = 0;
section = 0;
}
channel = st->es_pid;
snprintf(chaninfo, sizeof(chaninfo), " (channel %d)", channel);
snprintf(chaninfo, sizeof(chaninfo), " (PID %d)", channel);
if(ep->ep_sections[section] == NULL)
ep->ep_sections[section] = calloc(1, sizeof(ecm_section_t));
@ -1717,16 +1708,15 @@ cwc_table_input(struct th_descrambler *td, struct service *t,
if(ct->cs_okchannel >= 0 && channel != -1 &&
ct->cs_okchannel != channel) {
tvhlog(LOG_DEBUG, "cwc", "Filtering ECM channel %d", channel);
tvhlog(LOG_DEBUG, "cwc", "Filtering ECM (PID %d)", channel);
return;
}
es->es_seq = cwc_send_msg(cwc, data, len, sid, 1);
tvhlog(LOG_DEBUG, "cwc",
"Sending ECM%s section=%d/%d, for service %s (seqno: %d) PID %d",
chaninfo, section, ep->ep_last_section, t->s_svcname, es->es_seq,
st->es_pid);
"Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)",
chaninfo, section, ep->ep_last_section, t->s_svcname, es->es_seq);
es->es_time = getmonoclock();
break;