debug: convert all TRACE code to new tvhtrace routine

This commit is contained in:
Adam Sutton 2013-04-07 13:34:48 +01:00
parent bd592fb913
commit e7b220471d
7 changed files with 73 additions and 136 deletions

View file

@ -22,10 +22,8 @@ diseqc_send_msg(int fe_fd, __u8 framing_byte, __u8 address, __u8 cmd,
{
struct dvb_diseqc_master_cmd message;
#if DISEQC_TRACE
tvhlog(LOG_DEBUG, "diseqc", "sending %X %X %X %X %X %X",
framing_byte, address, cmd, data_1, data_2, data_3);
#endif
tvhtrace("diseqc", "sending %X %X %X %X %X %X",
framing_byte, address, cmd, data_1, data_2, data_3);
message.msg[0] = framing_byte;
message.msg[1] = address;
@ -45,11 +43,9 @@ diseqc_setup(int fe_fd, int lnb_num, int voltage, int band,
int j = lnb_num / 4;
int k, err;
#if DISEQC_TRACE
tvhlog(LOG_DEBUG, "diseqc",
"fe_fd %i, lnb_num %i, voltage %i, band %i, version %i, repeats %i",
fe_fd, lnb_num, voltage, band, version, repeats);
#endif
tvhtrace("diseqc",
"fe_fd %i, lnb_num %i, voltage %i, band %i, version %i, repeats %i",
fe_fd, lnb_num, voltage, band, version, repeats);
/* verify lnb number and diseqc data */
if(lnb_num < 0 || lnb_num >=64 || i < 0 || i >= 16 || j < 0 || j >= 16)

View file

@ -44,14 +44,6 @@
#include "cwc.h"
#include "tvhtime.h"
#if TDT_TRACE
#define TRACE(_pre, _fmt, ...)\
tvhlog(LOG_DEBUG, "tdt-"_pre, _fmt, __VA_ARGS__)
#else
#define TRACE(_pre, _fmt, ...) (void)0
#endif
/**
*
*/
@ -330,7 +322,7 @@ dvb_sdt_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
char provider[256];
char chname0[256], *chname;
uint8_t stype;
#if TDT_TRACE
#if ENABLE_TRACE
uint8_t running_status;
#endif
int l;
@ -355,7 +347,7 @@ dvb_sdt_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
break;
if (!tdmi) return -1;
}
TRACE("sdt", "onid %04X tsid %04X", onid, tsid);
tvhtrace("sdt", "onid %04X tsid %04X", onid, tsid);
// version = ptr[2] >> 1 & 0x1f;
// section_number = ptr[3];
@ -375,13 +367,13 @@ dvb_sdt_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
int save = 0;
service_id = ptr[0] << 8 | ptr[1];
// reserved = ptr[2];
#if TDT_TRACE
#if ENABLE_TRACE
running_status = (ptr[3] >> 5) & 0x7;
#endif
free_ca_mode = (ptr[3] >> 4) & 0x1;
dllen = ((ptr[3] & 0x0f) << 8) | ptr[4];
TRACE("sdt", " sid %04X running %d free_ca %d",
service_id, running_status, free_ca_mode);
tvhtrace("sdt", " sid %04X running %d free_ca %d",
service_id, running_status, free_ca_mode);
len -= 5;
ptr += 5;
@ -406,8 +398,8 @@ dvb_sdt_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
if(dvb_desc_service(ptr, dlen, &stype,
provider, sizeof(provider),
chname0, sizeof(chname0)) == 0) {
TRACE("sdt", " stype = %d, provider = %s, name = %s",
stype, provider, chname0);
tvhtrace("sdt", " stype = %d, provider = %s, name = %s",
stype, provider, chname0);
chname = chname0;
/* Some providers insert spaces.
Clean up that (both heading and trailing) */
@ -675,7 +667,7 @@ dvb_table_cable_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
return -1;
dmc.dmc_fe_params.frequency = freq * 100;
TRACE("nit", " dvb-c frequency %d", dmc.dmc_fe_params.frequency);
tvhtrace("nit", " dvb-c frequency %d", dmc.dmc_fe_params.frequency);
symrate =
bcdtoint(ptr[7]) * 100000 + bcdtoint(ptr[8]) * 1000 +
@ -719,7 +711,7 @@ dvb_table_sat_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
bcdtoint(ptr[0]) * 1000000 + bcdtoint(ptr[1]) * 10000 +
bcdtoint(ptr[2]) * 100 + bcdtoint(ptr[3]);
dmc.dmc_fe_params.frequency = freq * 10;
TRACE("nit", " dvb-s frequency %d", dmc.dmc_fe_params.frequency);
tvhtrace("nit", " dvb-s frequency %d", dmc.dmc_fe_params.frequency);
if(!freq)
return -1;
@ -807,7 +799,7 @@ dvb_table_terr_delivery(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
return -1;
dmc.dmc_fe_params.frequency = freq;
TRACE("nit", " dvb-t frequency %d", dmc.dmc_fe_params.frequency);
tvhtrace("nit", " dvb-t frequency %d", dmc.dmc_fe_params.frequency);
dmc.dmc_fe_params.u.ofdm.bandwidth = bandwidth_tab[(ptr[4] & 0xe0) >> 5];
dmc.dmc_fe_params.u.ofdm.constellation=constellation_tab[(ptr[5] & 0xc0) >> 6];
dmc.dmc_fe_params.u.ofdm.hierarchy_information=hierarchy_info_tab[(ptr[5] & 0x38) >> 3];
@ -878,10 +870,7 @@ dvb_nit_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
uint16_t network_id = (ptr[0] << 8) | ptr[1];
netname[0] = '\0';
TRACE("nit", "tableid 0x%02x", tableid);
#if TDT_TRACE
hexdump("nit", ptr, len);
#endif
tvhtrace("nit", "tableid 0x%02x", tableid);
/* Check NID */
if(tdmi->tdmi_adapter->tda_nitoid &&
@ -903,7 +892,7 @@ dvb_nit_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
dtag = ptr[0];
dlen = ptr[1];
TRACE("nit", "dtag %02X dlen %d", dtag, dlen);
tvhtrace("nit", "dtag %02X dlen %d", dtag, dlen);
switch(dtag) {
case DVB_DESC_NETWORK_NAME:
@ -917,7 +906,7 @@ dvb_nit_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
ptr += dlen + 2;
llen -= dlen + 2;
}
TRACE("nit", "network %d/%s", network_id, netname);
tvhtrace("nit", "network %d/%s", network_id, netname);
if (llen)
return -1;
@ -932,7 +921,7 @@ dvb_nit_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
onid = ( ptr[2] << 8) | ptr[3];
llen = ((ptr[4] & 0xf) << 8) | ptr[5];
TRACE("nit", " onid %04X tsid %04X", onid, tsid);
tvhtrace("nit", " onid %04X tsid %04X", onid, tsid);
ptr += 6;
len -= llen + 6;
@ -943,7 +932,7 @@ dvb_nit_callback(th_dvb_mux_instance_t *tdmi, uint8_t *ptr, int len,
dtag = ptr[0];
dlen = ptr[1];
TRACE("nit", " dtag %02X dlen %d", dtag, dlen);
tvhtrace("nit", " dtag %02X dlen %d", dtag, dlen);
switch(dtag) {
case DVB_DESC_SAT:

View file

@ -126,10 +126,8 @@ static void _epg_object_destroy
( epg_object_t *eo, epg_object_tree_t *tree )
{
assert(eo->refcount == 0);
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] destroy",
eo, eo->id, eo->type, eo->uri);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] destroy",
eo, eo->id, eo->type, eo->uri);
if (eo->uri) free(eo->uri);
if (tree) RB_REMOVE(tree, eo, uri_link);
if (eo->_updated) LIST_REMOVE(eo, up_link);
@ -139,10 +137,8 @@ static void _epg_object_destroy
static void _epg_object_getref ( void *o )
{
epg_object_t *eo = o;
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] getref %d",
eo, eo->id, eo->type, eo->uri, eo->refcount+1);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] getref %d",
eo, eo->id, eo->type, eo->uri, eo->refcount+1);
if (eo->refcount == 0) LIST_REMOVE(eo, un_link);
eo->refcount++;
}
@ -150,10 +146,8 @@ static void _epg_object_getref ( void *o )
static void _epg_object_putref ( void *o )
{
epg_object_t *eo = o;
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] putref %d",
eo, eo->id, eo->type, eo->uri, eo->refcount-1);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] putref %d",
eo, eo->id, eo->type, eo->uri, eo->refcount-1);
assert(eo->refcount>0);
eo->refcount--;
if (!eo->refcount) eo->destroy(eo);
@ -163,10 +157,8 @@ static void _epg_object_set_updated ( void *o )
{
epg_object_t *eo = o;
if (!eo->_updated) {
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] updated",
eo, eo->id, eo->type, eo->uri);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] updated",
eo, eo->id, eo->type, eo->uri);
eo->_updated = 1;
eo->updated = dispatch_clock;
LIST_INSERT_HEAD(&epg_object_updated, eo, up_link);
@ -180,10 +172,8 @@ static void _epg_object_create ( void *o )
else if (eo->id > _epg_object_idx) _epg_object_idx = eo->id;
if (!eo->getref) eo->getref = _epg_object_getref;
if (!eo->putref) eo->putref = _epg_object_putref;
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] created",
eo, eo->id, eo->type, eo->uri);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] created",
eo, eo->id, eo->type, eo->uri);
_epg_object_set_updated(eo);
LIST_INSERT_HEAD(&epg_object_unref, eo, un_link);
LIST_INSERT_HEAD(&epg_objects[eo->id & EPG_HASH_MASK], eo, id_link);
@ -231,10 +221,8 @@ epg_object_t *epg_object_find_by_id ( uint32_t id, epg_object_type_t type )
static htsmsg_t * _epg_object_serialize ( void *o )
{
epg_object_t *eo = o;
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] serialize",
eo, eo->id, eo->type, eo->uri);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] serialize",
eo, eo->id, eo->type, eo->uri);
htsmsg_t *m;
if ( !eo->id || !eo->type ) return NULL;
m = htsmsg_create_map();
@ -263,10 +251,8 @@ static epg_object_t *_epg_object_deserialize ( htsmsg_t *m, epg_object_t *eo )
_epg_object_set_updated(eo);
eo->updated = s64;
}
#ifdef EPG_TRACE
tvhlog(LOG_DEBUG, "epg", "eo [%p, %u, %d, %s] deserialize",
eo, eo->id, eo->type, eo->uri);
#endif
tvhtrace("epg", "eo [%p, %u, %d, %s] deserialize",
eo, eo->id, eo->type, eo->uri);
return eo;
}

View file

@ -533,10 +533,8 @@ static int _eit_process_event
/* Find broadcast */
ebc = epg_broadcast_find_by_time(svc->s_ch, start, stop, eid, 1, &save2);
#ifdef EPG_EIT_TRACE
tvhlog(LOG_DEBUG, mod->id, "eid=%5d, start=%lu, stop=%lu, ebc=%p",
tvhtrace("eit", "eid=%5d, start=%lu, stop=%lu, ebc=%p",
eid, start, stop, ebc);
#endif
if (!ebc) return dllen + 12;
/* Mark re-schedule detect (only now/next) */
@ -698,20 +696,17 @@ static int _eit_callback
lst = ptr[4];
seg = ptr[9];
ver = (ptr[2] >> 1) & 0x1f;
#ifdef EPG_EIT_TRACE
tvhlog(LOG_DEBUG, mod->id,
"tid=0x%02X, onid=0x%04X, tsid=0x%04X, sid=0x%04X, sec=%3d/%3d, seg=%3d, ver=%2d, cur=%d",
tableid, onid, tsid, sid, sec, lst, seg, ver, ptr[2] & 1);
#endif
tvhtrace("eit",
"tid=0x%02X, onid=0x%04X, tsid=0x%04X, sid=0x%04X"
", sec=%3d/%3d, seg=%3d, ver=%2d, cur=%d",
tableid, onid, tsid, sid, sec, lst, seg, ver, ptr[2] & 1);
/* Don't process */
if((ptr[2] & 1) == 0) return 0;
/* Current status */
tsta = eit_status_find(sta, tableid, onid, tsid, sid, sec, lst, seg, ver);
#ifdef EPG_EIT_TRACE
tvhlog(LOG_DEBUG, mod->id, tsta && tsta->state != EIT_STATUS_DONE ? "section process" : "section seen");
#endif
tvhtrace("eit", tsta && tsta->state != EIT_STATUS_DONE ? "section process" : "section seen");
if (!tsta) return 0; // already seen, no state change
if (tsta->state == EIT_STATUS_DONE) goto done;
@ -724,12 +719,10 @@ static int _eit_callback
} else {
if (tdmi->tdmi_transport_stream_id != tsid ||
tdmi->tdmi_network_id != onid) {
#ifdef EPG_EIT_TRACE
tvhlog(LOG_DEBUG, mod->id,
"invalid transport id found tid 0x%02X, onid:tsid %d:%d != %d:%d",
tableid, tdmi->tdmi_network_id, tdmi->tdmi_transport_stream_id,
onid, tsid);
#endif
tvhtrace("eit",
"invalid tsid found tid 0x%02X, onid:tsid %d:%d != %d:%d",
tableid, tdmi->tdmi_network_id, tdmi->tdmi_transport_stream_id,
onid, tsid);
tdmi = NULL;
}
}
@ -773,7 +766,7 @@ done:
if (!tsta) epggrab_ota_complete(ota);
}
}
#ifdef EPG_EIT_TRACE
#if ENABLE_TRACE
if (ota->state != EPGGRAB_OTA_MUX_COMPLETE)
{
int total = 0;
@ -781,16 +774,17 @@ done:
tvhlog(LOG_DEBUG, mod->id, "scan status");
LIST_FOREACH(tsta, &sta->tables, link) {
total++;
tvhlog(LOG_DEBUG, mod->id,
" tid=0x%02X, onid=0x%04X, tsid=0x%04X, sid=0x%04X, ver=%02d, done=%d, "
"mask=%08X|%08X|%08X|%08X|%08X|%08X|%08X|%08X",
tsta->tid, tsta->onid, tsta->tsid, tsta->sid, tsta->ver,
tsta->state == EIT_STATUS_DONE,
tsta->sec[7], tsta->sec[6], tsta->sec[5], tsta->sec[4],
tsta->sec[3], tsta->sec[2], tsta->sec[1], tsta->sec[0]);
tvhtrace("eit",
" tid=0x%02X, onid=0x%04X, tsid=0x%04X, sid=0x%04X, ver=%02d"
", done=%d, "
"mask=%08X|%08X|%08X|%08X|%08X|%08X|%08X|%08X",
tsta->tid, tsta->onid, tsta->tsid, tsta->sid, tsta->ver,
tsta->state == EIT_STATUS_DONE,
tsta->sec[7], tsta->sec[6], tsta->sec[5], tsta->sec[4],
tsta->sec[3], tsta->sec[2], tsta->sec[1], tsta->sec[0]);
if (tsta->state == EIT_STATUS_DONE) finished++;
}
tvhlog(LOG_DEBUG, mod->id, " completed %d of %d", finished, total);
tvhtrace("eit", " completed %d of %d", finished, total);
}
#endif

View file

@ -64,9 +64,7 @@ static void* timeshift_reaper_callback ( void *p )
TAILQ_REMOVE(&timeshift_reaper_list, tsf, link);
pthread_mutex_unlock(&timeshift_reaper_lock);
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "remove file %s", tsf->path);
#endif
tvhtrace("timeshift", "remove file %s", tsf->path);
/* Remove */
unlink(tsf->path);
@ -91,17 +89,13 @@ static void* timeshift_reaper_callback ( void *p )
free(tsf);
}
pthread_mutex_unlock(&timeshift_reaper_lock);
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "reaper thread exit");
#endif
tvhtrace("timeshift", "reaper thread exit");
return NULL;
}
static void timeshift_reaper_remove ( timeshift_file_t *tsf )
{
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "queue file for removal %s", tsf->path);
#endif
tvhtrace("timeshift", "queue file for removal %s", tsf->path);
pthread_mutex_lock(&timeshift_reaper_lock);
TAILQ_INSERT_TAIL(&timeshift_reaper_list, tsf, link);
pthread_cond_signal(&timeshift_reaper_cond);
@ -252,9 +246,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
/* Create File */
snprintf(path, sizeof(path), "%s/tvh-%"PRItime_t, ts->path, time);
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d create file %s", ts->id, path);
#endif
tvhtrace("timeshift", "ts %d create file %s", ts->id, path);
if ((fd = open(path, O_WRONLY | O_CREAT, 0600)) > 0) {
tsf_tmp = calloc(1, sizeof(timeshift_file_t));
tsf_tmp->time = time;
@ -268,10 +260,8 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int create )
/* Copy across last start message */
if (tsf_tl && (ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list))) {
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d copy smt_start to new file",
ts->id);
#endif
tvhtrace("timeshift", "ts %d copy smt_start to new file",
ts->id);
timeshift_index_data_t *ti2 = calloc(1, sizeof(timeshift_index_data_t));
ti2->data = streaming_msg_clone(ti->data);
TAILQ_INSERT_TAIL(&tsf_tmp->sstart, ti2, link);

View file

@ -30,8 +30,6 @@
#include <string.h>
#include <assert.h>
//#define TSHFT_TRACE
/* **************************************************************************
* File Reading
* *************************************************************************/
@ -316,15 +314,11 @@ static int _timeshift_read
/* Open file */
if (*fd == -1) {
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d open file %s",
ts->id, (*cur_file)->path);
#endif
tvhtrace("timeshift", "ts %d open file %s",
ts->id, (*cur_file)->path);
*fd = open((*cur_file)->path, O_RDONLY);
}
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d seek to %lu", ts->id, *cur_off);
#endif
tvhtrace("timeshift", "ts %d seek to %lu", ts->id, *cur_off);
lseek(*fd, *cur_off, SEEK_SET);
/* Read msg */
@ -335,10 +329,8 @@ static int _timeshift_read
tvhlog(LOG_ERR, "timeshift", "ts %d could not read buffer", ts->id);
return -1;
}
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d read msg %p (%ld)",
ts->id, *sm, r);
#endif
tvhtrace("timeshift", "ts %d read msg %p (%ld)",
ts->id, *sm, r);
/* Incomplete */
if (r == 0) {
@ -451,9 +443,7 @@ void *timeshift_reader ( void *p )
/* Exit */
if (ctrl->sm_type == SMT_EXIT) {
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d read exit request", ts->id);
#endif
tvhtrace("timeshift", "ts %d read exit request", ts->id);
run = 0;
streaming_msg_free(ctrl);
ctrl = NULL;
@ -734,7 +724,7 @@ void *timeshift_reader ( void *p )
(((cur_speed < 0) && (sm->sm_time >= deliver)) ||
((cur_speed > 0) && (sm->sm_time <= deliver))))) {
#ifndef TSHFT_TRACE
#if (!ENABLE_TRACE)
if (skip)
#endif
{
@ -742,7 +732,7 @@ void *timeshift_reader ( void *p )
int64_t delta = now - sm->sm_time;
if (sm->sm_type == SMT_PACKET)
pts = ((th_pkt_t*)sm->sm_data)->pkt_pts;
tvhlog(LOG_DEBUG, "timeshift", "ts %d deliver %"PRId64" pts=%"PRItime_t " shift=%"PRIu64,
tvhtrace("timeshift", "ts %d deliver %"PRId64" pts=%"PRItime_t " shift=%"PRIu64,
ts->id, sm->sm_time, pts, delta);
}
streaming_target_deliver2(ts->output, sm);
@ -755,10 +745,8 @@ void *timeshift_reader ( void *p )
else
wait = (deliver - sm->sm_time) / 1000;
if (wait == 0) wait = 1;
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d wait %d",
ts->id, wait);
#endif
tvhtrace("timeshift", "ts %d wait %d",
ts->id, wait);
}
/* Terminate */
@ -818,9 +806,7 @@ void *timeshift_reader ( void *p )
if (fd != -1) close(fd);
if (sm) streaming_msg_free(sm);
if (ctrl) streaming_msg_free(ctrl);
#ifdef TSHFT_TRACE
tvhlog(LOG_DEBUG, "timeshift", "ts %d exit reader thread", ts->id);
#endif
tvhtrace("timeshift", "ts %d exit reader thread", ts->id);
return NULL;
}

View file

@ -82,10 +82,8 @@ tvhtime_update ( struct tm *tm )
ntp_shm_t *ntp_shm;
int64_t t1, t2;
#if TIME_TRACE
tvhlog(LOG_DEBUG, "time", "current time is %04d/%02d/%02d %02d:%02d:%02d",
tvhtrace("time", "current time is %04d/%02d/%02d %02d:%02d:%02d",
tm->tm_year+1900, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
#endif
/* Current and reported time */
now = mktime(tm);
@ -108,9 +106,7 @@ tvhtime_update ( struct tm *tm )
if (!(ntp_shm = ntp_shm_init()))
return;
#if TIME_TRACE
tvhlog(LOG_DEBUG, "time", "ntp delta = %"PRId64" us\n", t2 - t1);
#endif
tvhtrace("time", "ntp delta = %"PRId64" us\n", t2 - t1);
ntp_shm->valid = 0;
ntp_shm->count++;
ntp_shm->clockTimeStampSec = now;