From: Jaroslav Kysela Date: Tue, 16 Aug 2016 17:59:35 +0000 (+0200) Subject: tvhlog: change subsys from string to int and more cleanups X-Git-Tag: v4.2.1~378 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad1255d516c195b1f20432375eaf23f58e5d7daa;p=thirdparty%2Ftvheadend.git tvhlog: change subsys from string to int and more cleanups --- diff --git a/src/access.c b/src/access.c index 54cfab266..12072747e 100644 --- a/src/access.c +++ b/src/access.c @@ -492,7 +492,7 @@ access_dump_a(access_t *a) tvh_strlcatf(buf, sizeof(buf), l, ", tag=ANY"); } - tvhtrace("access", "%s", buf); + tvhtrace(LS_ACCESS, "%s", buf); } /* @@ -995,7 +995,7 @@ access_entry_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&ae->ae_id, uuid, &access_entry_class, 0)) { if (uuid) - tvherror("access", "invalid uuid '%s'", uuid); + tvherror(LS_ACCESS, "invalid uuid '%s'", uuid); free(ae); return NULL; } @@ -1700,7 +1700,7 @@ passwd_entry_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&pw->pw_id, uuid, &passwd_entry_class, 0)) { if (uuid) - tvherror("access", "invalid uuid '%s'", uuid); + tvherror(LS_ACCESS, "invalid uuid '%s'", uuid); free(pw); return NULL; } @@ -1887,7 +1887,7 @@ ipblock_entry_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&ib->ib_id, uuid, &ipblock_entry_class, 0)) { if (uuid) - tvherror("access", "invalid uuid '%s'", uuid); + tvherror(LS_ACCESS, "invalid uuid '%s'", uuid); free(ib); return NULL; } @@ -2012,7 +2012,7 @@ access_init(int createdefault, int noacl) access_noacl = noacl; if (noacl) - tvhlog(LOG_WARNING, "access", "Access control checking disabled"); + tvhwarn(LS_ACCESS, "Access control checking disabled"); TAILQ_INIT(&access_entries); TAILQ_INIT(&access_tickets); @@ -2073,12 +2073,11 @@ access_init(int createdefault, int noacl) idnode_changed(&ae->ae_id); - tvhlog(LOG_WARNING, "access", - "Created default wide open access controle entry"); + tvhwarn(LS_ACCESS, "Created default wide open access controle entry"); } if(!TAILQ_FIRST(&access_entries) && !noacl) - tvherror("access", "No access entries loaded"); + tvherror(LS_ACCESS, "No access entries loaded"); /* Load superuser account */ diff --git a/src/api.c b/src/api.c index 41b4ba07b..50d857d1b 100644 --- a/src/api.c +++ b/src/api.c @@ -45,7 +45,7 @@ api_register ( const api_hook_t *hook ) api_skel->hook = hook; t = RB_INSERT_SORTED(&api_hook_tree, api_skel, link, ah_cmp); if (t) { - tvherror("api", "trying to re-register subsystem"); + tvherror(LS_API, "trying to re-register subsystem"); } else { SKEL_USED(api_skel); } @@ -80,7 +80,7 @@ api_exec ( access_t *perm, const char *subsystem, ah = RB_FIND(&api_hook_tree, &skel, link, ah_cmp); if (!ah) { - tvhwarn("api", "failed to find subsystem [%s]", subsystem); + tvhwarn(LS_API, "failed to find subsystem [%s]", subsystem); return ENOSYS; // TODO: is this really the right error code? } diff --git a/src/api/api_input.c b/src/api/api_input.c index 9e0c473c0..7a173ea11 100644 --- a/src/api/api_input.c +++ b/src/api/api_input.c @@ -46,7 +46,7 @@ api_input_satip_discover if (op == NULL || strcmp(op, "all")) return -EINVAL; - tvhinfo("satip", "Triggered new server discovery"); + tvhinfo(LS_SATIP, "Triggered new server discovery"); pthread_mutex_lock(&global_lock); satip_device_discovery_start(); diff --git a/src/api/api_mpegts.c b/src/api/api_mpegts.c index cfd684fb3..7c64c6008 100644 --- a/src/api/api_mpegts.c +++ b/src/api/api_mpegts.c @@ -50,8 +50,6 @@ api_mpegts_input_network_list if (!mi) goto exit; - tvhtrace("mpegts", "network-list: found input '%s'", mi->mi_name ?: ""); - htsmsg_t *l = htsmsg_create_list(); if ((is = mi->mi_network_list(mi))) { for (i = 0; i < is->is_count; i++) { diff --git a/src/avahi.c b/src/avahi.c index 467e665ef..d21bda9a0 100644 --- a/src/avahi.c +++ b/src/avahi.c @@ -74,8 +74,7 @@ entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, switch (state) { case AVAHI_ENTRY_GROUP_ESTABLISHED : /* The entry group has been established successfully */ - tvhlog(LOG_INFO, "AVAHI", - "Service '%s' successfully established.", name); + tvhoinfo(LS_AVAHI, "Service '%s' successfully established.", name); break; case AVAHI_ENTRY_GROUP_COLLISION : { @@ -87,8 +86,7 @@ entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, avahi_free(name); name = n; - tvhlog(LOG_ERR, "AVAHI", - "Service name collision, renaming service to '%s'", name); + tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name); /* And recreate the services */ create_services(avahi_entry_group_get_client(g)); @@ -96,9 +94,9 @@ entry_group_callback(AvahiEntryGroup *g, AvahiEntryGroupState state, } case AVAHI_ENTRY_GROUP_FAILURE : - tvhlog(LOG_ERR, "AVAHI", - "Entry group failure: %s", - avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g)))); + tvherror(LS_AVAHI, + "Entry group failure: %s", + avahi_strerror(avahi_client_errno(avahi_entry_group_get_client(g)))); break; case AVAHI_ENTRY_GROUP_UNCOMMITED: @@ -124,9 +122,9 @@ create_services(AvahiClient *c) if (!group) if (!(group = avahi_entry_group_new(c, entry_group_callback, NULL))) { - tvhlog(LOG_ERR, "AVAHI", - "avahi_enty_group_new() failed: %s", - avahi_strerror(avahi_client_errno(c))); + tvherror(LS_AVAHI, + "avahi_enty_group_new() failed: %s", + avahi_strerror(avahi_client_errno(c))); goto fail; } @@ -134,7 +132,7 @@ create_services(AvahiClient *c) * because it was reset previously, add our entries. */ if (avahi_entry_group_is_empty(group)) { - tvhlog(LOG_DEBUG, "AVAHI", "Adding service '%s'", name); + tvhdebug(LS_AVAHI, "Adding service '%s'", name); /* Add the service for HTSP */ if ((ret = avahi_entry_group_add_service(group, AVAHI_IF_UNSPEC, @@ -145,9 +143,9 @@ create_services(AvahiClient *c) if (ret == AVAHI_ERR_COLLISION) goto collision; - tvhlog(LOG_ERR, "AVAHI", - "Failed to add _htsp._tcp service: %s", - avahi_strerror(ret)); + tvherror(LS_AVAHI, + "Failed to add _htsp._tcp service: %s", + avahi_strerror(ret)); goto fail; } @@ -168,17 +166,17 @@ create_services(AvahiClient *c) if (ret == AVAHI_ERR_COLLISION) goto collision; - tvhlog(LOG_ERR, "AVAHI", - "Failed to add _http._tcp service: %s", - avahi_strerror(ret)); + tvherror(LS_AVAHI, + "Failed to add _http._tcp service: %s", + avahi_strerror(ret)); goto fail; } /* Tell the server to register the service */ if ((ret = avahi_entry_group_commit(group)) < 0) { - tvhlog(LOG_ERR, "AVAHI", - "Failed to commit entry group: %s", - avahi_strerror(ret)); + tvherror(LS_AVAHI, + "Failed to commit entry group: %s", + avahi_strerror(ret)); goto fail; } } @@ -194,8 +192,7 @@ create_services(AvahiClient *c) avahi_free(name); name = n; - tvhlog(LOG_ERR, "AVAHI", - "Service name collision, renaming service to '%s'", name); + tvherror(LS_AVAHI, "Service name collision, renaming service to '%s'", name); avahi_entry_group_reset(group); @@ -226,8 +223,7 @@ client_callback(AvahiClient *c, AvahiClientState state, void *userdata) break; case AVAHI_CLIENT_FAILURE: - tvhlog(LOG_ERR, "AVAHI", "Client failure: %s", - avahi_strerror(avahi_client_errno(c))); + tvherror(LS_AVAHI, "Client failure: %s", avahi_strerror(avahi_client_errno(c))); break; case AVAHI_CLIENT_S_COLLISION: @@ -271,7 +267,7 @@ avahi_thread(void *aux) avahi_poll = avahi_simple_poll_get(avahi_asp); if(avahi_do_restart) { - tvhlog(LOG_INFO, "AVAHI", "Service restarted."); + tvhinfo(LS_AVAHI, "Service restarted."); avahi_do_restart = 0; group = NULL; } diff --git a/src/bonjour.c b/src/bonjour.c index 423decfa6..5e4eb0f50 100644 --- a/src/bonjour.c +++ b/src/bonjour.c @@ -37,8 +37,8 @@ static void bonjour_callback(CFNetServiceRef theService, CFStreamError* error, void* info) { if (error->error) { - tvhlog(LOG_ERR, "bonjour", "callback error (domain = %ld, error =%d)", - error->domain, error->error); + tvherror(LS_BONJOUR, "callback error (domain = %ld, error =%d)", + error->domain, error->error); } } @@ -56,7 +56,7 @@ bonjour_start_service(CFNetServiceRef *svc, char *service_type, *svc = CFNetServiceCreate(NULL, CFSTR(""), str, CFSTR("Tvheadend"), port); if (!*svc) { - tvhlog(LOG_ERR, "bonjour", "service creation failed"); + tvherror(LS_BONJOUR, "service creation failed"); return; } @@ -84,11 +84,11 @@ bonjour_start_service(CFNetServiceRef *svc, char *service_type, } if (!CFNetServiceRegisterWithOptions(*svc, 0, &error)) - tvhlog(LOG_ERR, "bonjour", "registration failed (service type = %s, " - "domain = %ld, error =%d)", service_type, error.domain, error.error); + tvherror(LS_BONJOUR, "registration failed (service type = %s, " + "domain = %ld, error =%d)", service_type, error.domain, error.error); else - tvhlog(LOG_INFO, "bonjour", "service '%s' successfully established", - service_type); + tvherror(LS_BONJOUR, "service '%s' successfully established", + service_type); } static void diff --git a/src/bouquet.c b/src/bouquet.c index 8fcf266ca..0f278f7d9 100644 --- a/src/bouquet.c +++ b/src/bouquet.c @@ -98,7 +98,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf, if (idnode_insert(&bq->bq_id, uuid, &bouquet_class, 0)) { if (uuid) - tvherror("bouquet", "invalid uuid '%s'", uuid); + tvherror(LS_BOUQUET, "invalid uuid '%s'", uuid); bouquet_free(bq); return NULL; } @@ -131,7 +131,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf, bq->bq_src = strdup(buf); bq->bq_download = bqd = calloc(1, sizeof(*bqd)); bqd->bq = bq; - download_init(&bqd->download, "bouquet"); + download_init(&bqd->download, LS_BOUQUET); bqd->download.process = bouquet_download_process; bqd->download.stop = bouquet_download_stop; bouquet_change_comment(bq, bq->bq_ext_url, 0); @@ -140,7 +140,7 @@ bouquet_create(const char *uuid, htsmsg_t *conf, bq2 = RB_INSERT_SORTED(&bouquets, bq, bq_link, _bq_cmp); if (bq2) { - tvherror("bouquet", "found duplicate source id: '%s', remove duplicate config", bq->bq_src); + tvherror(LS_BOUQUET, "found duplicate source id: '%s', remove duplicate config", bq->bq_src); bouquet_free(bq); return NULL; } @@ -219,7 +219,7 @@ bouquet_find_by_source(const char *name, const char *src, int create) bq = RB_FIND(&bouquets, &bqs, bq_link, _bq_cmp); if (bq) { if (name && *name && bq->bq_name && strcmp(name, bq->bq_name)) { - tvhwarn("bouquet", "bouquet name '%s' changed to '%s'", bq->bq_name ?: "", name); + tvhwarn(LS_BOUQUET, "bouquet name '%s' changed to '%s'", bq->bq_name ?: "", name); free(bq->bq_name); bq->bq_name = strdup(name); idnode_changed(&bq->bq_id); @@ -228,7 +228,7 @@ bouquet_find_by_source(const char *name, const char *src, int create) } if (create && name) { bq = bouquet_create(NULL, NULL, name, src); - tvhinfo("bouquet", "new bouquet '%s'", name); + tvhinfo(LS_BOUQUET, "new bouquet '%s'", name); return bq; } return NULL; @@ -337,7 +337,7 @@ bouquet_add_service(bouquet_t *bq, service_t *s, uint64_t lcn, const char *tag) return; if (!idnode_set_exists(bq->bq_services, &s->s_id)) { - tvhtrace("bouquet", "add service %s to %s", s->s_nicename, bq->bq_name ?: ""); + tvhtrace(LS_BOUQUET, "add service %s to %s", s->s_nicename, bq->bq_name ?: ""); idnode_set_add(bq->bq_services, &s->s_id, NULL, NULL); bq->bq_saveflag = 1; } @@ -388,7 +388,7 @@ bouquet_unmap_channel(bouquet_t *bq, service_t *t) while (ilm) { ilm_next = LIST_NEXT(ilm, ilm_in1_link); if (((channel_t *)ilm->ilm_in2)->ch_bouquet == bq) { - tvhinfo("bouquet", "%s / %s: unmapped from %s", + tvhinfo(LS_BOUQUET, "%s / %s: unmapped from %s", channel_get_name((channel_t *)ilm->ilm_in2), t->s_nicename, bq->bq_name ?: ""); channel_delete((channel_t *)ilm->ilm_in2, 1); @@ -422,7 +422,7 @@ bouquet_notify_service_enabled(service_t *t) static void bouquet_remove_service(bouquet_t *bq, service_t *s, int delconf) { - tvhtrace("bouquet", "remove service %s from %s", + tvhtrace(LS_BOUQUET, "remove service %s from %s", s->s_nicename, bq->bq_name ?: ""); idnode_set_remove(bq->bq_services, &s->s_id); if (delconf) @@ -448,7 +448,7 @@ bouquet_completed(bouquet_t *bq, uint32_t seen) bq->bq_saveflag = 1; } - tvhtrace("bouquet", "%s: completed: enabled=%d active=%zi old=%zi seen=%u", + tvhtrace(LS_BOUQUET, "%s: completed: enabled=%d active=%zi old=%zi seen=%u", bq->bq_name ?: "", bq->bq_enabled, bq->bq_active_services->is_count, bq->bq_services->is_count, seen); @@ -1190,7 +1190,7 @@ next: while (*data && (*data == '\r' || *data == '\n')) data++; } bouquet_completed(bq, seen); - tvhinfo("bouquet", "parsed Enigma%d bouquet %s (%d services)", ver, bq->bq_name, seen); + tvhinfo(LS_BOUQUET, "parsed Enigma%d bouquet %s (%d services)", ver, bq->bq_name, seen); return 0; } diff --git a/src/channels.c b/src/channels.c index aa5ef2e3f..7f0a25f74 100644 --- a/src/channels.c +++ b/src/channels.c @@ -976,12 +976,12 @@ channel_create0 if (idnode_insert(&ch->ch_id, uuid, idc, IDNODE_SHORT_UUID)) { if (uuid) - tvherror("channel", "invalid uuid '%s'", uuid); + tvherror(LS_CHANNEL, "invalid uuid '%s'", uuid); free(ch); return NULL; } if (RB_INSERT_SORTED(&channels, ch, ch_link, ch_id_cmp)) { - tvherror("channel", "id collision!"); + tvherror(LS_CHANNEL, "id collision!"); abort(); } @@ -1028,7 +1028,7 @@ channel_delete ( channel_t *ch, int delconf ) idnode_save_check(&ch->ch_id, delconf); if (delconf) - tvhinfo("channel", "%s - deleting", channel_get_name(ch)); + tvhinfo(LS_CHANNEL, "%s - deleting", channel_get_name(ch)); /* Tags */ while((ilm = LIST_FIRST(&ch->ch_ctms)) != NULL) @@ -1241,7 +1241,7 @@ channel_tag_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&ct->ct_id, uuid, &channel_tag_class, IDNODE_SHORT_UUID)) { if (uuid) - tvherror("channel", "invalid tag uuid '%s'", uuid); + tvherror(LS_CHANNEL, "invalid tag uuid '%s'", uuid); free(ct); return NULL; } diff --git a/src/config.c b/src/config.c index c71e66da7..c7b0e012b 100644 --- a/src/config.c +++ b/src/config.c @@ -1427,11 +1427,11 @@ dobackup(const char *oldver) assert(root); - tvhinfo("config", "backup: migrating config from %s (running %s)", + tvhinfo(LS_CONFIG, "backup: migrating config from %s (running %s)", oldver, tvheadend_version); if (getcwd(cwd, sizeof(cwd)) == NULL) { - tvherror("config", "unable to get the current working directory"); + tvherror(LS_CONFIG, "unable to get the current working directory"); goto fatal; } @@ -1442,21 +1442,21 @@ dobackup(const char *oldver) else if (!access("/usr/local/bin/tar", X_OK)) argv[0] = "/usr/local/bin/tar"; else { - tvherror("config", "unable to find tar program"); + tvherror(LS_CONFIG, "unable to find tar program"); goto fatal; } snprintf(outfile, sizeof(outfile), "%s/backup", root); - if (makedirs("config", outfile, 0700, 1, -1, -1)) + if (makedirs(LS_CONFIG, outfile, 0700, 1, -1, -1)) goto fatal; if (chdir(root)) { - tvherror("config", "unable to find directory '%s'", root); + tvherror(LS_CONFIG, "unable to find directory '%s'", root); goto fatal; } snprintf(outfile, sizeof(outfile), "%s/backup/%s.tar.bz2", root, oldver); - tvhinfo("config", "backup: running, output file %s", outfile); + tvhinfo(LS_CONFIG, "backup: running, output file %s", outfile); if (spawnv(argv[0], (void *)argv, &pid, 1, 1)) { code = -ENOENT; @@ -1465,7 +1465,7 @@ dobackup(const char *oldver) tvh_safe_usleep(20000); if (code == -ECHILD) code = 0; - tvhinfo("config", "backup: completed"); + tvhinfo(LS_CONFIG, "backup: completed"); } if (code) { @@ -1478,25 +1478,25 @@ dobackup(const char *oldver) htsbuf_append(&q, " ", 1); } s = htsbuf_to_string(&q); - tvherror("config", "command '%s' returned error code %d", s, code); - tvherror("config", "executed in directory '%s'", root); - tvherror("config", "please, do not report this as an error, you may use --nobackup option"); - tvherror("config", "... or run the above command in the printed directory"); - tvherror("config", "... using the same user/group as for the tvheadend executable"); - tvherror("config", "... to check the reason for the unfinished backup"); + tvherror(LS_CONFIG, "command '%s' returned error code %d", s, code); + tvherror(LS_CONFIG, "executed in directory '%s'", root); + tvherror(LS_CONFIG, "please, do not report this as an error, you may use --nobackup option"); + tvherror(LS_CONFIG, "... or run the above command in the printed directory"); + tvherror(LS_CONFIG, "... using the same user/group as for the tvheadend executable"); + tvherror(LS_CONFIG, "... to check the reason for the unfinished backup"); free(s); htsbuf_queue_flush(&q); goto fatal; } if (chdir(cwd)) { - tvherror("config", "unable to change directory to '%s'", cwd); + tvherror(LS_CONFIG, "unable to change directory to '%s'", cwd); goto fatal; } return; fatal: - tvherror("config", "backup: fatal error"); + tvherror(LS_CONFIG, "backup: fatal error"); exit(EXIT_FAILURE); } @@ -1564,7 +1564,7 @@ config_migrate ( int backup ) /* Run migrations */ for ( ; v < ARRAY_SIZE(config_migrate_table); v++) { - tvhinfo("config", "migrating config from v%d to v%d", v, v+1); + tvhinfo(LS_CONFIG, "migrating config from v%d to v%d", v, v+1); config_migrate_table[v](); } @@ -1591,7 +1591,7 @@ config_check_one ( const char *dir ) HTSMSG_FOREACH(f, c) { if (!(e = htsmsg_field_get_map(f))) continue; if (strlen(f->hmf_name) != UUID_HEX_SIZE - 1) { - tvherror("START", "filename %s/%s/%s is invalid", hts_settings_get_root(), dir, f->hmf_name); + tvherror(LS_START, "filename %s/%s/%s is invalid", hts_settings_get_root(), dir, f->hmf_name); exit(1); } } @@ -1647,7 +1647,7 @@ config_boot ( const char *path, gid_t gid, uid_t uid ) if (!path) { const char *homedir = getenv("HOME"); if (homedir == NULL) { - tvherror("START", "environment variable HOME is not set"); + tvherror(LS_START, "environment variable HOME is not set"); exit(EXIT_FAILURE); } snprintf(buf, sizeof(buf), "%s/.hts/tvheadend", homedir); @@ -1657,8 +1657,8 @@ config_boot ( const char *path, gid_t gid, uid_t uid ) /* Ensure directory exists */ if (stat(path, &st)) { config_newcfg = 1; - if (makedirs("config", path, 0700, 1, gid, uid)) { - tvhwarn("START", "failed to create settings directory %s," + if (makedirs(LS_CONFIG, path, 0700, 1, gid, uid)) { + tvhwarn(LS_START, "failed to create settings directory %s," " settings will not be saved", path); return; } @@ -1666,7 +1666,7 @@ config_boot ( const char *path, gid_t gid, uid_t uid ) /* And is usable */ else if (access(path, R_OK | W_OK)) { - tvhwarn("START", "configuration path %s is not r/w" + tvhwarn(LS_START, "configuration path %s is not r/w" " for UID:%d GID:%d [e=%s]," " settings will not be saved", path, getuid(), getgid(), strerror(errno)); @@ -1682,12 +1682,12 @@ config_boot ( const char *path, gid_t gid, uid_t uid ) exit(78); /* config error */ if (chown(config_lock, uid, gid)) - tvhwarn("config", "unable to chown lock file %s UID:%d GID:%d", config_lock, uid, gid); + tvhwarn(LS_CONFIG, "unable to chown lock file %s UID:%d GID:%d", config_lock, uid, gid); /* Load global settings */ config2 = hts_settings_load("config"); if (!config2) { - tvhlog(LOG_DEBUG, "config", "no configuration, loading defaults"); + tvhlog(LOG_DEBUG, LS_CONFIG, "no configuration, loading defaults"); config.wizard = strdup("hello"); config_newcfg = 1; } else { @@ -1722,7 +1722,7 @@ config_init ( int backup ) const char *path = hts_settings_get_root(); if (path == NULL || access(path, R_OK | W_OK)) { - tvhwarn("START", "configuration path %s is not r/w" + tvhwarn(LS_START, "configuration path %s is not r/w" " for UID:%d GID:%d [e=%s]," " settings will not be saved", path, getuid(), getgid(), strerror(errno)); @@ -1741,7 +1741,7 @@ config_init ( int backup ) if (config_migrate(backup)) config_check(); } - tvhinfo("config", "loaded"); + tvhinfo(LS_CONFIG, "loaded"); } void config_done ( void ) @@ -1952,7 +1952,7 @@ config_muxconfpath_notify_cb(void *opaque, int disarmed) free(muxconf_path); return; } - tvhinfo("config", "scanfile (re)initialization with path %s", muxconf_path ?: ""); + tvhinfo(LS_CONFIG, "scanfile (re)initialization with path %s", muxconf_path ?: ""); scanfile_init(muxconf_path, 1); free(muxconf_path); } diff --git a/src/cron.c b/src/cron.c index 8fb7eedf8..a09452871 100644 --- a/src/cron.c +++ b/src/cron.c @@ -328,7 +328,7 @@ cron_next ( cron_t *c, const time_t now, time_t *ret ) *ret = mktime(&tmp); if (*ret <= now) { #ifndef CRON_TEST - tvherror("cron", "invalid time, now %"PRItime_t", result %"PRItime_t, now, *ret); + tvherror(LS_CRON, "invalid time, now %"PRItime_t", result %"PRItime_t, now, *ret); #else printf("ERROR: invalid time, now %"PRItime_t", result %"PRItime_t"\n", now, *ret); #endif diff --git a/src/dbus.c b/src/dbus.c index bdc2f9c7e..7909ffb81 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -140,21 +140,21 @@ dbus_create_session(const char *name) conn = dbus_bus_get_private(dbus_session ? DBUS_BUS_SESSION : DBUS_BUS_SYSTEM, &err); if (dbus_error_is_set(&err)) { - tvherror("dbus", "Connection error: %s", err.message); + tvherror(LS_DBUS, "Connection error: %s", err.message); dbus_error_free(&err); return NULL; } ret = dbus_bus_request_name(conn, name, DBUS_NAME_FLAG_REPLACE_EXISTING, &err); if (dbus_error_is_set(&err)) { - tvherror("dbus", "Name error: %s", err.message); + tvherror(LS_DBUS, "Name error: %s", err.message); dbus_error_free(&err); dbus_connection_close(conn); dbus_connection_unref(conn); return NULL; } if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) { - tvherror("dbus", "Not primary owner"); + tvherror(LS_DBUS, "Not primary owner"); dbus_connection_close(conn); dbus_connection_unref(conn); return NULL; @@ -175,7 +175,7 @@ dbus_send_signal(DBusConnection *conn, const char *obj_name, msg = dbus_message_new_signal(obj_name, if_name, sig_name); if (msg == NULL) { - tvherror("dbus", "Unable to create signal %s %s %s", + tvherror(LS_DBUS, "Unable to create signal %s %s %s", obj_name, if_name, sig_name); dbus_connection_unref(conn); return -1; @@ -183,7 +183,7 @@ dbus_send_signal(DBusConnection *conn, const char *obj_name, dbus_message_iter_init_append(msg, &args); dbus_from_htsmsg(value, &args); if (!dbus_connection_send(conn, msg, NULL)) { - tvherror("dbus", "Unable to send signal %s %s %s", + tvherror(LS_DBUS, "Unable to send signal %s %s %s", obj_name, if_name, sig_name); dbus_message_unref(msg); dbus_connection_unref(conn); @@ -388,7 +388,7 @@ dbus_server_thread(void *aux) n = tvhpoll_wait(poll, &ev, 1, -1); if (n < 0) { if (atomic_get(&dbus_running) && !ERRNO_AGAIN(errno)) - tvherror("dbus", "tvhpoll_wait() error"); + tvherror(LS_DBUS, "tvhpoll_wait() error"); } else if (n == 0) { continue; } diff --git a/src/descrambler/caclient.c b/src/descrambler/caclient.c index 0b4caaffa..eefd97459 100644 --- a/src/descrambler/caclient.c +++ b/src/descrambler/caclient.c @@ -89,7 +89,7 @@ caclient_create if ((s = htsmsg_get_str(conf, "class")) != NULL) c = caclient_class_find(s); if (c == NULL) { - tvherror("caclient", "wrong class %s!", s); + tvherror(LS_CACLIENT, "wrong class %s!", s); abort(); } #if ENABLE_CWC @@ -107,12 +107,12 @@ caclient_create cac = constcw_create(); #endif if (cac == NULL) { - tvherror("caclient", "CA Client class %s is not available!", s); + tvherror(LS_CACLIENT, "CA Client class %s is not available!", s); return NULL; } if (idnode_insert(&cac->cac_id, uuid, c, 0)) { if (uuid) - tvherror("caclient", "invalid uuid '%s'", uuid); + tvherror(LS_CACLIENT, "invalid uuid '%s'", uuid); free(cac); return NULL; } diff --git a/src/descrambler/capmt.c b/src/descrambler/capmt.c index 0efcddbc8..ee24b3200 100644 --- a/src/descrambler/capmt.c +++ b/src/descrambler/capmt.c @@ -372,7 +372,7 @@ capmt_pid_add(capmt_t *capmt, int adapter, int pid, mpegts_service_t *s) t = &ca->ca_pids[i]; if (t->pid == pid && t->ecm == ecm) { t->pid_refs++; - tvhtrace("capmt", "%s: adding pid %d adapter %d - reusing (%d)", + tvhtrace(LS_CAPMT, "%s: adding pid %d adapter %d - reusing (%d)", capmt_name(capmt), pid, adapter, t->pid_refs); return; } @@ -387,7 +387,7 @@ capmt_pid_add(capmt_t *capmt, int adapter, int pid, mpegts_service_t *s) o->ecm = ecm; mmi = ca->ca_tuner ? LIST_FIRST(&ca->ca_tuner->mi_mux_active) : NULL; mux = mmi ? mmi->mmi_mux : NULL; - tvhtrace("capmt", "%s: adding pid %d adapter %d, tuner %p, mmi %p, mux %p", capmt_name(capmt), pid, adapter, ca->ca_tuner, mmi, mux); + tvhtrace(LS_CAPMT, "%s: adding pid %d adapter %d, tuner %p, mmi %p, mux %p", capmt_name(capmt), pid, adapter, ca->ca_tuner, mmi, mux); if (mux) { pthread_mutex_unlock(&capmt->capmt_mutex); descrambler_open_pid(mux, o, @@ -446,7 +446,7 @@ capmt_pid_flush_adapter(capmt_t *capmt, int adapter) capmt_opaque_t *o; int pid, i; - tvhtrace("capmt", "%s: pid flush for adapter %d", capmt_name(capmt), adapter); + tvhtrace(LS_CAPMT, "%s: pid flush for adapter %d", capmt_name(capmt), adapter); ca = &capmt->capmt_adapters[adapter]; tuner = capmt->capmt_adapters[adapter].ca_tuner; if (tuner == NULL) { @@ -504,9 +504,9 @@ capmt_connect(capmt_t *capmt, int i) fd = tcp_connect(capmt->capmt_sockfile, capmt->capmt_port, NULL, errbuf, sizeof(errbuf), 2); if (fd < 0 && tvheadend_is_running()) { - tvhlog(LOG_ERR, "capmt", - "%s: Cannot connect to %s:%i (%s); Do you have OSCam running?", - capmt_name(capmt), capmt->capmt_sockfile, capmt->capmt_port, errbuf); + tvherror(LS_CAPMT, + "%s: Cannot connect to %s:%i (%s); Do you have OSCam running?", + capmt_name(capmt), capmt->capmt_sockfile, capmt->capmt_port, errbuf); fd = -1; } @@ -525,9 +525,9 @@ capmt_connect(capmt_t *capmt, int i) connect(fd, (const struct sockaddr*)&serv_addr_un, sizeof(serv_addr_un)) != 0) { if (tvheadend_is_running()) - tvhlog(LOG_ERR, "capmt", - "%s: Cannot connect to %s (%s); Do you have OSCam running?", - capmt_name(capmt), capmt->capmt_sockfile, strerror(errno)); + tvherror(LS_CAPMT, + "%s: Cannot connect to %s (%s); Do you have OSCam running?", + capmt_name(capmt), capmt->capmt_sockfile, strerror(errno)); if (fd >= 0) { close(fd); fd = -1; @@ -537,7 +537,7 @@ capmt_connect(capmt_t *capmt, int i) } if (fd >= 0) { - tvhlog(LOG_DEBUG, "capmt", "%s: Created socket %d", capmt_name(capmt), fd); + tvhdebug(LS_CAPMT, "%s: Created socket %d", capmt_name(capmt), fd); capmt->capmt_sock[i] = fd; capmt->capmt_sock_reconnect[i]++; if (capmt_oscam_netproto(capmt)) @@ -558,7 +558,7 @@ capmt_socket_close(capmt_t *capmt, int sock_idx) lock_assert(&capmt->capmt_mutex); if (fd < 0) return; - tvhtrace("capmt", "%s: socket close %d", capmt_name(capmt), fd); + tvhtrace(LS_CAPMT, "%s: socket close %d", capmt_name(capmt), fd); capmt_poll_rem(capmt, fd); close(fd); capmt->capmt_sock[sock_idx] = -1; @@ -589,9 +589,9 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t if (capmt->capmt_oscam == CAPMT_OSCAM_OLD) { // dumping current SID table for (i = 0; i < MAX_SOCKETS; i++) - tvhlog(LOG_DEBUG, "capmt", "%s: %s: SOCKETS TABLE DUMP [%d]: sid=%d socket=%d", capmt_name(capmt), __FUNCTION__, i, capmt->sids[i], capmt->capmt_sock[i]); + tvhdebug(LS_CAPMT, "%s: %s: SOCKETS TABLE DUMP [%d]: sid=%d socket=%d", capmt_name(capmt), __FUNCTION__, i, capmt->sids[i], capmt->capmt_sock[i]); if (sid == 0) { - tvhlog(LOG_DEBUG, "capmt", "%s: %s: got empty SID - returning from function", capmt_name(capmt), __FUNCTION__); + tvhdebug(LS_CAPMT, "%s: %s: got empty SID - returning from function", capmt_name(capmt), __FUNCTION__); return -1; } @@ -604,7 +604,7 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t } if (found) - tvhlog(LOG_DEBUG, "capmt", "%s: %s: found sid, reusing socket, i=%d", capmt_name(capmt), __FUNCTION__, i); + tvhdebug(LS_CAPMT, "%s: %s: found sid, reusing socket, i=%d", capmt_name(capmt), __FUNCTION__, i); else { //not found - adding to first free in table for (i = 0; i < MAX_SOCKETS; i++) { if (capmt->sids[i] == 0) { @@ -615,11 +615,11 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t } } if (i == MAX_SOCKETS) { - tvhlog(LOG_DEBUG, "capmt", "%s: %s: no free space for new SID!!!", capmt_name(capmt), __FUNCTION__); + tvhdebug(LS_CAPMT, "%s: %s: no free space for new SID!!!", capmt_name(capmt), __FUNCTION__); return -1; } else { capmt->sids[i] = sid; - tvhlog(LOG_DEBUG, "capmt", "%s: %s: added: i=%d", capmt_name(capmt), __FUNCTION__, i); + tvhdebug(LS_CAPMT, "%s: %s: added: i=%d", capmt_name(capmt), __FUNCTION__, i); } } @@ -648,19 +648,19 @@ capmt_write_msg(capmt_t *capmt, int adapter, int sid, const uint8_t *buf, size_t fd = capmt->capmt_sock[i]; if (fd <= 0) { - tvhtrace("capmt", "%s: Unable to send message for sid %i", capmt_name(capmt), sid); + tvhtrace(LS_CAPMT, "%s: Unable to send message for sid %i", capmt_name(capmt), sid); return -1; } - tvhtrace("capmt", "%s: Sending message to socket %i (sid %i)", capmt_name(capmt), fd, sid); - tvhlog_hexdump("capmt", buf, len); + tvhtrace(LS_CAPMT, "%s: Sending message to socket %i (sid %i)", capmt_name(capmt), fd, sid); + tvhlog_hexdump(LS_CAPMT, buf, len); res = send(fd, buf, len, MSG_DONTWAIT); if (res < len) { #if ENABLE_ANDROID - tvhlog(LOG_DEBUG, "capmt", "%s: Message send failed to socket %i (%li)", capmt_name(capmt), fd, (long int)res); // Android bug, ssize_t is long int + tvhdebug(LS_CAPMT, "%s: Message send failed to socket %i (%li)", capmt_name(capmt), fd, (long int)res); // Android bug, ssize_t is long int #else - tvhlog(LOG_DEBUG, "capmt", "%s: Message send failed to socket %i (%zi)", capmt_name(capmt), fd, res); + tvhdebug(LS_CAPMT, "%s: Message send failed to socket %i (%zi)", capmt_name(capmt), fd, res); #endif if (capmt->capmt_oscam != CAPMT_OSCAM_SO_WRAPPER) { capmt_socket_close_lock(capmt, i); @@ -760,12 +760,12 @@ capmt_send_stop(capmt_service_t *t) break; if (i == MAX_SOCKETS) { - tvhlog(LOG_DEBUG, "capmt", "%s: %s: socket to close not found", capmt_name(capmt), __FUNCTION__); + tvhdebug(LS_CAPMT, "%s: %s: socket to close not found", capmt_name(capmt), __FUNCTION__); return; } // closing socket (oscam handle this as event and stop decrypting) - tvhlog(LOG_DEBUG, "capmt", "%s: %s: closing socket i=%d, socket_fd=%d", capmt_name(capmt), __FUNCTION__, i, capmt->capmt_sock[i]); + tvhdebug(LS_CAPMT, "%s: %s: closing socket i=%d, socket_fd=%d", capmt_name(capmt), __FUNCTION__, i, capmt->capmt_sock[i]); capmt->sids[i] = 0; capmt->adps[i] = 0; capmt_socket_close(capmt, i); @@ -834,9 +834,9 @@ capmt_service_destroy(th_descrambler_t *td) capmt_caid_ecm_t *cce; capmt_t *capmt = ct->ct_capmt; - tvhlog(LOG_INFO, "capmt", - "%s: Removing CAPMT Server from service \"%s\" on adapter %d", - capmt_name(capmt), s->s_dvb_svcname, ct->ct_adapter); + tvhdebug(LS_CAPMT, + "%s: Removing CAPMT Server from service \"%s\" on adapter %d", + capmt_name(capmt), s->s_dvb_svcname, ct->ct_adapter); pthread_mutex_lock(&capmt->capmt_mutex); @@ -920,7 +920,7 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) capmt_caid_ecm_t *cce; int i, flags = 0, add = 0; - tvhtrace("capmt", "%s: setting filter: adapter=%d, demux=%d, filter=%d, pid=%d", + tvhtrace(LS_CAPMT, "%s: setting filter: adapter=%d, demux=%d, filter=%d, pid=%d", capmt_name(capmt), adapter, demux_index, filter_index, pid); if (adapter >= MAX_CA || demux_index >= MAX_INDEX || @@ -971,9 +971,9 @@ capmt_set_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) filter->pid = pid; filter->flags = flags; memcpy(&filter->filter, sbuf_peek(sb, offset + 8), sizeof(filter->filter)); - tvhlog_hexdump("capmt", filter->filter.filter, DMX_FILTER_SIZE); - tvhlog_hexdump("capmt", filter->filter.mask, DMX_FILTER_SIZE); - tvhlog_hexdump("capmt", filter->filter.mode, DMX_FILTER_SIZE); + tvhlog_hexdump(LS_CAPMT, filter->filter.filter, DMX_FILTER_SIZE); + tvhlog_hexdump(LS_CAPMT, filter->filter.mask, DMX_FILTER_SIZE); + tvhlog_hexdump(LS_CAPMT, filter->filter.mode, DMX_FILTER_SIZE); for (i = 0; i < DMX_FILTER_SIZE; i++) filter->filter.filter[i] &= filter->filter.mask[i]; if (add) @@ -1001,7 +1001,7 @@ capmt_stop_filter(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) else pid = sbuf_peek_s16be(sb, offset + 6); - tvhtrace("capmt", "%s: stopping filter: adapter=%d, demux=%d, filter=%d, pid=%d", + tvhtrace(LS_CAPMT, "%s: stopping filter: adapter=%d, demux=%d, filter=%d, pid=%d", capmt_name(capmt), adapter, demux_index, filter_index, pid); if (adapter >= MAX_CA || demux_index >= MAX_INDEX || @@ -1061,12 +1061,12 @@ capmt_abort(capmt_t *capmt, int keystate) t = (mpegts_service_t *)ct->td_service; if (ct->td_keystate != keystate) { - tvhlog(LOG_ERR, "capmt", - "%s: Can not descramble service \"%s\", %s", - capmt_name(capmt), - t->s_dvb_svcname, - keystate == DS_FORBIDDEN ? - "access denied" : "connection close"); + tvherror(LS_CAPMT, + "%s: Can not descramble service \"%s\", %s", + capmt_name(capmt), + t->s_dvb_svcname, + keystate == DS_FORBIDDEN ? + "access denied" : "connection close"); ct->td_keystate = keystate; } } @@ -1100,9 +1100,9 @@ capmt_process_key(capmt_t *capmt, uint8_t adapter, uint32_t index, if (!ok) { if (ct->td_keystate != DS_FORBIDDEN) { - tvhlog(LOG_ERR, "capmt", - "%s: Can not descramble service \"%s\", access denied", - capmt_name(capmt), t->s_dvb_svcname); + tvherror(LS_CAPMT, + "%s: Can not descramble service \"%s\", access denied", + capmt_name(capmt), t->s_dvb_svcname); ct->td_keystate = DS_FORBIDDEN; } continue; @@ -1248,7 +1248,7 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) int i, j; ca_info_t *cai; - tvhlog(LOG_DEBUG, "capmt", "%s: CA_SET_PID adapter %d index %d pid %d (0x%04x)", capmt_name(capmt), adapter, index, pid, pid); + tvhdebug(LS_CAPMT, "%s: CA_SET_PID adapter %d index %d pid %d (0x%04x)", capmt_name(capmt), adapter, index, pid, pid); if (adapter < MAX_CA && index >= 0 && index < MAX_INDEX) { cai = &capmt->capmt_adapters[adapter].ca_info[index]; for (i = 0, j = -1; i < MAX_PIDS; i++) { @@ -1267,7 +1267,7 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) cai->pids[i] = 0; } } else { - tvhlog(LOG_ERR, "capmt", "%s: Invalid index %d in CA_SET_PID (%d) for adapter %d", capmt_name(capmt), index, MAX_INDEX, adapter); + tvherror(LS_CAPMT, "%s: Invalid index %d in CA_SET_PID (%d) for adapter %d", capmt_name(capmt), index, MAX_INDEX, adapter); } } else if (cmd == CA_SET_DESCR) { @@ -1276,9 +1276,9 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) int32_t parity = sbuf_peek_s32(sb, offset + 8); uint8_t *cw = sbuf_peek (sb, offset + 12); - tvhlog(LOG_DEBUG, "capmt", "%s, CA_SET_DESCR adapter %d par %d idx %d %02x%02x%02x%02x%02x%02x%02x%02x", - capmt_name(capmt), adapter, parity, index, - cw[0], cw[1], cw[2], cw[3], cw[4], cw[5], cw[6], cw[7]); + tvhdebug(LS_CAPMT, "%s, CA_SET_DESCR adapter %d par %d idx %d %02x%02x%02x%02x%02x%02x%02x%02x", + capmt_name(capmt), adapter, parity, index, + cw[0], cw[1], cw[2], cw[3], cw[4], cw[5], cw[6], cw[7]); if (index < 0) // skipping removal request return; if (adapter >= MAX_CA || index >= MAX_INDEX) @@ -1288,7 +1288,7 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) } else if (parity == 1) { capmt_process_key(capmt, adapter, index, DESCRAMBLER_DES, empty, cw, 1); } else - tvhlog(LOG_ERR, "capmt", "%s: Invalid parity %d in CA_SET_DESCR for adapter%d", capmt_name(capmt), parity, adapter); + tvherror(LS_CAPMT, "%s: Invalid parity %d in CA_SET_DESCR for adapter%d", capmt_name(capmt), parity, adapter); } else if (cmd == CA_SET_DESCR_AES) { @@ -1296,11 +1296,11 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) int32_t parity = sbuf_peek_s32(sb, offset + 8); uint8_t *cw = sbuf_peek (sb, offset + 12); - tvhlog(LOG_DEBUG, "capmt", "%s: CA_SET_DESCR_AES adapter %d par %d idx %d " - "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", - capmt_name(capmt), adapter, parity, index, - cw[0], cw[1], cw[2], cw[3], cw[4], cw[5], cw[6], cw[7], - cw[8], cw[9], cw[10], cw[11], cw[12], cw[13], cw[14], cw[15]); + tvhdebug(LS_CAPMT, "%s: CA_SET_DESCR_AES adapter %d par %d idx %d " + "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + capmt_name(capmt), adapter, parity, index, + cw[0], cw[1], cw[2], cw[3], cw[4], cw[5], cw[6], cw[7], + cw[8], cw[9], cw[10], cw[11], cw[12], cw[13], cw[14], cw[15]); if (index < 0) // skipping removal request return; if (adapter >= MAX_CA || index >= MAX_INDEX) @@ -1310,7 +1310,7 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) } else if (parity == 1) { capmt_process_key(capmt, adapter, index, DESCRAMBLER_AES, empty, cw, 1); } else - tvhlog(LOG_ERR, "capmt", "%s: Invalid parity %d in CA_SET_DESCR_AES for adapter%d", capmt_name(capmt), parity, adapter); + tvherror(LS_CAPMT, "%s: Invalid parity %d in CA_SET_DESCR_AES for adapter%d", capmt_name(capmt), parity, adapter); } else if (cmd == CA_SET_DESCR_MODE) { @@ -1328,8 +1328,8 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) cai = &capmt->capmt_adapters[adapter].ca_info[index]; if (algo != cai->algo && cai->cipher_mode != cipher_mode) { - tvhlog(LOG_DEBUG, "capmt", "%s, CA_SET_DESCR_MODE adapter %d algo %d cipher mode %d", - capmt_name(capmt), adapter, algo, cipher_mode); + tvhdebug(LS_CAPMT, "%s, CA_SET_DESCR_MODE adapter %d algo %d cipher mode %d", + capmt_name(capmt), adapter, algo, cipher_mode); cai->algo = algo; cai->cipher_mode = cipher_mode; } @@ -1360,8 +1360,8 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) cardsystem, pid, ecmtime, hops, reader, from, protocol); - tvhlog(LOG_DEBUG, "capmt", "%s: ECM_INFO: adapter=%d sid=%d caid=%04X(%s) pid=%04X provid=%06X ecmtime=%d hops=%d reader=%s from=%s protocol=%s", - capmt_name(capmt), adapter, sid, caid, cardsystem, pid, provid, ecmtime, hops, reader, from, protocol); + tvhdebug(LS_CAPMT, "%s: ECM_INFO: adapter=%d sid=%d caid=%04X(%s) pid=%04X provid=%06X ecmtime=%d hops=%d reader=%s from=%s protocol=%s", + capmt_name(capmt), adapter, sid, caid, cardsystem, pid, provid, ecmtime, hops, reader, from, protocol); free(protocol); free(from); @@ -1374,12 +1374,12 @@ capmt_analyze_cmd(capmt_t *capmt, int adapter, sbuf_t *sb, int offset) int offset2 = offset + 6; char *info = capmt_peek_str(sb, &offset2); - tvhlog(LOG_INFO, "capmt", "%s: Connected to server '%s' (protocol version %d)", capmt_name(capmt), info, protover); + tvhinfo(LS_CAPMT, "%s: Connected to server '%s' (protocol version %d)", capmt_name(capmt), info, protover); free(info); } else { - tvhlog(LOG_ERR, "capmt", "%s: unknown command %08X", capmt_name(capmt), cmd); + tvherror(LS_CAPMT, "%s: unknown command %08X", capmt_name(capmt), cmd); } } @@ -1387,27 +1387,27 @@ static void show_connection(capmt_t *capmt, const char *what) { if (capmt->capmt_oscam == CAPMT_OSCAM_TCP || capmt->capmt_oscam == CAPMT_OSCAM_NET_PROTO) { - tvhlog(LOG_INFO, "capmt", - "%s: mode %i connected to %s:%i (%s)", - capmt_name(capmt), - capmt->capmt_oscam, - capmt->capmt_sockfile, capmt->capmt_port, - what); + tvhinfo(LS_CAPMT, + "%s: mode %i connected to %s:%i (%s)", + capmt_name(capmt), + capmt->capmt_oscam, + capmt->capmt_sockfile, capmt->capmt_port, + what); } else if (capmt->capmt_oscam == CAPMT_OSCAM_UNIX_SOCKET || capmt->capmt_oscam == CAPMT_OSCAM_UNIX_SOCKET_NP) { - tvhlog(LOG_INFO, "capmt", - "%s: mode %i sockfile %s got connection from client (%s)", - capmt_name(capmt), - capmt->capmt_oscam, - capmt->capmt_sockfile, - what); + tvhinfo(LS_CAPMT, + "%s: mode %i sockfile %s got connection from client (%s)", + capmt_name(capmt), + capmt->capmt_oscam, + capmt->capmt_sockfile, + what); } else { - tvhlog(LOG_INFO, "capmt", - "%s: mode %i sockfile %s port %i got connection from client (%s)", - capmt_name(capmt), - capmt->capmt_oscam, - capmt->capmt_sockfile, capmt->capmt_port, - what); + tvhinfo(LS_CAPMT, + "%s: mode %i sockfile %s port %i got connection from client (%s)", + capmt_name(capmt), + capmt->capmt_oscam, + capmt->capmt_sockfile, capmt->capmt_port, + what); } } @@ -1452,7 +1452,7 @@ handle_ca0(capmt_t *capmt) { continue; } - tvhtrace("capmt", "%s: thread received shutdown", capmt_name(capmt)); + tvhtrace(LS_CAPMT, "%s: thread received shutdown", capmt_name(capmt)); atomic_set(&capmt->capmt_running, 0); continue; } @@ -1470,7 +1470,7 @@ handle_ca0(capmt_t *capmt) { ret = recv(recvsock, buf, sizeof(buf), MSG_DONTWAIT); if (ret == 0) { - tvhlog(LOG_INFO, "capmt", "%s: normal socket shutdown", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s: normal socket shutdown", capmt_name(capmt)); close(recvsock); capmt_poll_rem(capmt, recvsock); @@ -1481,8 +1481,8 @@ handle_ca0(capmt_t *capmt) { if (ret < 0) continue; - tvhtrace("capmt", "%s: Received message from socket %i", capmt_name(capmt), recvsock); - tvhlog_hexdump("capmt", buf, ret); + tvhtrace(LS_CAPMT, "%s: Received message from socket %i", capmt_name(capmt), recvsock); + tvhlog_hexdump(LS_CAPMT, buf, ret); pbuf = &buffer[adapter]; sbuf_append(pbuf, buf, ret); @@ -1545,7 +1545,7 @@ handle_single(capmt_t *capmt) continue; } - tvhtrace("capmt", "%s: thread received shutdown", capmt_name(capmt)); + tvhtrace(LS_CAPMT, "%s: thread received shutdown", capmt_name(capmt)); atomic_set(&capmt->capmt_running, 0); continue; } @@ -1561,7 +1561,7 @@ handle_single(capmt_t *capmt) ret = recv(recvsock, buf, sizeof(buf), MSG_DONTWAIT); if (ret == 0) { - tvhlog(LOG_INFO, "capmt", "%s: normal socket shutdown", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s: normal socket shutdown", capmt_name(capmt)); capmt_poll_rem(capmt, recvsock); break; } @@ -1569,8 +1569,8 @@ handle_single(capmt_t *capmt) if (ret < 0) continue; - tvhtrace("capmt", "%s: Received message from socket %i", capmt_name(capmt), recvsock); - tvhlog_hexdump("capmt", buf, ret); + tvhtrace(LS_CAPMT, "%s: Received message from socket %i", capmt_name(capmt), recvsock); + tvhlog_hexdump(LS_CAPMT, buf, ret); sbuf_append(&buffer, buf, ret); @@ -1626,16 +1626,16 @@ handle_ca0_wrapper(capmt_t *capmt) ret = recv(capmt->capmt_adapters[0].ca_sock, buffer, 18, MSG_WAITALL); if (ret < 0) { - tvhlog(LOG_ERR, "capmt", "%s: error receiving over socket", capmt_name(capmt)); + tvherror(LS_CAPMT, "%s: error receiving over socket", capmt_name(capmt)); break; } else if (ret == 0) { /* normal socket shutdown */ - tvhlog(LOG_INFO, "capmt", "%s: normal socket shutdown", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s: normal socket shutdown", capmt_name(capmt)); break; } else { - tvhtrace("capmt", "%s: Received message from socket %i", capmt_name(capmt), capmt->capmt_adapters[0].ca_sock); - tvhlog_hexdump("capmt", buffer, ret); + tvhtrace(LS_CAPMT, "%s: Received message from socket %i", capmt_name(capmt), capmt->capmt_adapters[0].ca_sock); + tvhlog_hexdump(LS_CAPMT, buffer, ret); capmt_process_key(capmt, 0, buffer[0] | ((uint16_t)buffer[1] << 8), @@ -1646,7 +1646,7 @@ handle_ca0_wrapper(capmt_t *capmt) } capmt_abort(capmt, DS_UNKNOWN); - tvhlog(LOG_INFO, "capmt", "%s: connection from client closed ...", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s: connection from client closed ...", capmt_name(capmt)); } #endif @@ -1656,7 +1656,7 @@ capmt_create_udp_socket(capmt_t *capmt, int *socket, int port) { *socket = tvh_socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (*socket < 0) { - tvherror("capmt", "%s: failed to create UDP socket", capmt_name(capmt)); + tvherror(LS_CAPMT, "%s: failed to create UDP socket", capmt_name(capmt)); return 0; } @@ -1667,7 +1667,7 @@ capmt_create_udp_socket(capmt_t *capmt, int *socket, int port) if (bind(*socket, (const struct sockaddr*)&serv_addr, sizeof(serv_addr)) != 0) { - tvherror("capmt", "%s: failed to bind to ca0 (port %d)", capmt_name(capmt), port); + tvherror(LS_CAPMT, "%s: failed to bind to ca0 (port %d)", capmt_name(capmt), port); return 0; } else @@ -1687,7 +1687,7 @@ capmt_thread(void *aux) int d, i, j, fatal; int64_t mono; - tvhlog(LOG_INFO, "capmt", "%s active", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s active", capmt_name(capmt)); while (atomic_get(&capmt->capmt_running)) { fatal = 0; @@ -1753,10 +1753,10 @@ capmt_thread(void *aux) if (!la || !la->la_is_enabled(la)) continue; n = la->la_dvb_number; if (n < 0 || n > MAX_CA) { - tvhlog(LOG_ERR, "capmt", "%s: adapter number > MAX_CA", capmt_name(capmt)); + tvherror(LS_CAPMT, "%s: adapter number > MAX_CA", capmt_name(capmt)); continue; } - tvhlog(LOG_INFO, "capmt", "%s: created UDP socket %d", capmt_name(capmt), n); + tvhinfo(LS_CAPMT, "%s: created UDP socket %d", capmt_name(capmt), n); bind_ok = capmt_create_udp_socket(capmt, &capmt->capmt_adapters[n].ca_sock, capmt->capmt_port + n); @@ -1774,7 +1774,7 @@ capmt_thread(void *aux) capmt->capmt_oscam == CAPMT_OSCAM_UNIX_SOCKET_NP) { handle_single(capmt); } else { - tvhlog(LOG_ERR, "capmt", "%s: Only modes 3 and 4 are supported for non-linuxdvb devices", capmt_name(capmt)); + tvherror(LS_CAPMT, "%s: Only modes 3 and 4 are supported for non-linuxdvb devices", capmt_name(capmt)); fatal = 1; } #endif @@ -1813,7 +1813,7 @@ capmt_thread(void *aux) d = 60; } - tvhlog(LOG_INFO, "capmt", "%s: Automatic reconnection attempt in in %d seconds", idnode_get_title(&capmt->cac_id, NULL), d); + tvhinfo(LS_CAPMT, "%s: Automatic reconnection attempt in in %d seconds", idnode_get_title(&capmt->cac_id, NULL), d); mono = mclk() + sec2mono(d); do { @@ -1825,7 +1825,7 @@ capmt_thread(void *aux) pthread_mutex_unlock(&capmt->capmt_mutex); } - tvhlog(LOG_INFO, "capmt", "%s inactive", capmt_name(capmt)); + tvhinfo(LS_CAPMT, "%s inactive", capmt_name(capmt)); return NULL; } @@ -1868,7 +1868,7 @@ capmt_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm) break; } if (i >= DMX_FILTER_SIZE && i + 2 <= len) { - tvhtrace("capmt", "filter match pid %d len %d emm %d", pid, len, emm); + tvhtrace(LS_CAPMT, "filter match pid %d len %d emm %d", pid, len, emm); capmt_filter_data(capmt, o->adapter, demux_index, filter_index, data, len, @@ -1886,9 +1886,9 @@ capmt_caid_add(capmt_service_t *ct, mpegts_service_t *t, int pid, caid_t *c) { capmt_caid_ecm_t *cce; - tvhlog(LOG_DEBUG, "capmt", - "%s: New caid 0x%04X:0x%06X (pid 0x%04X) for service \"%s\"", - capmt_name(ct->ct_capmt), c->caid, c->providerid, pid, t->s_dvb_svcname); + tvhdebug(LS_CAPMT, + "%s: New caid 0x%04X:0x%06X (pid 0x%04X) for service \"%s\"", + capmt_name(ct->ct_capmt), c->caid, c->providerid, pid, t->s_dvb_svcname); cce = calloc(1, sizeof(capmt_caid_ecm_t)); cce->cce_caid = c->caid; @@ -2085,13 +2085,13 @@ capmt_send_request(capmt_service_t *ct, int lm) } else if (cce2->cce_caid == 0x4ad2) { cad.cad_length = 0x04; cad.cad_data[3] = cce2->cce_providerid & 0xffffff; - }else - tvhlog(LOG_WARNING, "capmt", "%s: Unknown CAID type, don't know where to put provider ID", capmt_name(capmt)); + } else + tvhwarn(LS_CAPMT, "%s: Unknown CAID type, don't know where to put provider ID", capmt_name(capmt)); } memcpy(&buf[pos], &cad, cad.cad_length + 2); pos += cad.cad_length + 2; - tvhlog(LOG_DEBUG, "capmt", "%s: adding ECMPID=0x%X (%d), " - "CAID=0x%X (%d) PROVID=0x%X (%d), SID=%d, ADAPTER=%d", + tvhdebug(LS_CAPMT, "%s: adding ECMPID=0x%X (%d), " + "CAID=0x%X (%d) PROVID=0x%X (%d), SID=%d, ADAPTER=%d", capmt_name(capmt), cce2->cce_ecmpid, cce2->cce_ecmpid, cce2->cce_caid, cce2->cce_caid, @@ -2113,8 +2113,8 @@ capmt_send_request(capmt_service_t *ct, int lm) if(ct->td_keystate != DS_RESOLVED) - tvhlog(LOG_DEBUG, "capmt", - "%s: Trying to obtain key for service \"%s\"", capmt_name(capmt), t->s_dvb_svcname); + tvhdebug(LS_CAPMT, "%s: Trying to obtain key for service \"%s\"", + capmt_name(capmt), t->s_dvb_svcname); buf[9] = pmtversion; pmtversion = (pmtversion + 1) & 0x1F; @@ -2141,7 +2141,8 @@ capmt_enumerate_services(capmt_t *capmt, int force) if (!all_srv_count) { // closing socket (oscam handle this as event and stop decrypting) - tvhlog(LOG_DEBUG, "capmt", "%s: %s: no subscribed services, closing socket, fd=%d", capmt_name(capmt), __FUNCTION__, capmt->capmt_sock[0]); + tvhdebug(LS_CAPMT, "%s: %s: no subscribed services, closing socket, fd=%d", + capmt_name(capmt), __FUNCTION__, capmt->capmt_sock[0]); if (capmt->capmt_sock[0] >= 0) caclient_set_status((caclient_t *)capmt, CACLIENT_STATUS_READY); if (capmt_oscam_netproto(capmt)) { @@ -2206,9 +2207,9 @@ capmt_service_start(caclient_t *cac, service_t *s) capmt->capmt_oscam != CAPMT_OSCAM_NET_PROTO && capmt->capmt_oscam != CAPMT_OSCAM_UNIX_SOCKET && capmt->capmt_oscam != CAPMT_OSCAM_UNIX_SOCKET_NP) { - tvhlog(LOG_WARNING, "capmt", - "%s: Virtual adapters are supported only in modes 3, 4, 5 and 6 (service \"%s\")", - capmt_name(capmt), t->s_dvb_svcname); + tvhwarn(LS_CAPMT, + "%s: Virtual adapters are supported only in modes 3, 4, 5 and 6 (service \"%s\")", + capmt_name(capmt), t->s_dvb_svcname); goto fin; } @@ -2222,17 +2223,17 @@ capmt_service_start(caclient_t *cac, service_t *s) } } if (tuner < 0 || tuner >= MAX_CA) { - tvhlog(LOG_ERR, "capmt", - "%s: No free adapter slot available for service \"%s\"", - capmt_name(capmt), t->s_dvb_svcname); + tvherror(LS_CAPMT, + "%s: No free adapter slot available for service \"%s\"", + capmt_name(capmt), t->s_dvb_svcname); pthread_mutex_unlock(&capmt->capmt_mutex); return; } } - tvhlog(LOG_INFO, "capmt", - "%s: Starting CAPMT server for service \"%s\" on adapter %d", - capmt_name(capmt), t->s_dvb_svcname, tuner); + tvhinfo(LS_CAPMT, + "%s: Starting CAPMT server for service \"%s\" on adapter %d", + capmt_name(capmt), t->s_dvb_svcname, tuner); capmt->capmt_adapters[tuner].ca_tuner = t->s_dvb_active_input; @@ -2302,12 +2303,12 @@ static void capmt_free(caclient_t *cac) { capmt_t *capmt = (capmt_t *)cac; - tvhlog(LOG_INFO, "capmt", "%s: mode %i %s %s port %i destroyed", - capmt_name(capmt), - capmt->capmt_oscam, - capmt->capmt_oscam == CAPMT_OSCAM_TCP || - capmt->capmt_oscam == CAPMT_OSCAM_NET_PROTO ? "IP address" : "sockfile", - capmt->capmt_sockfile, capmt->capmt_port); + tvhinfo(LS_CAPMT, "%s: mode %i %s %s port %i destroyed", + capmt_name(capmt), + capmt->capmt_oscam, + capmt->capmt_oscam == CAPMT_OSCAM_TCP || + capmt->capmt_oscam == CAPMT_OSCAM_NET_PROTO ? "IP address" : "sockfile", + capmt->capmt_sockfile, capmt->capmt_port); capmt_flush_queue(capmt, 1); free(capmt->capmt_sockfile); } diff --git a/src/descrambler/cwc.c b/src/descrambler/cwc.c index 29db78c9a..aa368acea 100644 --- a/src/descrambler/cwc.c +++ b/src/descrambler/cwc.c @@ -433,8 +433,8 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 } len = (size_t)ret; - tvhtrace("cwc", "sending message sid %d len %zu enq %d", sid, len, enq); - tvhlog_hexdump("cwc", buf, len); + tvhtrace(LS_CWC, "sending message sid %d len %zu enq %d", sid, len, enq); + tvhlog_hexdump(LS_CWC, buf, len); buf[0] = (len - 2) >> 8; buf[1] = (len - 2) & 0xff; @@ -447,7 +447,7 @@ cwc_send_msg(cwc_t *cwc, const uint8_t *msg, size_t len, int sid, int enq, uint1 pthread_mutex_unlock(&cwc->cwc_writer_mutex); } else { if (tvh_write(cwc->cwc_fd, buf, len)) - tvhlog(LOG_INFO, "cwc", "write error %s", strerror(errno)); + tvhinfo(LS_CWC, "write error %s", strerror(errno)); free(cm); } @@ -531,30 +531,30 @@ cwc_new_card(cwc_t *cwc, uint16_t caid, uint8_t *ua, n = caid2name(caid & 0xff00) ?: "Unknown"; if (ua) { - tvhlog(LOG_INFO, "cwc", "%s:%i: Connected as user %s " - "to a %s-card [0x%04x : %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x] " - "with %d provider%s", - cwc->cwc_hostname, cwc->cwc_port, - cwc->cwc_username, n, caid, - ua[0], ua[1], ua[2], ua[3], ua[4], ua[5], ua[6], ua[7], - pcount, pcount > 1 ? "s" : ""); + tvhinfo(LS_CWC, "%s:%i: Connected as user %s " + "to a %s-card [0x%04x : %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x] " + "with %d provider%s", + cwc->cwc_hostname, cwc->cwc_port, + cwc->cwc_username, n, caid, + ua[0], ua[1], ua[2], ua[3], ua[4], ua[5], ua[6], ua[7], + pcount, pcount > 1 ? "s" : ""); } else { - tvhlog(LOG_INFO, "cwc", "%s:%i: Connected as user %s " - "to a %s-card [0x%04x] with %d provider%s", - cwc->cwc_hostname, cwc->cwc_port, - cwc->cwc_username, n, caid, - pcount, pcount > 1 ? "s" : ""); + tvhinfo(LS_CWC, "%s:%i: Connected as user %s " + "to a %s-card [0x%04x] with %d provider%s", + cwc->cwc_hostname, cwc->cwc_port, + cwc->cwc_username, n, caid, + pcount, pcount > 1 ? "s" : ""); } for (i = 0, ep = pcard->cs_ra.providers; i < pcount; i++, ep++) { if (psa) { sa = ep->sa; - tvhlog(LOG_INFO, "cwc", "%s:%i: Provider ID #%d: 0x%04x:0x%06x %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x", - cwc->cwc_hostname, cwc->cwc_port, i + 1, caid, ep->id, - sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7]); + tvhinfo(LS_CWC, "%s:%i: Provider ID #%d: 0x%04x:0x%06x %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x", + cwc->cwc_hostname, cwc->cwc_port, i + 1, caid, ep->id, + sa[0], sa[1], sa[2], sa[3], sa[4], sa[5], sa[6], sa[7]); } else { - tvhlog(LOG_INFO, "cwc", "%s:%i: Provider ID #%d: 0x%04x:0x%06x", - cwc->cwc_hostname, cwc->cwc_port, i + 1, caid, ep->id); + tvhinfo(LS_CWC, "%s:%i: Provider ID #%d: 0x%04x:0x%06x", + cwc->cwc_hostname, cwc->cwc_port, i + 1, caid, ep->id); } } @@ -579,14 +579,14 @@ cwc_decode_card_data_reply(cwc_t *cwc, uint8_t *msg, int len) len -= 12; if(len < 3) { - tvhlog(LOG_INFO, "cwc", "Invalid card data reply"); + tvhinfo(LS_CWC, "Invalid card data reply"); return -1; } plen = (msg[1] & 0xf) << 8 | msg[2]; if(plen < 14) { - tvhlog(LOG_INFO, "cwc", "Invalid card data reply (message)"); + tvhinfo(LS_CWC, "Invalid card data reply (message)"); return -1; } @@ -596,7 +596,7 @@ cwc_decode_card_data_reply(cwc_t *cwc, uint8_t *msg, int len) plen -= 12; if(plen < nprov * 11) { - tvhlog(LOG_INFO, "cwc", "Invalid card data reply (provider list)"); + tvhinfo(LS_CWC, "Invalid card data reply (provider list)"); return -1; } @@ -619,17 +619,17 @@ cwc_decode_card_data_reply(cwc_t *cwc, uint8_t *msg, int len) ua[4] || ua[5] || ua[6] || ua[7]; if (!emm_allowed) { - tvhlog(LOG_INFO, "cwc", - "%s:%i: Will not forward EMMs (not allowed by server)", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, + "%s:%i: Will not forward EMMs (not allowed by server)", + cwc->cwc_hostname, cwc->cwc_port); } else if (pcard->cs_ra.type != CARD_UNKNOWN) { - tvhlog(LOG_INFO, "cwc", "%s:%i: Will forward EMMs", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, "%s:%i: Will forward EMMs", + cwc->cwc_hostname, cwc->cwc_port); cwc->cwc_forward_emm = 1; } else { - tvhlog(LOG_INFO, "cwc", + tvhinfo(LS_CWC, "%s:%i: Will not forward EMMs (unsupported CA system)", - cwc->cwc_hostname, cwc->cwc_port); + cwc->cwc_hostname, cwc->cwc_port); } } @@ -728,27 +728,27 @@ handle_ecm_reply(cwc_service_t *ct, ecm_section_t *es, uint8_t *msg, return; // We already know it's bad if (es->es_nok >= CWC_MAX_NOKS) { - tvhlog(LOG_DEBUG, "cwc", - "Too many NOKs[%i] for service \"%s\"%s from %s", - es->es_section, t->s_dvb_svcname, chaninfo, ct->td_nicename); + tvhdebug(LS_CWC, + "Too many NOKs[%i] for service \"%s\"%s from %s", + es->es_section, t->s_dvb_svcname, chaninfo, ct->td_nicename); es->es_keystate = ES_FORBIDDEN; goto forbid; } if (descrambler_resolved((service_t *)t, (th_descrambler_t *)ct)) { - tvhlog(LOG_DEBUG, "cwc", - "NOK[%i] from %s: Already has a key for service \"%s\"", - es->es_section, ct->td_nicename, t->s_dvb_svcname); + tvhdebug(LS_CWC, + "NOK[%i] from %s: Already has a key for service \"%s\"", + es->es_section, ct->td_nicename, t->s_dvb_svcname); es->es_nok = CWC_MAX_NOKS; /* do not send more ECM requests */ es->es_keystate = ES_IDLE; if (ct->td_keystate == DS_UNKNOWN) ct->td_keystate = DS_IDLE; } - tvhlog(LOG_DEBUG, "cwc", - "Received NOK[%i] for service \"%s\"%s " - "(seqno: %d Req delay: %"PRId64" ms)", - es->es_section, t->s_dvb_svcname, chaninfo, seq, delay); + tvhdebug(LS_CWC, + "Received NOK[%i] for service \"%s\"%s " + "(seqno: %d Req delay: %"PRId64" ms)", + es->es_section, t->s_dvb_svcname, chaninfo, seq, delay); forbid: i = 0; @@ -773,10 +773,10 @@ forbid: } if (ep == NULL) { /* !UNKNOWN && !RESOLVED */ - tvhlog(LOG_ERR, "cwc", - "Can not descramble service \"%s\", access denied (seqno: %d " - "Req delay: %"PRId64" ms) from %s", - t->s_dvb_svcname, seq, delay, ct->td_nicename); + tvherror(LS_CWC, + "Can not descramble service \"%s\", access denied (seqno: %d " + "Req delay: %"PRId64" ms) from %s", + t->s_dvb_svcname, seq, delay, ct->td_nicename); ct->td_keystate = DS_FORBIDDEN; ct->ecm_state = ECM_RESET; /* this pid is not valid, force full scan */ @@ -795,33 +795,33 @@ forbid: (t->s_dvb_prefcapid != ct->cs_channel && t->s_dvb_prefcapid_lock == PREFCAPID_OFF)) { t->s_dvb_prefcapid = ct->cs_channel; - tvhlog(LOG_DEBUG, "cwc", "Saving prefered PID %d for %s", + tvhdebug(LS_CWC, "Saving prefered PID %d for %s", t->s_dvb_prefcapid, ct->td_nicename); service_request_save((service_t*)t, 0); } if(len < 35) { - tvhlog(LOG_DEBUG, "cwc", - "Received ECM reply%s for service \"%s\" [%d] " - "even: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" - " odd: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x (seqno: %d " - "Req delay: %"PRId64" ms)", - chaninfo, - t->s_dvb_svcname, es->es_section, - msg[3 + 0], msg[3 + 1], msg[3 + 2], msg[3 + 3], msg[3 + 4], - msg[3 + 5], msg[3 + 6], msg[3 + 7], msg[3 + 8], msg[3 + 9], - msg[3 + 10],msg[3 + 11],msg[3 + 12],msg[3 + 13],msg[3 + 14], - msg[3 + 15], seq, delay); + tvhdebug(LS_CWC, + "Received ECM reply%s for service \"%s\" [%d] " + "even: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" + " odd: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x (seqno: %d " + "Req delay: %"PRId64" ms)", + chaninfo, + t->s_dvb_svcname, es->es_section, + msg[3 + 0], msg[3 + 1], msg[3 + 2], msg[3 + 3], msg[3 + 4], + msg[3 + 5], msg[3 + 6], msg[3 + 7], msg[3 + 8], msg[3 + 9], + msg[3 + 10],msg[3 + 11],msg[3 + 12],msg[3 + 13],msg[3 + 14], + msg[3 + 15], seq, delay); if(es->es_keystate != ES_RESOLVED) - tvhlog(LOG_DEBUG, "cwc", - "Obtained DES keys for service \"%s\" in %"PRId64" ms, from %s", - t->s_dvb_svcname, delay, ct->td_nicename); + tvhdebug(LS_CWC, + "Obtained DES keys for service \"%s\" in %"PRId64" ms, from %s", + t->s_dvb_svcname, delay, ct->td_nicename); es->es_keystate = ES_RESOLVED; es->es_resolved = 1; off = 8; } else { - tvhlog(LOG_DEBUG, "cwc", + tvhdebug(LS_CWC, "Received ECM reply%s for service \"%s\" " "even: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" " odd: %02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" @@ -837,9 +837,9 @@ forbid: msg[3 + 30],msg[3 + 31], seq, delay); if(es->es_keystate != ES_RESOLVED) - tvhlog(LOG_DEBUG, "cwc", - "Obtained AES keys for service \"%s\" in %"PRId64" ms, from %s", - t->s_dvb_svcname, delay, ct->td_nicename); + tvhdebug(LS_CWC, + "Obtained AES keys for service \"%s\" in %"PRId64" ms, from %s", + t->s_dvb_svcname, delay, ct->td_nicename); es->es_keystate = ES_RESOLVED; es->es_resolved = 1; off = 16; @@ -887,10 +887,10 @@ cwc_running_reply(cwc_t *cwc, uint8_t msgtype, uint8_t *msg, int len) if(es->es_seq == seq) { if (es->es_resolved) { mpegts_service_t *t = (mpegts_service_t *)ct->td_service; - tvhlog(LOG_DEBUG, "cwc", - "Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)", - es->es_pending ? "duplicate " : "", - ep->ep_pid, t->s_dvb_svcname, ct->td_nicename, es->es_seq); + tvhdebug(LS_CWC, + "Ignore %sECM (PID %d) for service \"%s\" from %s (seq %i)", + es->es_pending ? "duplicate " : "", + ep->ep_pid, t->s_dvb_svcname, ct->td_nicename, es->es_seq); return 0; } if (es->es_pending) { @@ -898,7 +898,7 @@ cwc_running_reply(cwc_t *cwc, uint8_t msgtype, uint8_t *msg, int len) return 0; } } - tvhlog(LOG_WARNING, "cwc", "Got unexpected ECM reply (seqno: %d)", seq); + tvhwarn(LS_CWC, "Got unexpected ECM reply (seqno: %d)", seq); break; case 0xD3: @@ -906,14 +906,14 @@ cwc_running_reply(cwc_t *cwc, uint8_t msgtype, uint8_t *msg, int len) if (caid){ if(len < 3) { - tvhlog(LOG_INFO, "cwc", "Invalid card data reply"); + tvhinfo(LS_CWC, "Invalid card data reply"); return -1; } plen = (msg[1] & 0xf) << 8 | msg[2]; if(plen < 14) { - tvhlog(LOG_INFO, "cwc", "Invalid card data reply (message)"); + tvhinfo(LS_CWC, "Invalid card data reply (message)"); return -1; } @@ -948,7 +948,7 @@ cwc_read(cwc_t *cwc, void *buf, size_t len, int timeout) pthread_mutex_lock(&cwc->cwc_mutex); if (r && tvheadend_is_running()) - tvhwarn("cwc", "read error %d (%s)", r, strerror(r)); + tvhwarn(LS_CWC, "read error %d (%s)", r, strerror(r)); if(cwc_must_break(cwc)) return ECONNABORTED; @@ -968,16 +968,16 @@ cwc_read_message(cwc_t *cwc, const char *state, int timeout) if((r = cwc_read(cwc, buf, 2, timeout))) { if (tvheadend_is_running()) - tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Read error (header): %s", - cwc->cwc_hostname, cwc->cwc_port, state, strerror(r)); + tvhinfo(LS_CWC, "%s:%i: %s: Read error (header): %s", + cwc->cwc_hostname, cwc->cwc_port, state, strerror(r)); return -1; } msglen = (buf[0] << 8) | buf[1]; if(msglen >= CWS_NETMSGSIZE) { if (tvheadend_is_running()) - tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Invalid message size: %d", - cwc->cwc_hostname, cwc->cwc_port, state, msglen); + tvhinfo(LS_CWC, "%s:%i: %s: Invalid message size: %d", + cwc->cwc_hostname, cwc->cwc_port, state, msglen); return -1; } @@ -986,14 +986,14 @@ cwc_read_message(cwc_t *cwc, const char *state, int timeout) if((r = cwc_read(cwc, cwc->cwc_buf + 2, msglen, 1000))) { if (tvheadend_is_running()) - tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Read error: %s", - cwc->cwc_hostname, cwc->cwc_port, state, strerror(r)); + tvhinfo(LS_CWC, "%s:%i: %s: Read error: %s", + cwc->cwc_hostname, cwc->cwc_port, state, strerror(r)); return -1; } if((msglen = des_decrypt(cwc->cwc_buf, msglen + 2, cwc)) < 15) { - tvhlog(LOG_INFO, "cwc", "%s:%i: %s: Decrypt failed", - cwc->cwc_hostname, cwc->cwc_port, state); + tvhinfo(LS_CWC, "%s:%i: %s: Decrypt failed", + cwc->cwc_hostname, cwc->cwc_port, state); return -1; } return msglen; @@ -1059,7 +1059,7 @@ cwc_writer_thread(void *aux) pthread_mutex_unlock(&cwc->cwc_writer_mutex); // int64_t ts = getfastmonoclock(); if (tvh_write(cwc->cwc_fd, cm->cm_data, cm->cm_len)) - tvhlog(LOG_INFO, "cwc", "write error %s", strerror(errno)); + tvhinfo(LS_CWC, "write error %s", strerror(errno)); // printf("Write took %lld usec\n", getfastmonoclock() - ts); free(cm); pthread_mutex_lock(&cwc->cwc_writer_mutex); @@ -1098,8 +1098,8 @@ cwc_session(cwc_t *cwc) * Get login key */ if((r = cwc_read(cwc, cwc->cwc_buf, 14, 5000))) { - tvhlog(LOG_INFO, "cwc", "%s:%i: No login key received: %s", - cwc->cwc_hostname, cwc->cwc_port, strerror(r)); + tvhinfo(LS_CWC, "%s:%i: No login key received: %s", + cwc->cwc_hostname, cwc->cwc_port, strerror(r)); return; } @@ -1115,8 +1115,8 @@ cwc_session(cwc_t *cwc) return; if(cwc->cwc_buf[12] != MSG_CLIENT_2_SERVER_LOGIN_ACK) { - tvhlog(LOG_INFO, "cwc", "%s:%i: Login failed", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, "%s:%i: Login failed", + cwc->cwc_hostname, cwc->cwc_port); return; } @@ -1130,8 +1130,8 @@ cwc_session(cwc_t *cwc) return; if(cwc->cwc_buf[12] != MSG_CARD_DATA) { - tvhlog(LOG_INFO, "cwc", "%s:%i: Card data request failed", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, "%s:%i: Card data request failed", + cwc->cwc_hostname, cwc->cwc_port); return; } @@ -1164,7 +1164,7 @@ cwc_session(cwc_t *cwc) break; cwc_running_reply(cwc, cwc->cwc_buf[12], cwc->cwc_buf, r); } - tvhdebug("cwc", "session thread exiting"); + tvhdebug(LS_CWC, "session thread exiting"); /** * Collect the writer thread @@ -1173,7 +1173,7 @@ cwc_session(cwc_t *cwc) cwc->cwc_writer_running = 0; tvh_cond_signal(&cwc->cwc_writer_cond, 0); pthread_join(writer_thread_id, NULL); - tvhlog(LOG_DEBUG, "cwc", "Write thread joined"); + tvhdebug(LS_CWC, "Write thread joined"); } /** @@ -1200,7 +1200,7 @@ cwc_thread(void *aux) snprintf(hostname, sizeof(hostname), "%s", cwc->cwc_hostname); port = cwc->cwc_port; - tvhlog(LOG_INFO, "cwc", "Attemping to connect to %s:%d", hostname, port); + tvhinfo(LS_CWC, "Attemping to connect to %s:%d", hostname, port); pthread_mutex_unlock(&cwc->cwc_mutex); @@ -1210,9 +1210,9 @@ cwc_thread(void *aux) if(fd == -1) { attempts++; - tvhlog(LOG_INFO, "cwc", - "Connection attempt to %s:%d failed: %s", - hostname, port, errbuf); + tvhinfo(LS_CWC, + "Connection attempt to %s:%d failed: %s", + hostname, port, errbuf); } else { if(cwc->cwc_running == 0) { @@ -1220,7 +1220,7 @@ cwc_thread(void *aux) break; } - tvhlog(LOG_INFO, "cwc", "Connected to %s:%d", hostname, port); + tvhinfo(LS_CWC, "Connected to %s:%d", hostname, port); attempts = 0; cwc->cwc_fd = fd; @@ -1230,8 +1230,8 @@ cwc_thread(void *aux) cwc->cwc_fd = -1; close(fd); - tvhlog(LOG_INFO, "cwc", "Disconnected from %s:%i", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, "Disconnected from %s:%i", + cwc->cwc_hostname, cwc->cwc_port); } if(cwc->cwc_running == 0) continue; @@ -1244,9 +1244,9 @@ cwc_thread(void *aux) d = 3; - tvhlog(LOG_INFO, "cwc", - "%s:%i: Automatic connection attempt in %d seconds", - cwc->cwc_hostname, cwc->cwc_port, d-1); + tvhinfo(LS_CWC, + "%s:%i: Automatic connection attempt in %d seconds", + cwc->cwc_hostname, cwc->cwc_port, d-1); mono = mclk() + sec2mono(d); do { @@ -1256,8 +1256,8 @@ cwc_thread(void *aux) } while (ERRNO_AGAIN(r)); } - tvhlog(LOG_INFO, "cwc", "%s:%i inactive", - cwc->cwc_hostname, cwc->cwc_port); + tvhinfo(LS_CWC, "%s:%i inactive", + cwc->cwc_hostname, cwc->cwc_port); cwc_free_cards(cwc); pthread_mutex_unlock(&cwc->cwc_mutex); return NULL; @@ -1290,8 +1290,8 @@ cwc_emm_send(void *aux, const uint8_t *radata, int ralen, void *mux) cs_card_data_t *pcard = aux; cwc_t *cwc = pcard->cwc; - tvhtrace("cwc", "sending EMM for %04x mux %p", pcard->cs_ra.caid, mux); - tvhlog_hexdump("cwc", radata, ralen); + tvhtrace(LS_CWC, "sending EMM for %04x mux %p", pcard->cs_ra.caid, mux); + tvhlog_hexdump(LS_CWC, radata, ralen); cwc_send_msg(cwc, radata, ralen, 0, 1, 0, 0); } @@ -1372,7 +1372,7 @@ cwc_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm) ct->ecm_state = ECM_INIT; ct->cs_channel = -1; t->s_dvb_prefcapid = 0; - tvhlog(LOG_DEBUG, "cwc", "Reset after unexpected or no reply for service \"%s\"", t->s_dvb_svcname); + tvhdebug(LS_CWC, "Reset after unexpected or no reply for service \"%s\"", t->s_dvb_svcname); } LIST_FOREACH(ep, &ct->cs_pids, ep_link) @@ -1381,7 +1381,7 @@ cwc_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm) if(ep == NULL) { if (ct->ecm_state == ECM_INIT) { // Validate prefered ECM PID - tvhlog(LOG_DEBUG, "cwc", "ECM state INIT"); + tvhdebug(LS_CWC, "ECM state INIT"); if(t->s_dvb_prefcapid_lock != PREFCAPID_OFF) { st = service_stream_find((service_t*)t, t->s_dvb_prefcapid); @@ -1392,7 +1392,7 @@ cwc_table_input(void *opaque, int pid, const uint8_t *data, int len, int emm) pcard->cs_ra.caid == c->caid && verify_provider(pcard, c->providerid)) goto prefcapid_ok; - tvhlog(LOG_DEBUG, "cwc", "Invalid prefered ECM (PID %d) found for service \"%s\"", t->s_dvb_prefcapid, t->s_dvb_svcname); + tvhdebug(LS_CWC, "Invalid prefered ECM (PID %d) found for service \"%s\"", t->s_dvb_prefcapid, t->s_dvb_svcname); t->s_dvb_prefcapid = 0; } @@ -1402,8 +1402,8 @@ prefcapid_ok: ep = calloc(1, sizeof(ecm_pid_t)); ep->ep_pid = pid; LIST_INSERT_HEAD(&ct->cs_pids, ep, ep_link); - tvhlog(LOG_DEBUG, "cwc", "Insert %s ECM (PID %d) for service \"%s\"", - t->s_dvb_prefcapid ? "preferred" : "new", pid, t->s_dvb_svcname); + tvhdebug(LS_CWC, "Insert %s ECM (PID %d) for service \"%s\"", + t->s_dvb_prefcapid ? "preferred" : "new", pid, t->s_dvb_svcname); } } if(ep == NULL) @@ -1469,15 +1469,15 @@ found: if(ct->cs_channel >= 0 && channel != -1 && ct->cs_channel != channel) { - tvhlog(LOG_DEBUG, "cwc", "Filtering ECM (PID %d)", channel); + tvhdebug(LS_CWC, "Filtering ECM (PID %d)", channel); goto end; } es->es_seq = cwc_send_msg(cwc, data, len, sid, 1, caid, provid); - tvhlog(LOG_DEBUG, "cwc", - "Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)", - chaninfo, section, ep->ep_last_section, t->s_dvb_svcname, es->es_seq); + tvhdebug(LS_CWC, + "Sending ECM%s section=%d/%d, for service \"%s\" (seqno: %d)", + chaninfo, section, ep->ep_last_section, t->s_dvb_svcname, es->es_seq); es->es_time = getfastmonoclock(); break; @@ -1649,8 +1649,8 @@ add: } if (reuse != 1) - tvhlog(LOG_DEBUG, "cwc", "%s %susing CWC %s:%d", - service_nicename(t), reuse ? "re" : "", cwc->cwc_hostname, cwc->cwc_port); + tvhdebug(LS_CWC, "%s %susing CWC %s:%d", + service_nicename(t), reuse ? "re" : "", cwc->cwc_hostname, cwc->cwc_port); end: pthread_mutex_unlock(&t->s_stream_mutex); @@ -1685,7 +1685,7 @@ cwc_caid_update(caclient_t *cac, mpegts_mux_t *mux, uint16_t caid, uint16_t pid, cwc_t *cwc = (cwc_t *)cac;; cs_card_data_t *pcard; - tvhtrace("cwc", + tvhtrace(LS_CWC, "caid update event - client %s mux %p caid %04x (%i) pid %04x (%i) valid %i", cac->cac_name, mux, caid, caid, pid, pid, valid); pthread_mutex_lock(&cwc->cwc_mutex); diff --git a/src/descrambler/descrambler.c b/src/descrambler/descrambler.c index 3072817e8..6de934a93 100644 --- a/src/descrambler/descrambler.c +++ b/src/descrambler/descrambler.c @@ -168,7 +168,7 @@ descrambler_init ( void ) if (idx + 1 >= MAX_QUICK_ECM_ENTRIES) continue; if ((s = htsmsg_get_str(e, "caid")) == NULL) continue; caid = strtol(s, NULL, 16); - tvhinfo("descrambler", "adding CAID %04X as quick ECM (%s)", caid, htsmsg_get_str(e, "name") ?: "unknown"); + tvhinfo(LS_DESCRAMBLER, "adding CAID %04X as quick ECM (%s)", caid, htsmsg_get_str(e, "name") ?: "unknown"); if (!quick_ecm_table) quick_ecm_table = malloc(sizeof(uint16_t) * MAX_QUICK_ECM_ENTRIES); quick_ecm_table[idx++] = caid; @@ -183,7 +183,7 @@ descrambler_init ( void ) if (idx + 1 >= MAX_CONSTCW_ENTRIES) continue; if ((s = htsmsg_get_str(e, "caid")) == NULL) continue; caid = strtol(s, NULL, 16); - tvhinfo("descrambler", "adding CAID %04X as constant crypto-word (%s)", caid, htsmsg_get_str(e, "name") ?: "unknown"); + tvhinfo(LS_DESCRAMBLER, "adding CAID %04X as constant crypto-word (%s)", caid, htsmsg_get_str(e, "name") ?: "unknown"); if (!constcw_table) constcw_table = malloc(sizeof(uint16_t) * MAX_CONSTCW_ENTRIES); constcw_table[idx++] = caid; @@ -283,7 +283,7 @@ descrambler_service_start ( service_t *t ) dr->dr_key_interval = sec2mono(10); dr->dr_key_const = constcw; if (constcw) - tvhtrace("descrambler", "using constcw for \"%s\"", t->s_nicename); + tvhtrace(LS_DESCRAMBLER, "using constcw for \"%s\"", t->s_nicename); dr->dr_skip = 0; dr->dr_force_skip = 0; tvhcsa_init(&dr->dr_csa); @@ -361,7 +361,7 @@ descrambler_notify_nokey( th_descrambler_runtime_t *dr ) mpegts_service_t *t = (mpegts_service_t *)dr->dr_service; descramble_info_t *di; - tvhlog(LOG_DEBUG, "descrambler", "no key for service='%s'", t->s_dvb_svcname); + tvhdebug(LS_DESCRAMBLER, "no key for service='%s'", t->s_dvb_svcname); di = calloc(1, sizeof(*di)); di->pid = t->s_pmt_pid; @@ -379,7 +379,7 @@ descrambler_notify( th_descrambler_t *td, mpegts_service_t *t = (mpegts_service_t *)td->td_service; descramble_info_t *di; - tvhlog(LOG_DEBUG, "descrambler", "info - service='%s' caid=%04X(%s) " + tvhdebug(LS_DESCRAMBLER, "info - service='%s' caid=%04X(%s) " "provid=%06X ecmtime=%d hops=%d " "reader='%s' from='%s' protocol='%s'%s", t->s_dvb_svcname, caid, cardsystem, provid, @@ -439,13 +439,13 @@ descrambler_keys ( th_descrambler_t *td, int type, LIST_FOREACH(td2, &t->s_descramblers, td_service_link) if (td2 != td && td2->td_keystate == DS_RESOLVED) { - tvhlog(LOG_DEBUG, "descrambler", - "Already has a key from %s for service \"%s\", " - "ignoring key from \"%s\"%s", - td2->td_nicename, - ((mpegts_service_t *)td2->td_service)->s_dvb_svcname, - td->td_nicename, - dr->dr_key_const ? " (const)" : ""); + tvhdebug(LS_DESCRAMBLER, + "Already has a key from %s for service \"%s\", " + "ignoring key from \"%s\"%s", + td2->td_nicename, + ((mpegts_service_t *)td2->td_service)->s_dvb_svcname, + td->td_nicename, + dr->dr_key_const ? " (const)" : ""); td->td_keystate = DS_IDLE; if (td->td_ecm_idle) td->td_ecm_idle(td); @@ -469,13 +469,13 @@ descrambler_keys ( th_descrambler_t *td, int type, if (j) { if (td->td_keystate != DS_RESOLVED) - tvhlog(LOG_DEBUG, "descrambler", - "Obtained keys from %s for service \"%s\"%s", - td->td_nicename, - ((mpegts_service_t *)t)->s_dvb_svcname, - dr->dr_key_const ? " (const)" : ""); + tvhdebug( LS_DESCRAMBLER, + "Obtained keys from %s for service \"%s\"%s", + td->td_nicename, + ((mpegts_service_t *)t)->s_dvb_svcname, + dr->dr_key_const ? " (const)" : ""); if (dr->dr_csa.csa_keylen == 8) { - tvhtrace("descrambler", "Obtained keys " + tvhtrace(LS_DESCRAMBLER, "Obtained keys " "%02X%02X%02X%02X%02X%02X%02X%02X:%02X%02X%02X%02X%02X%02X%02X%02X" " from %s for service \"%s\"", even[0], even[1], even[2], even[3], even[4], even[5], even[6], even[7], @@ -483,7 +483,7 @@ descrambler_keys ( th_descrambler_t *td, int type, td->td_nicename, ((mpegts_service_t *)t)->s_dvb_svcname); } else if (dr->dr_csa.csa_keylen == 16) { - tvhtrace("descrambler", "Obtained keys " + tvhtrace(LS_DESCRAMBLER, "Obtained keys " "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X:" "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X" " from %s for service \"%s\"", @@ -494,18 +494,18 @@ descrambler_keys ( th_descrambler_t *td, int type, td->td_nicename, ((mpegts_service_t *)t)->s_dvb_svcname); } else { - tvhtrace("descrambler", "Unknown keys from %s for for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "Unknown keys from %s for for service \"%s\"", td->td_nicename, ((mpegts_service_t *)t)->s_dvb_svcname); } dr->dr_ecm_last_key_time = mclk(); td->td_keystate = DS_RESOLVED; td->td_service->s_descrambler = td; } else { - tvhlog(LOG_DEBUG, "descrambler", - "Empty keys received from %s for service \"%s\"%s", - td->td_nicename, - ((mpegts_service_t *)t)->s_dvb_svcname, - dr->dr_key_const ? " (const)" : ""); + tvhdebug(LS_DESCRAMBLER, + "Empty keys received from %s for service \"%s\"%s", + td->td_nicename, + ((mpegts_service_t *)t)->s_dvb_svcname, + dr->dr_key_const ? " (const)" : ""); } fin: @@ -559,7 +559,7 @@ descrambler_flush_table_data( service_t *t ) if (mux == NULL) return; - tvhtrace("descrambler", "flush table data for service \"%s\"", ms->s_dvb_svcname); + tvhtrace(LS_DESCRAMBLER, "flush table data for service \"%s\"", ms->s_dvb_svcname); pthread_mutex_lock(&mux->mm_descrambler_lock); TAILQ_FOREACH(dt, &mux->mm_descrambler_tables, link) { if (dt->table == NULL || dt->table->mt_service != ms) @@ -717,7 +717,7 @@ descrambler_descramble ( service_t *t, if (key_valid(dr, ki) == 0) goto next; if (key_changed(dr, ki, dd->dd_timestamp)) { - tvhtrace("descrambler", "stream key changed to %s for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "stream key changed to %s for service \"%s\"", (ki & 0x40) ? "odd" : "even", ((mpegts_service_t *)t)->s_dvb_svcname); if (key_late(dr, ki, dd->dd_timestamp)) { @@ -745,18 +745,18 @@ descrambler_descramble ( service_t *t, if ((ki & 0x80) != 0x00) { if (key_valid(dr, ki) == 0) { if (!key_started(dr, ki) && tvhlog_limit(&dr->dr_loglimit_key, 10)) - tvhwarn("descrambler", "%s %s", + tvhwarn(LS_DESCRAMBLER, "%s %s", ((mpegts_service_t *)t)->s_dvb_svcname, (ki & 0x40) ? "odd stream key is not valid" : "even stream key is not valid"); goto next; } if (key_changed(dr, ki, mclk())) { - tvhtrace("descrambler", "stream key changed to %s for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "stream key changed to %s for service \"%s\"", (ki & 0x40) ? "odd" : "even", ((mpegts_service_t *)t)->s_dvb_svcname); if (key_late(dr, ki, mclk())) { - tvherror("descrambler", "ECM - key late (%"PRId64" ms) for service \"%s\"", + tvherror(LS_DESCRAMBLER, "ECM - key late (%"PRId64" ms) for service \"%s\"", mono2ms(mclk() - dr->dr_ecm_last_key_time), ((mpegts_service_t *)t)->s_dvb_svcname); descrambler_notify_nokey(dr); @@ -787,7 +787,7 @@ next: /* do not use the first TS packet to decide - it may be wrong */ while (dr->dr_queue_total > 20 * 188) { if (descrambler_data_key_check(dr, ki & 0xc0, 20 * 188)) { - tvhtrace("descrambler", "initial stream key set to %s for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "initial stream key set to %s for service \"%s\"", (ki & 0x40) ? "odd" : "even", ((mpegts_service_t *)t)->s_dvb_svcname); key_update(dr, ki, mclk()); @@ -798,7 +798,7 @@ next: } } else if (dr->dr_key_index != (ki & 0x40) && dr->dr_key_start + sec2mono(2) < mclk()) { - tvhtrace("descrambler", "stream key changed to %s for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "stream key changed to %s for service \"%s\"", (ki & 0x40) ? "odd" : "even", ((mpegts_service_t *)t)->s_dvb_svcname); key_update(dr, ki, mclk()); @@ -814,10 +814,10 @@ next: descrambler_data_cut(dr, MAX((dbuflen / 10) * 188, len)); if (dr->dr_last_err + sec2mono(10) < mclk()) { dr->dr_last_err = mclk(); - tvherror("descrambler", "cannot decode packets for service \"%s\"", + tvherror(LS_DESCRAMBLER, "cannot decode packets for service \"%s\"", ((mpegts_service_t *)t)->s_dvb_svcname); } else { - tvhtrace("descrambler", "cannot decode packets for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "cannot decode packets for service \"%s\"", ((mpegts_service_t *)t)->s_dvb_svcname); } } @@ -883,7 +883,7 @@ descrambler_table_callback ds->quick_ecm_called = 1; dr->dr_quick_ecm = descrambler_quick_ecm(mt->mt_service, mt->mt_pid); if (dr->dr_quick_ecm) - tvhdebug("descrambler", "quick ECM enabled for service '%s'", + tvhdebug(LS_DESCRAMBLER, "quick ECM enabled for service '%s'", t->s_dvb_svcname); } if ((ptr[0] & 0xfe) == 0x80) { /* 0x80 = even, 0x81 = odd */ @@ -891,14 +891,14 @@ descrambler_table_callback if (dr->dr_quick_ecm) dr->dr_key_valid &= ~(1 << ((ptr[0] & 1) + 6)); /* 0x40 = even, 0x80 = odd */ } - tvhtrace("descrambler", "ECM message %02x (section %d, len %d, pid %d) for service \"%s\"", + tvhtrace(LS_DESCRAMBLER, "ECM message %02x (section %d, len %d, pid %d) for service \"%s\"", ptr[0], des->number, len, mt->mt_pid, t->s_dvb_svcname); } } else - tvhtrace("descrambler", "Unknown fast table message %02x (section %d, len %d, pid %d)", + tvhtrace(LS_DESCRAMBLER, "Unknown fast table message %02x (section %d, len %d, pid %d)", ptr[0], des->number, len, mt->mt_pid); } else { - tvhtrace("descrambler", "EMM message %02x:%02x:%02x:%02x (len %d, pid %d)", + tvhtrace(LS_DESCRAMBLER, "EMM message %02x:%02x:%02x:%02x (len %d, pid %d)", ptr[0], ptr[1], ptr[2], ptr[3], len, mt->mt_pid); } } @@ -936,7 +936,7 @@ descrambler_open_pid_( mpegts_mux_t *mux, void *opaque, int pid, TAILQ_INIT(&dt->sections); dt->table = mpegts_table_add(mux, 0, 0, descrambler_table_callback, dt, (flags & MT_FAST) ? "ecm" : "emm", - MT_FULL | MT_DEFER | flags, pid, + LS_TBL_CSA, MT_FULL | MT_DEFER | flags, pid, MPS_WEIGHT_CA); if (dt->table) dt->table->mt_service = (mpegts_service_t *)service; @@ -947,7 +947,7 @@ descrambler_open_pid_( mpegts_mux_t *mux, void *opaque, int pid, ds->opaque = opaque; LIST_INIT(&ds->ecmsecs); TAILQ_INSERT_TAIL(&dt->sections, ds, link); - tvhtrace("descrambler", "mux %p open pid %04X (%i) (flags 0x%04x) for %p", mux, pid, pid, flags, opaque); + tvhtrace(LS_DESCRAMBLER, "mux %p open pid %04X (%i) (flags 0x%04x) for %p", mux, pid, pid, flags, opaque); return 1; } @@ -994,7 +994,7 @@ descrambler_close_pid_( mpegts_mux_t *mux, void *opaque, int pid ) free(dt); } free(ds); - tvhtrace("descrambler", "mux %p close pid %04X (%i) (flags 0x%04x) for %p", mux, pid, pid, flags, opaque); + tvhtrace(LS_DESCRAMBLER, "mux %p close pid %04X (%i) (flags 0x%04x) for %p", mux, pid, pid, flags, opaque); return 1; } } @@ -1023,7 +1023,7 @@ descrambler_flush_tables( mpegts_mux_t *mux ) if (mux == NULL) return; - tvhtrace("descrambler", "mux %p - flush tables", mux); + tvhtrace(LS_DESCRAMBLER, "mux %p - flush tables", mux); caclient_caid_update(mux, 0, 0, -1); pthread_mutex_lock(&mux->mm_descrambler_lock); mux->mm_descrambler_flush = 1; @@ -1057,8 +1057,8 @@ descrambler_cat_data( mpegts_mux_t *mux, const uint8_t *data, int len ) uint16_t caid = 0, pid = 0; TAILQ_HEAD(,descrambler_emm) removing; - tvhtrace("descrambler", "CAT data (len %d)", len); - tvhlog_hexdump("descrambler", data, len); + tvhtrace(LS_DESCRAMBLER, "CAT data (len %d)", len); + tvhlog_hexdump(LS_DESCRAMBLER, data, len); pthread_mutex_lock(&mux->mm_descrambler_lock); TAILQ_FOREACH(emm, &mux->mm_descrambler_emms, link) emm->to_be_removed = 1; @@ -1080,7 +1080,7 @@ descrambler_cat_data( mpegts_mux_t *mux, const uint8_t *data, int len ) if (emm->caid == caid) { emm->to_be_removed = 0; if (emm->pid == EMM_PID_UNKNOWN) { - tvhtrace("descrambler", "attach emm caid %04X (%i) pid %04X (%i)", caid, caid, pid, pid); + tvhtrace(LS_DESCRAMBLER, "attach emm caid %04X (%i) pid %04X (%i)", caid, caid, pid, pid); emm->pid = pid; descrambler_open_pid_(mux, emm->opaque, pid, emm->callback, NULL); } @@ -1098,7 +1098,7 @@ next: if (emm->pid != EMM_PID_UNKNOWN) { caid = emm->caid; pid = emm->pid; - tvhtrace("descrambler", "close emm caid %04X (%i) pid %04X (%i)", caid, caid, pid, pid); + tvhtrace(LS_DESCRAMBLER, "close emm caid %04X (%i) pid %04X (%i)", caid, caid, pid, pid); descrambler_close_pid_(mux, emm->opaque, pid); } TAILQ_REMOVE(&mux->mm_descrambler_emms, emm, link); @@ -1146,7 +1146,7 @@ unlock: } TAILQ_INSERT_TAIL(&mux->mm_descrambler_emms, emm, link); if (pid != EMM_PID_UNKNOWN) { - tvhtrace("descrambler", + tvhtrace(LS_DESCRAMBLER, "attach emm caid %04X (%i) pid %04X (%i) - direct", caid, caid, pid, pid); descrambler_open_pid_(mux, opaque, pid, callback, NULL); @@ -1175,7 +1175,7 @@ descrambler_close_emm( mpegts_mux_t *mux, void *opaque, int caid ) pid = emm->pid; if (pid != EMM_PID_UNKNOWN) { caid = emm->caid; - tvhtrace("descrambler", "close emm caid %04X (%i) pid %04X (%i) - direct", caid, caid, pid, pid); + tvhtrace(LS_DESCRAMBLER, "close emm caid %04X (%i) pid %04X (%i) - direct", caid, caid, pid, pid); descrambler_close_pid_(mux, opaque, pid); } pthread_mutex_unlock(&mux->mm_descrambler_lock); diff --git a/src/descrambler/emm_reass.c b/src/descrambler/emm_reass.c index cf5df654a..34af9cf4f 100644 --- a/src/descrambler/emm_reass.c +++ b/src/descrambler/emm_reass.c @@ -329,13 +329,13 @@ emm_viaccess crc = tvh_crc32(ass2, len, 0xffffffff); if (!emm_cache_lookup(ra, crc)) { - tvhlog(LOG_DEBUG, "cwc", - "Send EMM " - "%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" - "...%02x.%02x.%02x.%02x", - ass2[0], ass2[1], ass2[2], ass2[3], - ass2[4], ass2[5], ass2[6], ass2[7], - ass2[len-4], ass2[len-3], ass2[len-2], ass2[len-1]); + tvhdebug(LS_CWC, + "Send EMM " + "%02x.%02x.%02x.%02x.%02x.%02x.%02x.%02x" + "...%02x.%02x.%02x.%02x", + ass2[0], ass2[1], ass2[2], ass2[3], + ass2[4], ass2[5], ass2[6], ass2[7], + ass2[len-4], ass2[len-3], ass2[len-2], ass2[len-1]); send(aux, ass2, len, mux); emm_cache_insert(ra, crc); } @@ -441,7 +441,7 @@ emm_streamguard if (len < 1) return; - tvhlog(LOG_INFO, "cwc", "emm_streamguard streamguard card data emm get,here lots of works todo..."); + tvhinfo(LS_CWC, "emm_streamguard streamguard card data emm get,here lots of works todo..."); if (data[0] == 0x87) { match = memcmp(&data[3], &ra->ua[4], 4) == 0; @@ -579,8 +579,8 @@ void emm_filter(emm_reass_t *ra, const uint8_t *data, int len, void *mux, emm_send_t send, void *aux) { - tvhtrace("emm-filter", "%s - len %d mux %p", caid2name(ra->caid), len, mux); - tvhlog_hexdump("emm-filter", data, len); + tvhtrace(LS_CWC, "emm filter : %s - len %d mux %p", caid2name(ra->caid), len, mux); + tvhlog_hexdump(LS_CWC, data, len); if (ra->do_emm) ra->do_emm(ra, data, len, mux, send, aux); } diff --git a/src/descrambler/ffdecsa/ffdecsa_interface.c b/src/descrambler/ffdecsa/ffdecsa_interface.c index ae100432e..f5a93c4db 100644 --- a/src/descrambler/ffdecsa/ffdecsa_interface.c +++ b/src/descrambler/ffdecsa/ffdecsa_interface.c @@ -180,7 +180,7 @@ ffdecsa_init(void) #ifdef CONFIG_SSE2 if (std_caps & (1<<26)) { current = funcs_128sse2; - tvhlog(LOG_INFO, "CSA", "Using SSE2 128bit parallel descrambling"); + tvhinfo(LS_CSA, "Using SSE2 128bit parallel descrambling"); return; } #endif @@ -188,7 +188,7 @@ ffdecsa_init(void) #ifdef CONFIG_MMX if (std_caps & (1<<23)) { current = funcs_64mmx; - tvhlog(LOG_INFO, "CSA", "Using MMX 64bit parallel descrambling"); + tvhinfo(LS_CSA, "Using MMX 64bit parallel descrambling"); return; } #endif @@ -198,7 +198,7 @@ ffdecsa_init(void) #endif #endif - tvhlog(LOG_INFO, "CSA", "Using 32bit parallel descrambling"); + tvhinfo(LS_CSA, "Using 32bit parallel descrambling"); } diff --git a/src/download.c b/src/download.c index 48af26a64..7387a6e40 100644 --- a/src/download.c +++ b/src/download.c @@ -39,12 +39,12 @@ download_file(download_t *dn, const char *filename) fd = tvh_open(filename, O_RDONLY, 0); if (fd < 0) { - tvherror(dn->log, "unable to open file '%s': %s", + tvherror(dn->subsys, "unable to open file '%s': %s", filename, strerror(errno)); return -1; } if (fstat(fd, &st) || st.st_size == 0) { - tvherror(dn->log, "unable to stat file '%s': %s", + tvherror(dn->subsys, "unable to stat file '%s': %s", filename, strerror(errno)); close(fd); return -1; @@ -122,7 +122,7 @@ download_fetch_complete(http_client_t *hc) if (hc->hc_code == HTTP_STATUS_OK && hc->hc_result == 0 && hc->hc_data_size > 0) dn->process(dn->aux, last_url, hc->hc_url, hc->hc_data, hc->hc_data_size); else - tvherror(dn->log, "unable to fetch data from url [%d-%d/%zd]", + tvherror(dn->subsys, "unable to fetch data from url [%d-%d/%zd]", hc->hc_code, hc->hc_result, hc->hc_data_size); /* note: http_client_close must be called outside http_client callbacks */ @@ -187,7 +187,7 @@ download_pipe_read(void *aux) if (ERRNO_AGAIN(errno)) break; failed: - tvherror(dn->log, "pipe: read failed: %d", errno); + tvherror(dn->subsys, "pipe: read failed: %d", errno); download_pipe_close(dn); return; } @@ -210,7 +210,7 @@ download_pipe(download_t *dn, const char *args) /* Arguments */ if (spawn_parse_args(&argv, 64, args, NULL)) { - tvherror(dn->log, "pipe: unable to parse arguments (%s)", args); + tvherror(dn->subsys, "pipe: unable to parse arguments (%s)", args); return -1; } @@ -222,7 +222,7 @@ download_pipe(download_t *dn, const char *args) if (r < 0) { dn->pipe_fd = -1; dn->pipe_pid = 0; - tvherror(dn->log, "pipe: cannot start (%s)", args); + tvherror(dn->subsys, "pipe: cannot start (%s)", args); return -1; } @@ -265,12 +265,12 @@ download_fetch(void *aux) } if (urlparse(dn->url, &u) < 0) { - tvherror(dn->log, "wrong url"); + tvherror(dn->subsys, "wrong url"); goto stop; } hc = http_client_connect(dn, HTTP_VERSION_1_1, u.scheme, u.host, u.port, NULL); if (hc == NULL) { - tvherror(dn->log, "unable to open http client"); + tvherror(dn->subsys, "unable to open http client"); goto stop; } hc->hc_handle_location = 1; @@ -280,7 +280,7 @@ download_fetch(void *aux) http_client_ssl_peer_verify(hc, dn->ssl_peer_verify); if (http_client_simple(hc, &u) < 0) { http_client_close(hc); - tvherror(dn->log, "unable to send http command"); + tvherror(dn->subsys, "unable to send http command"); goto stop; } @@ -298,10 +298,10 @@ done: * */ void -download_init( download_t *dn, const char *log ) +download_init( download_t *dn, int subsys ) { memset(dn, 0, sizeof(*dn)); - dn->log = strdup(log); + dn->subsys = subsys; dn->pipe_fd = -1; sbuf_init(&dn->pipe_sbuf); } @@ -337,6 +337,5 @@ download_done( download_t *dn ) download_pipe_close(dn); mtimer_disarm(&dn->fetch_timer); mtimer_disarm(&dn->pipe_read_timer); - free(dn->log); dn->log = NULL; free(dn->url); dn->url = NULL; } diff --git a/src/download.h b/src/download.h index 9ac7287e5..8c791174a 100644 --- a/src/download.h +++ b/src/download.h @@ -23,7 +23,7 @@ #include "http.h" typedef struct download { - char *log; + int subsys; char *url; void *aux; int ssl_peer_verify; @@ -39,7 +39,7 @@ typedef struct download { pid_t pipe_pid; } download_t; -void download_init ( download_t *dn, const char *log ); +void download_init ( download_t *dn, int subsys ); void download_start( download_t *dn, const char *url, void *aux ); void download_done ( download_t *dn ); diff --git a/src/dvr/dvr_autorec.c b/src/dvr/dvr_autorec.c index 59fe36f86..66a3469fc 100644 --- a/src/dvr/dvr_autorec.c +++ b/src/dvr/dvr_autorec.c @@ -123,7 +123,7 @@ dvr_autorec_completed(dvr_autorec_entry_t *dae, int error_code) if (count <= max_count) break; if (de_prev) { - tvhinfo("dvr", "autorec %s removing recordings %s (allowed count %u total %u)", + tvhinfo(LS_DVR, "autorec %s removing recordings %s (allowed count %u total %u)", dae->dae_name, idnode_uuid_as_str(&de_prev->de_id, ubuf), max_count, total); dvr_entry_cancel_delete(de_prev, 0); } @@ -280,7 +280,7 @@ dvr_autorec_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&dae->dae_id, uuid, &dvr_autorec_entry_class, 0)) { if (uuid) - tvhwarn("dvr", "invalid autorec entry uuid '%s'", uuid); + tvhwarn(LS_DVR, "invalid autorec entry uuid '%s'", uuid); free(dae); return NULL; } @@ -324,7 +324,7 @@ dvr_autorec_update_htsp(dvr_autorec_entry_t *dae, htsmsg_t *conf) { idnode_update(&dae->dae_id, conf); idnode_changed(&dae->dae_id); - tvhlog(LOG_INFO, "autorec", "\"%s\" on \"%s\": Updated", dae->dae_title ? dae->dae_title : "", + tvhinfo(LS_DVR, "autorec \"%s\" on \"%s\": Updated", dae->dae_title ? dae->dae_title : "", (dae->dae_channel && dae->dae_channel->ch_name) ? dae->dae_channel->ch_name : "any channel"); } diff --git a/src/dvr/dvr_config.c b/src/dvr/dvr_config.c index 7fbe2fb8a..18eac388b 100644 --- a/src/dvr/dvr_config.c +++ b/src/dvr/dvr_config.c @@ -85,10 +85,10 @@ dvr_config_find_by_name_default(const char *name) if (cfg == NULL) { if (name && *name) - tvhlog(LOG_WARNING, "dvr", "Configuration '%s' not found, using default", name); + tvhwarn(LS_DVR, "Configuration '%s' not found, using default", name); cfg = dvrdefaultconfig; } else if (!cfg->dvr_enabled) { - tvhlog(LOG_WARNING, "dvr", "Configuration '%s' not enabled, using default", name); + tvhwarn(LS_DVR, "Configuration '%s' not enabled, using default", name); cfg = dvrdefaultconfig; } @@ -170,7 +170,7 @@ dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf) if (idnode_insert(&cfg->dvr_id, uuid, &dvr_config_class, 0)) { if (uuid) - tvherror("dvr", "invalid config uuid '%s'", uuid); + tvherror(LS_DVR, "invalid config uuid '%s'", uuid); free(cfg); return NULL; } @@ -204,7 +204,7 @@ dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf) cfg->dvr_valid = 1; } - tvhinfo("dvr", "Creating new configuration '%s'", cfg->dvr_config_name); + tvhinfo(LS_DVR, "Creating new configuration '%s'", cfg->dvr_config_name); if (cfg->dvr_profile == NULL) { cfg->dvr_profile = profile_find_by_name("dvr", NULL); @@ -213,7 +213,7 @@ dvr_config_create(const char *name, const char *uuid, htsmsg_t *conf) } if (dvr_config_is_default(cfg) && dvr_config_find_by_name(NULL)) { - tvherror("dvr", "Unable to create second default config, removing"); + tvherror(LS_DVR, "Unable to create second default config, removing"); LIST_INSERT_HEAD(&dvrconfigs, cfg, config_link); dvr_config_destroy(cfg, 0); cfg = NULL; @@ -239,7 +239,7 @@ dvr_config_destroy(dvr_config_t *cfg, int delconf) idnode_save_check(&cfg->dvr_id, delconf); if (delconf) { - tvhinfo("dvr", "Deleting configuration '%s'", cfg->dvr_config_name); + tvhinfo(LS_DVR, "Deleting configuration '%s'", cfg->dvr_config_name); hts_settings_remove("dvr/config/%s", idnode_uuid_as_str(&cfg->dvr_id, ubuf)); } LIST_REMOVE(cfg, config_link); @@ -294,12 +294,12 @@ dvr_config_storage_check(dvr_config_t *cfg) cfg->dvr_storage = strdup(getcwd(buf, sizeof(buf))); } - tvhlog(LOG_WARNING, "dvr", - "Output directory for video recording is not yet configured " - "for DVR configuration \"%s\". " - "Defaulting to to \"%s\". " - "This can be changed from the web user interface.", - cfg->dvr_config_name, cfg->dvr_storage); + tvhwarn(LS_DVR, + "Output directory for video recording is not yet configured " + "for DVR configuration \"%s\". " + "Defaulting to to \"%s\". " + "This can be changed from the web user interface.", + cfg->dvr_config_name, cfg->dvr_storage); } /** @@ -510,7 +510,7 @@ dvr_config_delete(const char *name) if (!dvr_config_is_default(cfg)) dvr_config_destroy(cfg, 1); else - tvhwarn("dvr", "Attempt to delete default config ignored"); + tvhwarn(LS_DVR, "Attempt to delete default config ignored"); } /** diff --git a/src/dvr/dvr_cutpoints.c b/src/dvr/dvr_cutpoints.c index 4b496d708..8a12a2214 100644 --- a/src/dvr/dvr_cutpoints.c +++ b/src/dvr/dvr_cutpoints.c @@ -73,7 +73,7 @@ dvr_parse_edl /* Sanity Checks */ if(start < 0 || end < 0 || end < start || start == end || action < DVR_CP_CUT || action > DVR_CP_COMM) { - tvhwarn("dvr", "Insane entry: start=%f, end=%f. Skipping.", start, end); + tvhwarn(LS_DVR, "Insane entry: start=%f, end=%f. Skipping.", start, end); return 1; } @@ -120,7 +120,7 @@ dvr_parse_comskip /* Sanity Checks */ if(start < 0 || end < 0 || end < start || start == end) { - tvherror("dvr", "Insane EDL entry: start=%d, end=%d. Skipping.", start, end); + tvherror(LS_DVR, "Insane EDL entry: start=%d, end=%d. Skipping.", start, end); return 1; } diff --git a/src/dvr/dvr_db.c b/src/dvr/dvr_db.c index dba3ec439..38785c7f9 100644 --- a/src/dvr/dvr_db.c +++ b/src/dvr/dvr_db.c @@ -95,7 +95,7 @@ dvr_entry_trace_(const char *file, int line, dvr_entry_t *de, const char *fmt, . snprintf(buf, sizeof(buf), "entry %s - %s", idnode_uuid_as_str(&de->de_id, ubuf), fmt); - tvhlogv(file, line, LOG_TRACE, "dvr", buf, &args); + tvhlogv(file, line, LOG_TRACE, LS_DVR, buf, &args); va_end(args); } @@ -120,7 +120,7 @@ dvr_entry_trace_time2_(const char *file, int line, t2name ? " " : "", t2name ? gmtime2local(t2, t2buf, sizeof(t2buf)) : "", fmt); - tvhlogv(file, line, LOG_TRACE, "dvr", buf, &args); + tvhlogv(file, line, LOG_TRACE, LS_DVR, buf, &args); va_end(args); } @@ -813,7 +813,7 @@ dvr_entry_create(const char *uuid, htsmsg_t *conf, int clone) if (idnode_insert(&de->de_id, uuid, &dvr_entry_class, IDNODE_SHORT_UUID)) { if (uuid) - tvhwarn("dvr", "invalid entry uuid '%s'", uuid); + tvhwarn(LS_DVR, "invalid entry uuid '%s'", uuid); free(de); return NULL; } @@ -842,7 +842,7 @@ dvr_entry_create(const char *uuid, htsmsg_t *conf, int clone) de2->de_sched_state != DVR_COMPLETED && de2->de_sched_state != DVR_MISSED_TIME && strcmp(de2->de_owner ?: "", de->de_owner ?: "") == 0) { - tvhlog(LOG_INFO, "dvr", "delete entry %s \"%s\" on \"%s\" start time %"PRId64", " + tvhinfo(LS_DVR, "delete entry %s \"%s\" on \"%s\" start time %"PRId64", " "scheduled for recording by \"%s\" (duplicate with %s)", idnode_uuid_as_str(&de->de_id, ubuf), lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), @@ -960,7 +960,7 @@ dvr_entry_create_(int enabled, const char *config_uuid, epg_broadcast_t *e, if (strftime(tbuf, sizeof(tbuf), "%F %T", &tm) <= 0) *tbuf = 0; - tvhlog(LOG_INFO, "dvr", "entry %s \"%s\" on \"%s\" starting at %s, " + tvhinfo(LS_DVR, "entry %s \"%s\" on \"%s\" starting at %s, " "scheduled for recording by \"%s\"", idnode_uuid_as_str(&de->de_id, ubuf), lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), tbuf, creator ?: ""); @@ -1357,8 +1357,8 @@ dvr_entry_create_by_autorec(int enabled, epg_broadcast_t *e, dvr_autorec_entry_t (de->de_sched_state == DVR_RECORDING)) count++; if (count >= max_count) { - tvhlog(LOG_DEBUG, "dvr", "Autorecord \"%s\": Not scheduling \"%s\" because of autorecord max schedules limit reached", - dae->dae_name, lang_str_get(e->episode->title, NULL)); + tvhinfo(LS_DVR, "Autorecord \"%s\": Not scheduling \"%s\" because of autorecord max schedules limit reached", + dae->dae_name, lang_str_get(e->episode->title, NULL)); return; } } @@ -1719,12 +1719,12 @@ dosave: idnode_changed(&de->de_id); htsp_dvr_entry_update(de); if (tvhlog_limit(&de->de_update_limit, 60)) { - tvhlog(LOG_INFO, "dvr", "\"%s\" on \"%s\": Updated%s (%s)", - lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), - updated ? " Timer" : "", - dvr_updated_str(buf, sizeof(buf), save)); + tvhinfo(LS_DVR, "\"%s\" on \"%s\": Updated%s (%s)", + lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), + updated ? " Timer" : "", + dvr_updated_str(buf, sizeof(buf), save)); } else { - tvhtrace("dvr", "\"%s\" on \"%s\": Updated%s (%s)", + tvhtrace(LS_DVR, "\"%s\" on \"%s\": Updated%s (%s)", lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), updated ? " Timer" : "", dvr_updated_str(buf, sizeof(buf), save)); @@ -1798,7 +1798,7 @@ dvr_event_replaced(epg_broadcast_t *e, epg_broadcast_t *new_e) RB_FOREACH(e2, &ch->ch_epg_schedule, sched_link) { if (dvr_entry_fuzzy_match(de, e2, e2->dvb_eid, de->de_config->dvr_update_window)) { - tvhtrace("dvr", " replacement event %s on %s @ start %s stop %s", + tvhtrace(LS_DVR, " replacement event %s on %s @ start %s stop %s", epg_broadcast_get_title(e2, NULL), channel_get_name(ch), gmtime2local(e2->start, t1buf, sizeof(t1buf)), @@ -1878,7 +1878,7 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn if (esrc != EPG_SOURCE_EIT || e->dvb_eid == 0 || e->channel == NULL) return; - tvhtrace("dvr", "dvr event running check for %s on %s running %d", + tvhtrace(LS_DVR, "dvr event running check for %s on %s running %d", epg_broadcast_get_title(e, NULL), channel_get_name(e->channel), running); @@ -1891,14 +1891,14 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn } if (running == EPG_RUNNING_NOW && de->de_dvb_eid == e->dvb_eid) { if (de->de_running_pause) { - tvhdebug("dvr", "dvr entry %s event %s on %s - EPG unpause", + tvhdebug(LS_DVR, "dvr entry %s event %s on %s - EPG unpause", idnode_uuid_as_str(&de->de_id, ubuf), epg_broadcast_get_title(e, NULL), channel_get_name(e->channel)); atomic_set_time_t(&de->de_running_pause, 0); } if (!de->de_running_start) { - tvhdebug("dvr", "dvr entry %s event %s on %s - EPG marking start", + tvhdebug(LS_DVR, "dvr entry %s event %s on %s - EPG marking start", idnode_uuid_as_str(&de->de_id, ubuf), epg_broadcast_get_title(e, NULL), channel_get_name(e->channel)); @@ -1907,7 +1907,7 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn if (dvr_entry_get_start_time(de, 1) > gclk()) { atomic_set_time_t(&de->de_start, gclk()); dvr_entry_set_timer(de); - tvhdebug("dvr", "dvr entry %s event %s on %s - EPG start", + tvhdebug(LS_DVR, "dvr entry %s event %s on %s - EPG start", idnode_uuid_as_str(&de->de_id, ubuf), epg_broadcast_get_title(e, NULL), channel_get_name(e->channel)); @@ -1925,7 +1925,7 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn srcname = de->de_dvb_eid == e->dvb_eid ? "event" : "other running event"; if (!de->de_running_stop || de->de_running_start > de->de_running_stop) { - tvhdebug("dvr", "dvr entry %s %s %s on %s - EPG marking stop", + tvhdebug(LS_DVR, "dvr entry %s %s %s on %s - EPG marking stop", idnode_uuid_as_str(&de->de_id, ubuf), srcname, epg_broadcast_get_title(e, NULL), channel_get_name(de->de_channel)); @@ -1934,14 +1934,14 @@ void dvr_event_running(epg_broadcast_t *e, epg_source_t esrc, epg_running_t runn atomic_set_time_t(&de->de_running_pause, 0); if (de->de_sched_state == DVR_RECORDING && de->de_running_start) { dvr_stop_recording(de, SM_CODE_OK, 0, 0); - tvhdebug("dvr", "dvr entry %s %s %s on %s - EPG stop", + tvhdebug(LS_DVR, "dvr entry %s %s %s on %s - EPG stop", idnode_uuid_as_str(&de->de_id, ubuf), srcname, epg_broadcast_get_title(e, NULL), channel_get_name(de->de_channel)); } } else if (running == EPG_RUNNING_PAUSE && de->de_dvb_eid == e->dvb_eid) { if (!de->de_running_pause) { - tvhdebug("dvr", "dvr entry %s event %s on %s - EPG pause", + tvhdebug(LS_DVR, "dvr entry %s event %s on %s - EPG pause", idnode_uuid_as_str(&de->de_id, ubuf), epg_broadcast_get_title(e, NULL), channel_get_name(e->channel)); @@ -1973,10 +1973,10 @@ dvr_stop_recording(dvr_entry_t *de, int stopcode, int saveconf, int clone) else dvr_entry_completed(de, stopcode); - tvhlog(LOG_INFO, "dvr", "\"%s\" on \"%s\": " - "End of program: %s", - lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), - dvr_entry_status(de)); + tvhinfo(LS_DVR, "\"%s\" on \"%s\": " + "End of program: %s", + lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), + dvr_entry_status(de)); if (dvr_entry_rerecord(de)) return; @@ -2030,8 +2030,8 @@ dvr_entry_start_recording(dvr_entry_t *de, int clone) dvr_entry_set_state(de, DVR_RECORDING, DVR_RS_PENDING, SM_CODE_OK); - tvhlog(LOG_INFO, "dvr", "\"%s\" on \"%s\" recorder starting", - lang_str_get(de->de_title, NULL), DVR_CH_NAME(de)); + tvhinfo(LS_DVR, "\"%s\" on \"%s\" recorder starting", + lang_str_get(de->de_title, NULL), DVR_CH_NAME(de)); if (!clone && (r = dvr_rec_subscribe(de)) < 0) { dvr_entry_completed(de, r == -EPERM ? SM_CODE_USER_ACCESS : @@ -3444,11 +3444,11 @@ dvr_entry_delete(dvr_entry_t *de) str1 = dvr_entry_get_retention_string(de); str2 = dvr_entry_get_removal_string(de); - tvhlog(LOG_INFO, "dvr", "delete entry %s \"%s\" on \"%s\" start time %s, " - "scheduled for recording by \"%s\", retention \"%s\" removal \"%s\"", - idnode_uuid_as_str(&de->de_id, ubuf), - lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), tbuf, - de->de_creator ?: "", str1, str2); + tvhinfo(LS_DVR, "delete entry %s \"%s\" on \"%s\" start time %s, " + "scheduled for recording by \"%s\", retention \"%s\" removal \"%s\"", + idnode_uuid_as_str(&de->de_id, ubuf), + lang_str_get(de->de_title, NULL), DVR_CH_NAME(de), tbuf, + de->de_creator ?: "", str1, str2); free(str2); free(str1); @@ -3468,8 +3468,8 @@ dvr_entry_delete(dvr_entry_t *de) if (filename == NULL) continue; r = deferred_unlink(filename, rdir); if(r && r != -ENOENT) - tvhlog(LOG_WARNING, "dvr", "Unable to remove file '%s' from disk -- %s", - filename, strerror(-errno)); + tvhwarn(LS_DVR, "Unable to remove file '%s' from disk -- %s", + filename, strerror(-errno)); cmd = de->de_config->dvr_postremove; if (cmd && cmd[0]) diff --git a/src/dvr/dvr_inotify.c b/src/dvr/dvr_inotify.c index 4ead008a6..f7bb4ca3b 100644 --- a/src/dvr/dvr_inotify.c +++ b/src/dvr/dvr_inotify.c @@ -72,8 +72,7 @@ void dvr_inotify_init ( void ) { atomic_set(&_inot_fd, inotify_init1(IN_CLOEXEC)); if (atomic_get(&_inot_fd) < 0) { - tvhlog(LOG_ERR, "dvr", "failed to initialise inotify (err=%s)", - strerror(errno)); + tvherror(LS_DVR, "failed to initialise inotify (err=%s)", strerror(errno)); return; } @@ -141,8 +140,8 @@ static void dvr_inotify_add_one ( dvr_entry_t *de, htsmsg_t *m ) LIST_INSERT_HEAD(&e->entries, dif, link); if (e->fd < 0) { - tvhlog(LOG_ERR, "dvr", "failed to add inotify watch to %s (err=%s)", - e->path, strerror(errno)); + tvherror(LS_DVR, "failed to add inotify watch to %s (err=%s)", + e->path, strerror(errno)); dvr_inotify_del(de); } diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index c2f7515dc..b3cd2f2ed 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -87,7 +87,7 @@ dvr_rec_subscribe(dvr_entry_t *de) tcp_get_ip_from_str(de->de_creator, &sa) != NULL) aa = access_get_by_addr(&sa); else { - tvherror("dvr", "unable to find access (owner '%s', creator '%s')", + tvherror(LS_DVR, "unable to find access (owner '%s', creator '%s')", de->de_owner, de->de_creator); return -EPERM; } @@ -99,7 +99,7 @@ dvr_rec_subscribe(dvr_entry_t *de) c1 = aa->aa_conn_limit ? rec_count + net_count >= aa->aa_conn_limit : -1; c2 = aa->aa_conn_limit_dvr ? rec_count >= aa->aa_conn_limit_dvr : -1; if (c1 && c2) { - tvherror("dvr", "multiple connections are not allowed for user '%s' from '%s' " + tvherror(LS_DVR, "multiple connections are not allowed for user '%s' from '%s' " "(limit %u, dvr limit %u, active DVR %u, streaming %u)", aa->aa_username ?: "", aa->aa_representative ?: "", aa->aa_conn_limit, aa->aa_conn_limit_dvr, rec_count, net_count); @@ -114,12 +114,12 @@ dvr_rec_subscribe(dvr_entry_t *de) profile_chain_init(prch, pro, de->de_channel); if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) { profile_chain_close(prch); - tvherror("dvr", "unable to create new channel streaming chain '%s' for '%s', using default", + tvherror(LS_DVR, "unable to create new channel streaming chain '%s' for '%s', using default", profile_get_name(pro), channel_get_name(de->de_channel)); pro = profile_find_by_name(NULL, NULL); profile_chain_init(prch, pro, de->de_channel); if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) { - tvherror("dvr", "unable to create channel streaming default chain '%s' for '%s'", + tvherror(LS_DVR, "unable to create channel streaming default chain '%s' for '%s'", profile_get_name(pro), channel_get_name(de->de_channel)); profile_chain_close(prch); free(prch); @@ -131,7 +131,7 @@ dvr_rec_subscribe(dvr_entry_t *de) buf, prch->prch_flags, NULL, NULL, NULL, NULL); if (de->de_s == NULL) { - tvherror("dvr", "unable to create new channel subcription for '%s' profile '%s'", + tvherror(LS_DVR, "unable to create new channel subcription for '%s' profile '%s'", channel_get_name(de->de_channel), profile_get_name(pro)); profile_chain_close(prch); free(prch); @@ -203,7 +203,7 @@ cleanup_filename(dvr_config_t *cfg, char *s, int dosubs) s1 = intlconv_utf8safestr(cfg->dvr_charset_id, s, (len * 2) + 1); if (s1 == NULL) { - tvherror("dvr", "Unsupported charset %s using ASCII", cfg->dvr_charset); + tvherror(LS_DVR, "Unsupported charset %s using ASCII", cfg->dvr_charset); s1 = intlconv_utf8safestr(intlconv_charset_id("ASCII", 1, 1), s, len * 2); if (s1 == NULL) @@ -684,7 +684,7 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) path[sizeof(path)-1] = '\0'; l = strlen(path); if (l + 1 >= sizeof(path)) { - tvherror("dvr", "wrong storage path"); + tvherror(LS_DVR, "wrong storage path"); return -1; } @@ -765,7 +765,7 @@ pvr_generate_filename(dvr_entry_t *de, const streaming_start_t *ss) dirsep = path + l; } htsstr_unescape_to(path, filename, sizeof(filename)); - if (makedirs("dvr", filename, + if (makedirs(LS_DVR, filename, cfg->dvr_muxcnf.m_directory_permissions, 0, -1, -1) != 0) return -1; max = pathconf(filename, _PC_NAME_MAX); @@ -826,19 +826,18 @@ cut1: if (lastpath) { if (strcmp(path, lastpath) == 0) { free(lastpath); - tvherror("dvr", "unable to create unique name (missing $n in format string?)"); + tvherror(LS_DVR, "unable to create unique name (missing $n in format string?)"); return -1; } } if(stat(path, &st) == -1) { - tvhlog(LOG_DEBUG, "dvr", "File \"%s\" -- %s -- Using for recording", - path, strerror(errno)); + tvhdebug(LS_DVR, "File \"%s\" -- %s -- Using for recording", + path, strerror(errno)); break; } - tvhlog(LOG_DEBUG, "dvr", "Overwrite protection, file \"%s\" exists", - path); + tvhdebug(LS_DVR, "Overwrite protection, file \"%s\" exists", path); free(lastpath); lastpath = strdup(path); @@ -869,9 +868,8 @@ dvr_rec_fatal_error(dvr_entry_t *de, const char *fmt, ...) vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap); va_end(ap); - tvhlog(LOG_ERR, "dvr", - "Recording error: \"%s\": %s", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), msgbuf); + tvherror(LS_DVR, "Recording error: \"%s\": %s", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), msgbuf); } /** @@ -964,7 +962,7 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss) } } - tvhlog(LOG_INFO, "dvr", "%s from " + tvhinfo(LS_DVR, "%s from " "adapter: \"%s\", " "network: \"%s\", mux: \"%s\", provider: \"%s\", " "service: \"%s\"", @@ -977,7 +975,7 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss) si->si_service ?: ""); - tvhlog(LOG_INFO, "dvr", + tvhinfo(LS_DVR, " # %-16s %-4s %-10s %-12s %-11s %-8s", "type", "lang", @@ -1042,7 +1040,7 @@ dvr_rec_start(dvr_entry_t *de, const streaming_start_t *ss) htsmsg_add_u32(e, "ancillary_id", ssc->ssc_ancillary_id); } - tvhlog(LOG_INFO, "dvr", + tvhinfo(LS_DVR, "%2d %-16s %-4s %-10s %-12s %-11s %-8s %s", ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), @@ -1164,9 +1162,8 @@ dvr_thread_rec_start(dvr_entry_t **_de, streaming_start_t *ss, if (*started && muxer_reconfigure(prch->prch_muxer, ss) < 0) { - tvhlog(LOG_WARNING, - "dvr", "Unable to reconfigure \"%s\"", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL)); + tvhwarn(LS_DVR, "Unable to reconfigure \"%s\"", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL)); // Try to restart the recording if the muxer doesn't // support reconfiguration of the streams. @@ -1427,9 +1424,8 @@ dvr_thread(void *aux) // Recording is completed dvr_entry_set_state(de, de->de_sched_state, de->de_rec_state, SM_CODE_OK); - tvhlog(LOG_INFO, - "dvr", "Recording completed: \"%s\"", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL)); + tvhinfo(LS_DVR, "Recording completed: \"%s\"", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL)); goto fin; @@ -1437,10 +1433,9 @@ dvr_thread(void *aux) // Error during recording dvr_rec_set_state(de, DVR_RS_ERROR, sm->sm_code); - tvhlog(LOG_ERR, - "dvr", "Recording stopped: \"%s\": %s", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), - streaming_code2txt(sm->sm_code)); + tvherror(LS_DVR, "Recording stopped: \"%s\": %s", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), + streaming_code2txt(sm->sm_code)); fin: streaming_queue_clear(&backlog); @@ -1470,10 +1465,9 @@ fin: if(de->de_last_error != code) { dvr_rec_set_state(de, DVR_RS_ERROR, code); - tvhlog(LOG_ERR, - "dvr", "Streaming error: \"%s\": %s", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), - streaming_code2txt(code)); + tvherror(LS_DVR, "Streaming error: \"%s\": %s", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), + streaming_code2txt(code)); } } break; @@ -1483,10 +1477,9 @@ fin: if (de->de_last_error != sm->sm_code) { dvr_rec_set_state(de, DVR_RS_PENDING, sm->sm_code); - tvhlog(LOG_ERR, - "dvr", "Recording unable to start: \"%s\": %s", - dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), - streaming_code2txt(sm->sm_code)); + tvherror(LS_DVR, "Recording unable to start: \"%s\": %s", + dvr_get_filename(de) ?: lang_str_get(de->de_title, NULL), + streaming_code2txt(sm->sm_code)); } break; diff --git a/src/dvr/dvr_timerec.c b/src/dvr/dvr_timerec.c index 7be194d37..f752db6d1 100644 --- a/src/dvr/dvr_timerec.c +++ b/src/dvr/dvr_timerec.c @@ -178,7 +178,7 @@ dvr_timerec_create(const char *uuid, htsmsg_t *conf) if (idnode_insert(&dte->dte_id, uuid, &dvr_timerec_entry_class, 0)) { if (uuid) - tvhwarn("dvr", "invalid timerec entry uuid '%s'", uuid); + tvhwarn(LS_DVR, "invalid timerec entry uuid '%s'", uuid); free(dte); return NULL; } @@ -219,7 +219,7 @@ dvr_timerec_update_htsp (dvr_timerec_entry_t *dte, htsmsg_t *conf) { idnode_update(&dte->dte_id, conf); idnode_changed(&dte->dte_id); - tvhlog(LOG_INFO, "timerec", "\"%s\" on \"%s\": Updated", dte->dte_title ? dte->dte_title : "", + tvhinfo(LS_DVR, "timerec \"%s\" on \"%s\": Updated", dte->dte_title ? dte->dte_title : "", (dte->dte_channel && dte->dte_channel->ch_name) ? dte->dte_channel->ch_name : "any channel"); } @@ -717,7 +717,7 @@ dvr_timerec_timer_cb(void *aux) { dvr_timerec_entry_t *dte; - tvhtrace("dvr", "timerec update"); + tvhtrace(LS_DVR, "timerec update"); /* check all entries */ TAILQ_FOREACH(dte, &timerec_entries, dte_link) { diff --git a/src/dvr/dvr_vfsmgr.c b/src/dvr/dvr_vfsmgr.c index 4e9b449d9..93a8e6900 100644 --- a/src/dvr/dvr_vfsmgr.c +++ b/src/dvr/dvr_vfsmgr.c @@ -102,7 +102,7 @@ dvr_vfs_refresh_entry(dvr_entry_t *de) filename = htsmsg_get_str(m, "filename"); if(filename == NULL || statvfs(filename, &vst) < 0 || stat(filename, &st) < 0) { - tvhlog(LOG_ERR, "dvr", "unable to stat file '%s'", filename); + tvherror(LS_DVR, "unable to stat file '%s'", filename); goto rem; } vfs = dvr_vfs_find(vfs, tvh_fsid(vst.f_fsid)); @@ -205,18 +205,18 @@ dvr_disk_space_cleanup(dvr_config_t *cfg) /* If calling this function to fast after the previous call, statvfs might be wrong/not updated yet */ /* So we are risking to delete more files than needed, so allow 10s for the system to handle previous deletes */ if (dvr_disk_space_config_lastdelete + sec2mono(10) > mclk()) { - tvhlog(LOG_WARNING, "dvr","disk space cleanup for config \"%s\" is not allowed now", configName); + tvhwarn(LS_DVR,"disk space cleanup for config \"%s\" is not allowed now", configName); return -1; } if (diskBytes < requiredBytes) { - tvhlog(LOG_WARNING, "dvr","disk space cleanup for config \"%s\", required free space \"%"PRId64" MiB\" is smaller than the total disk size!", - configName, TOMIB(requiredBytes)); + tvhwarn(LS_DVR,"disk space cleanup for config \"%s\", required free space \"%"PRId64" MiB\" is smaller than the total disk size!", + configName, TOMIB(requiredBytes)); if (maximalBytes >= usedBytes) return -1; } - tvhtrace("dvr", "disk space cleanup for config \"%s\", required/current free space \"%"PRId64"/%"PRId64" MiB\", required/current used space \"%"PRId64"/%"PRId64" MiB\"", + tvhtrace(LS_DVR, "disk space cleanup for config \"%s\", required/current free space \"%"PRId64"/%"PRId64" MiB\", required/current used space \"%"PRId64"/%"PRId64" MiB\"", configName, TOMIB(requiredBytes), TOMIB(availBytes), TOMIB(maximalBytes), TOMIB(usedBytes)); while (availBytes < requiredBytes || ((maximalBytes < usedBytes) && cfg->dvr_cleanup_threshold_used)) { @@ -258,8 +258,8 @@ dvr_disk_space_cleanup(dvr_config_t *cfg) localtime_r(&stoptime, &tm); if (strftime(tbuf, sizeof(tbuf), "%F %T", &tm) <= 0) *tbuf = 0; - tvhlog(LOG_INFO, "dvr","Delete \"until space needed\" recording \"%s\" with stop time \"%s\" and file size \"%"PRId64" MB\"", - lang_str_get(oldest->de_title, NULL), tbuf, TOMIB(fileSize)); + tvhinfo(LS_DVR,"Delete \"until space needed\" recording \"%s\" with stop time \"%s\" and file size \"%"PRId64" MB\"", + lang_str_get(oldest->de_title, NULL), tbuf, TOMIB(fileSize)); dvr_disk_space_config_lastdelete = mclk(); if (dvr_entry_get_retention_days(oldest) == DVR_RET_ONREMOVE) { @@ -270,20 +270,20 @@ dvr_disk_space_cleanup(dvr_config_t *cfg) idnode_changed(&oldest->de_id); } } else { - tvhlog(LOG_WARNING, "dvr", "%s \"until space needed\" recordings found for config \"%s\", you are running out of disk space very soon!", - loops > 0 ? "Not enough" : "No", configName); + tvhwarn(LS_DVR, "%s \"until space needed\" recordings found for config \"%s\", you are running out of disk space very soon!", + loops > 0 ? "Not enough" : "No", configName); goto finish; } loops++; if (loops >= 10) { - tvhlog(LOG_WARNING, "dvr", "Not able to clear the required disk space after deleting %i \"until space needed\" recordings...", loops); + tvhwarn(LS_DVR, "Not able to clear the required disk space after deleting %i \"until space needed\" recordings...", loops); goto finish; } } finish: - tvhtrace("dvr", "disk space cleanup for config \"%s\", cleared \"%"PRId64" MB\" of disk space, new free disk space \"%"PRId64" MiB\", new used disk space \"%"PRId64" MiB\"", + tvhtrace(LS_DVR, "disk space cleanup for config \"%s\", cleared \"%"PRId64" MB\" of disk space, new free disk space \"%"PRId64" MiB\", new used disk space \"%"PRId64" MiB\"", configName, TOMIB(clearedBytes), TOMIB(availBytes), TOMIB(usedBytes)); return clearedBytes; @@ -332,13 +332,13 @@ dvr_disk_space_check() continue; if (availBytes < requiredBytes) { - tvhlog(LOG_WARNING, "dvr","running out of free disk space for dvr config \"%s\", required free space \"%"PRId64" MiB\", current free space \"%"PRId64" MiB\"", - cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile", - TOMIB(requiredBytes), TOMIB(availBytes)); + tvhwarn(LS_DVR,"running out of free disk space for dvr config \"%s\", required free space \"%"PRId64" MiB\", current free space \"%"PRId64" MiB\"", + cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile", + TOMIB(requiredBytes), TOMIB(availBytes)); } else { - tvhlog(LOG_WARNING, "dvr","running out of used disk space for dvr config \"%s\", required used space \"%"PRId64" MiB\", current used space \"%"PRId64" MiB\"", - cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile", - TOMIB(maximalBytes), TOMIB(usedBytes)); + tvhwarn(LS_DVR,"running out of used disk space for dvr config \"%s\", required used space \"%"PRId64" MiB\", current used space \"%"PRId64" MiB\"", + cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile", + TOMIB(maximalBytes), TOMIB(usedBytes)); } /* only cleanup one directory at the time as the system needs time to delete the actual files */ @@ -351,7 +351,7 @@ dvr_disk_space_check() goto checking; } else { checking: - tvhtrace("dvr", "checking free and used disk space for config \"%s\" : OK", + tvhtrace(LS_DVR, "checking free and used disk space for config \"%s\" : OK", cfg != dvr_config_find_by_name(NULL) ? cfg->dvr_config_name : "Default profile"); } } diff --git a/src/epg.c b/src/epg.c index 67c5ae526..ecb26481e 100644 --- a/src/epg.c +++ b/src/epg.c @@ -121,7 +121,7 @@ void epg_updated ( void ) /* Remove unref'd */ while ((eo = LIST_FIRST(&epg_object_unref))) { - tvhtrace("epg", + tvhtrace(LS_EPG, "unref'd object %u (%s) created during update", eo->id, eo->uri); LIST_REMOVE(eo, un_link); eo->destroy(eo); @@ -147,7 +147,7 @@ static void _epg_object_destroy ( epg_object_t *eo, epg_object_tree_t *tree ) { assert(eo->refcount == 0); - tvhtrace("epg", "eo [%p, %u, %d, %s] destroy", + tvhtrace(LS_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); @@ -158,7 +158,7 @@ static void _epg_object_destroy static void _epg_object_getref ( void *o ) { epg_object_t *eo = o; - tvhtrace("epg", "eo [%p, %u, %d, %s] getref %d", + tvhtrace(LS_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++; @@ -167,7 +167,7 @@ static void _epg_object_getref ( void *o ) static void _epg_object_putref ( void *o ) { epg_object_t *eo = o; - tvhtrace("epg", "eo [%p, %u, %d, %s] putref %d", + tvhtrace(LS_EPG, "eo [%p, %u, %d, %s] putref %d", eo, eo->id, eo->type, eo->uri, eo->refcount-1); assert(eo->refcount>0); eo->refcount--; @@ -178,7 +178,7 @@ static void _epg_object_set_updated ( void *o ) { epg_object_t *eo = o; if (!eo->_updated) { - tvhtrace("epg", "eo [%p, %u, %d, %s] updated", + tvhtrace(LS_EPG, "eo [%p, %u, %d, %s] updated", eo, eo->id, eo->type, eo->uri); eo->_updated = 1; eo->updated = gclk(); @@ -216,7 +216,7 @@ static void _epg_object_create ( void *o ) if (!eo->id) eo->id = ++_epg_object_idx; if (!eo->getref) eo->getref = _epg_object_getref; if (!eo->putref) eo->putref = _epg_object_putref; - tvhtrace("epg", "eo [%p, %u, %d, %s] created", + tvhtrace(LS_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); @@ -224,7 +224,7 @@ static void _epg_object_create ( void *o ) if (!RB_INSERT_SORTED(epg_id_tree(eo), eo, id_link, _id_cmp)) break; if (id) { - tvherror("epg", "fatal error, duplicate EPG ID"); + tvherror(LS_EPG, "fatal error, duplicate EPG ID"); abort(); } eo->id = ++_epg_object_idx; @@ -280,7 +280,7 @@ 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; - tvhtrace("epg", "eo [%p, %u, %d, %s] serialize", + tvhtrace(LS_EPG, "eo [%p, %u, %d, %s] serialize", eo, eo->id, eo->type, eo->uri); htsmsg_t *m; if (!eo->id || !eo->type) return NULL; @@ -310,7 +310,7 @@ static epg_object_t *_epg_object_deserialize ( htsmsg_t *m, epg_object_t *eo ) _epg_object_set_updated(eo); eo->updated = s64; } - tvhtrace("epg", "eo [%p, %u, %d, %s] deserialize", + tvhtrace(LS_EPG, "eo [%p, %u, %d, %s] deserialize", eo, eo->id, eo->type, eo->uri); return eo; } @@ -434,11 +434,11 @@ static void _epg_brand_destroy ( void *eo ) { epg_brand_t *eb = (epg_brand_t*)eo; if (LIST_FIRST(&eb->seasons)) { - tvhlog(LOG_CRIT, "epg", "attempt to destroy brand with seasons"); + tvhlog(LOG_CRIT, LS_EPG, "attempt to destroy brand with seasons"); assert(0); } if (LIST_FIRST(&eb->episodes)) { - tvhlog(LOG_CRIT, "epg", "attempt to destroy brand with episodes"); + tvhlog(LOG_CRIT, LS_EPG, "attempt to destroy brand with episodes"); assert(0); } if (eb->title) lang_str_destroy(eb->title); @@ -645,7 +645,7 @@ static void _epg_season_destroy ( void *eo ) { epg_season_t *es = (epg_season_t*)eo; if (LIST_FIRST(&es->episodes)) { - tvhlog(LOG_CRIT, "epg", "attempt to destory season with episodes"); + tvhlog(LOG_CRIT, LS_EPG, "attempt to destory season with episodes"); assert(0); } if (es->brand) _epg_brand_rem_season(es->brand, es); @@ -891,7 +891,7 @@ static void _epg_episode_destroy ( void *eo ) epg_genre_t *g; epg_episode_t *ee = eo; if (LIST_FIRST(&ee->broadcasts)) { - tvhlog(LOG_CRIT, "epg", "attempt to destroy episode with broadcasts"); + tvhlog(LOG_CRIT, LS_EPG, "attempt to destroy episode with broadcasts"); assert(0); } if (ee->brand) _epg_brand_rem_episode(ee->brand, ee); @@ -1444,7 +1444,7 @@ static void _epg_serieslink_destroy ( void *eo ) { epg_serieslink_t *es = (epg_serieslink_t*)eo; if (LIST_FIRST(&es->broadcasts)) { - tvhlog(LOG_CRIT, "epg", "attempt to destory series link with broadcasts"); + tvhlog(LOG_CRIT, LS_EPG, "attempt to destory series link with broadcasts"); assert(0); } _epg_object_destroy(eo, &epg_serieslinks); @@ -1572,9 +1572,9 @@ static void _epg_channel_timer_callback ( void *p ) /* Expire */ if ( ebc->stop <= gclk() ) { - tvhlog(LOG_DEBUG, "epg", "expire event %u (%s) from %s", - ebc->id, epg_broadcast_get_title(ebc, NULL), - channel_get_name(ch)); + tvhdebug(LS_EPG, "expire event %u (%s) from %s", + ebc->id, epg_broadcast_get_title(ebc, NULL), + channel_get_name(ch)); _epg_channel_rem_broadcast(ch, ebc, NULL); continue; // skip to next @@ -1594,19 +1594,19 @@ static void _epg_channel_timer_callback ( void *p ) /* Change (update HTSP) */ if (cur != ch->ch_epg_now || nxt != ch->ch_epg_next) { - tvhlog(LOG_DEBUG, "epg", "now/next %u/%u set on %s", - ch->ch_epg_now ? ch->ch_epg_now->id : 0, - ch->ch_epg_next ? ch->ch_epg_next->id : 0, - channel_get_name(ch)); - tvhlog(LOG_DEBUG, "epg", "inform HTSP of now event change on %s", - channel_get_name(ch)); + tvhdebug(LS_EPG, "now/next %u/%u set on %s", + ch->ch_epg_now ? ch->ch_epg_now->id : 0, + ch->ch_epg_next ? ch->ch_epg_next->id : 0, + channel_get_name(ch)); + tvhdebug(LS_EPG, "inform HTSP of now event change on %s", + channel_get_name(ch)); htsp_channel_update_nownext(ch); } /* re-arm */ if (next) { - tvhlog(LOG_DEBUG, "epg", "arm channel timer @ %"PRItime_t" for %s", - next, channel_get_name(ch)); + tvhdebug(LS_EPG, "arm channel timer @ %"PRItime_t" for %s", + next, channel_get_name(ch)); gtimer_arm_absn(&ch->ch_epg_timer, _epg_channel_timer_callback, ch, next); } @@ -1642,7 +1642,7 @@ static epg_broadcast_t *_epg_channel_add_broadcast _epg_object_create(ret); // Note: sets updated _epg_object_getref(ret); - tvhtrace("epg", "added event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, + tvhtrace(LS_EPG, "added event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, ret->id, epg_broadcast_get_title(ret, NULL), channel_get_name(ch), ret->start, ret->stop); @@ -1659,7 +1659,7 @@ static epg_broadcast_t *_epg_channel_add_broadcast } else { ret->stop = (*bcast)->stop; _epg_object_set_updated(ret); - tvhtrace("epg", "updated event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, + tvhtrace(LS_EPG, "updated event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, ret->id, epg_broadcast_get_title(ret, NULL), channel_get_name(ch), ret->start, ret->stop); } @@ -1673,11 +1673,11 @@ static epg_broadcast_t *_epg_channel_add_broadcast while ((ebc = RB_PREV(ret, sched_link)) != NULL) { if (ebc->stop <= ret->start) break; if (!_epg_object_can_remove(ebc, ret)) { - tvhtrace("epg", "grabber for event %u has lower priority than overlap (b), removing", ebc->id); + tvhtrace(LS_EPG, "grabber for event %u has lower priority than overlap (b), removing", ebc->id); _epg_channel_rem_broadcast(ch, ret, NULL); return NULL; } - tvhtrace("epg", "remove overlap (b) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, + tvhtrace(LS_EPG, "remove overlap (b) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, ebc->id, epg_broadcast_get_title(ebc, NULL), channel_get_name(ch), ebc->start, ebc->stop); _epg_channel_rem_broadcast(ch, ebc, ret); @@ -1687,11 +1687,11 @@ static epg_broadcast_t *_epg_channel_add_broadcast while ((ebc = RB_NEXT(ret, sched_link)) != NULL) { if (ebc->start >= ret->stop) break; if (!_epg_object_can_remove(ebc, ret)) { - tvhtrace("epg", "grabber for event %u has lower priority than overlap (a), removing", ebc->id); + tvhtrace(LS_EPG, "grabber for event %u has lower priority than overlap (a), removing", ebc->id); _epg_channel_rem_broadcast(ch, ret, NULL); return NULL; } - tvhtrace("epg", "remove overlap (a) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, + tvhtrace(LS_EPG, "remove overlap (a) event %u (%s) on %s @ %"PRItime_t " to %"PRItime_t, ebc->id, epg_broadcast_get_title(ebc, NULL), channel_get_name(ch), ebc->start, ebc->stop); _epg_channel_rem_broadcast(ch, ebc, ret); diff --git a/src/epgdb.c b/src/epgdb.c index aebcbc462..cedfbf666 100644 --- a/src/epgdb.c +++ b/src/epgdb.c @@ -142,7 +142,7 @@ _epgdb_v2_process( char **sect, htsmsg_t *m, epggrab_stats_t *stats ) /* Unknown */ } else { - tvhlog(LOG_DEBUG, "epgdb", "malformed database section [%s]", *sect); + tvhdebug(LS_EPGDB, "malformed database section [%s]", *sect); //htsmsg_print(m); } } @@ -305,7 +305,7 @@ void epg_init ( void ) if ( fd < 0 ) fd = hts_settings_open_file(0, "epgdb"); if ( fd < 0 ) { - tvhlog(LOG_DEBUG, "epgdb", "database does not exist"); + tvhdebug(LS_EPGDB, "database does not exist"); return; } @@ -313,29 +313,29 @@ void epg_init ( void ) act.sa_sigaction = epg_mmap_sigbus; act.sa_flags = SA_SIGINFO; if (sigaction(SIGBUS, &act, &oldact)) { - tvhlog(LOG_ERR, "epgdb", "failed to install SIGBUS handler"); + tvherror(LS_EPGDB, "failed to install SIGBUS handler"); close(fd); return; } /* Map file to memory */ if ( fstat(fd, &st) != 0 ) { - tvhlog(LOG_ERR, "epgdb", "failed to detect database size"); + tvherror(LS_EPGDB, "failed to detect database size"); goto end; } if ( !st.st_size ) { - tvhlog(LOG_DEBUG, "epgdb", "database is empty"); + tvhdebug(LS_EPGDB, "database is empty"); goto end; } remain = st.st_size; rp = mem = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if ( mem == MAP_FAILED ) { - tvhlog(LOG_ERR, "epgdb", "failed to mmap database"); + tvherror(LS_EPGDB, "failed to mmap database"); goto end; } if (sigsetjmp(epg_mmap_env, 1)) { - tvhlog(LOG_ERR, "epgdb", "failed to read from mapped file"); + tvherror(LS_EPGDB, "failed to read from mapped file"); if (mem) munmap(mem, st.st_size); goto end; @@ -344,7 +344,7 @@ void epg_init ( void ) #if ENABLE_ZLIB if (remain > 12 && memcmp(rp, "\xff\xffGZIP00", 8) == 0) { uint32_t orig = (rp[8] << 24) | (rp[9] << 16) | (rp[10] << 8) | rp[11]; - tvhlog(LOG_INFO, "epgdb", "gzip format detected, inflating (ratio %.1f%%)", + tvhinfo(LS_EPGDB, "gzip format detected, inflating (ratio %.1f%%)", (float)((remain * 100.0) / orig)); rp = zlib_mem = tvh_gzip_inflate(rp + 12, remain - 12, orig); remain = rp ? orig : 0; @@ -362,7 +362,7 @@ void epg_init ( void ) /* Safety check */ if ((int64_t)msglen > remain) { - tvhlog(LOG_ERR, "epgdb", "corruption detected, some/all data lost"); + tvherror(LS_EPGDB, "corruption detected, some/all data lost"); break; } @@ -400,13 +400,13 @@ void epg_init ( void ) } /* Stats */ - tvhlog(LOG_INFO, "epgdb", "loaded v%d", ver); - tvhlog(LOG_INFO, "epgdb", " config %d", stats.config.total); - tvhlog(LOG_INFO, "epgdb", " channels %d", stats.channels.total); - tvhlog(LOG_INFO, "epgdb", " brands %d", stats.brands.total); - tvhlog(LOG_INFO, "epgdb", " seasons %d", stats.seasons.total); - tvhlog(LOG_INFO, "epgdb", " episodes %d", stats.episodes.total); - tvhlog(LOG_INFO, "epgdb", " broadcasts %d", stats.broadcasts.total); + tvhinfo(LS_EPGDB, "loaded v%d", ver); + tvhinfo(LS_EPGDB, " config %d", stats.config.total); + tvhinfo(LS_EPGDB, " channels %d", stats.channels.total); + tvhinfo(LS_EPGDB, " brands %d", stats.brands.total); + tvhinfo(LS_EPGDB, " seasons %d", stats.seasons.total); + tvhinfo(LS_EPGDB, " episodes %d", stats.episodes.total); + tvhinfo(LS_EPGDB, " broadcasts %d", stats.broadcasts.total); /* Close file */ munmap(mem, st.st_size); @@ -471,7 +471,7 @@ static void epg_save_tsk_callback ( void *p, int dearmed ) size_t size = sb->sb_ptr; int fd, r; - tvhinfo("epgdb", "save start"); + tvhinfo(LS_EPGDB, "save start"); fd = hts_settings_open_file(1, "epgdb.v%d", EPG_DB_VERSION); if (fd >= 0) { #if ENABLE_ZLIB @@ -482,11 +482,11 @@ static void epg_save_tsk_callback ( void *p, int dearmed ) r = tvh_write(fd, sb->sb_data, sb->sb_ptr); close(fd); if (r) - tvherror("epgdb", "write error (size %zd)", size); + tvherror(LS_EPGDB, "write error (size %zd)", size); else - tvhinfo("epgdb", "stored (size %zd)", size); + tvhinfo(LS_EPGDB, "stored (size %zd)", size); } else - tvherror("epgdb", "unable to open epgdb file"); + tvherror(LS_EPGDB, "unable to open epgdb file"); sbuf_free(sb); free(sb); } @@ -508,7 +508,7 @@ void epg_save ( void ) if (!sb) return; - tvhinfo("epgdb", "snapshot start"); + tvhinfo(LS_EPGDB, "snapshot start"); sbuf_init_fixed(sb, EPG_DB_ALLOC_STEP); @@ -551,16 +551,16 @@ void epg_save ( void ) tasklet_arm_alloc(epg_save_tsk_callback, sb); /* Stats */ - tvhinfo("epgdb", "queued to save (size %d)", sb->sb_ptr); - tvhinfo("epgdb", " brands %d", stats.brands.total); - tvhinfo("epgdb", " seasons %d", stats.seasons.total); - tvhinfo("epgdb", " episodes %d", stats.episodes.total); - tvhinfo("epgdb", " broadcasts %d", stats.broadcasts.total); + tvhinfo(LS_EPGDB, "queued to save (size %d)", sb->sb_ptr); + tvhinfo(LS_EPGDB, " brands %d", stats.brands.total); + tvhinfo(LS_EPGDB, " seasons %d", stats.seasons.total); + tvhinfo(LS_EPGDB, " episodes %d", stats.episodes.total); + tvhinfo(LS_EPGDB, " broadcasts %d", stats.broadcasts.total); return; error: - tvhlog(LOG_ERR, "epgdb", "failed to store epg to disk"); + tvherror(LS_EPGDB, "failed to store epg to disk"); hts_settings_remove("epgdb.v%d", EPG_DB_VERSION); sbuf_free(sb); free(sb); diff --git a/src/epggrab.c b/src/epggrab.c index 99bbf2eff..73d262ca7 100644 --- a/src/epggrab.c +++ b/src/epggrab.c @@ -73,10 +73,10 @@ static void _epggrab_module_grab ( epggrab_module_int_t *mod ) /* Process */ if ( data ) { - tvhlog(LOG_INFO, mod->id, "grab took %"PRId64" seconds", mono2sec(tm2 - tm1)); + tvhinfo(mod->subsys, "%s: grab took %"PRId64" seconds", mod->id, mono2sec(tm2 - tm1)); epggrab_module_parse(mod, data); } else { - tvhlog(LOG_WARNING, mod->id, "grab returned no data"); + tvhwarn(mod->subsys, "%s: grab returned no data", mod->id); } } diff --git a/src/epggrab.h b/src/epggrab.h index ce8334aea..9d29a466a 100644 --- a/src/epggrab.h +++ b/src/epggrab.h @@ -152,6 +152,7 @@ struct epggrab_module EPGGRAB_EXT, } type; ///< Grabber type const char *id; ///< Module identifier + int subsys; ///< Module log subsystem const char *saveid; ///< Module save identifier const char *name; ///< Module name (for display) int enabled; ///< Whether the module is enabled diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c index 3a4348b87..24dd0034c 100644 --- a/src/epggrab/channel.c +++ b/src/epggrab/channel.c @@ -113,8 +113,8 @@ _epgggrab_channel_link_delete(idnode_list_mapping_t *ilm, int delconf) { epggrab_channel_t *ec = (epggrab_channel_t *)ilm->ilm_in1; channel_t *ch = (channel_t *)ilm->ilm_in2; - tvhdebug(ec->mod->id, "unlinking %s from %s", - ec->id, channel_get_name(ch)); + tvhdebug(ec->mod->subsys, "%s: unlinking %s from %s", + ec->mod->id, ec->id, channel_get_name(ch)); idnode_list_unlink(ilm, delconf ? ec : NULL); } @@ -172,8 +172,8 @@ epggrab_channel_link ( epggrab_channel_t *ec, channel_t *ch, void *origin ) } /* New link */ - tvhdebug(ec->mod->id, "linking %s to %s", - ec->id, channel_get_name(ch)); + tvhdebug(ec->mod->subsys, "%s: linking %s to %s", + ec->mod->id, ec->id, channel_get_name(ch)); ilm = idnode_list_link(&ec->idnode, &ec->channels, &ch->ch_id, &ch->ch_epggrab, @@ -335,7 +335,7 @@ epggrab_channel_t *epggrab_channel_create ec = calloc(1, sizeof(*ec)); if (idnode_insert(&ec->idnode, uuid, &epggrab_channel_class, 0)) { if (uuid) - tvherror("epggrab", "invalid uuid '%s'", uuid); + tvherror(LS_EPGGRAB, "invalid uuid '%s'", uuid); free(ec); return NULL; } @@ -351,7 +351,7 @@ epggrab_channel_t *epggrab_channel_create TAILQ_INSERT_TAIL(&epggrab_channel_entries, ec, all_link); if (RB_INSERT_SORTED(&owner->channels, ec, link, _ch_id_cmp)) { - tvherror("epggrab", "removing duplicate channel id '%s' (uuid '%s')", ec->id, uuid); + tvherror(LS_EPGGRAB, "removing duplicate channel id '%s' (uuid '%s')", ec->id, uuid); epggrab_channel_destroy(ec, 1, 0); return NULL; } diff --git a/src/epggrab/module.c b/src/epggrab/module.c index a3c815c9e..8c3a41e5c 100644 --- a/src/epggrab/module.c +++ b/src/epggrab/module.c @@ -225,13 +225,14 @@ const idclass_t epggrab_mod_ota_class = { epggrab_module_t *epggrab_module_create ( epggrab_module_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority ) { assert(skel); /* Setup */ skel->id = strdup(id); + skel->subsys = subsys; skel->saveid = strdup(saveid ?: id); skel->name = strdup(name); skel->priority = priority; @@ -240,7 +241,7 @@ epggrab_module_t *epggrab_module_create /* Insert */ assert(!epggrab_module_find_by_id(id)); LIST_INSERT_HEAD(&epggrab_modules, skel, link); - tvhlog(LOG_INFO, "epggrab", "module %s created", id); + tvhinfo(LS_EPGGRAB, "module %s created", id); idnode_insert(&skel->idnode, NULL, cls, 0); @@ -265,22 +266,22 @@ void epggrab_module_parse( void *m, htsmsg_t *data ) htsmsg_destroy(data); /* Debug stats */ - tvhlog(LOG_INFO, mod->id, "parse took %"PRId64" seconds", mono2sec(tm2 - tm1)); - tvhlog(LOG_INFO, mod->id, " channels tot=%5d new=%5d mod=%5d", - stats.channels.total, stats.channels.created, - stats.channels.modified); - tvhlog(LOG_INFO, mod->id, " brands tot=%5d new=%5d mod=%5d", - stats.brands.total, stats.brands.created, - stats.brands.modified); - tvhlog(LOG_INFO, mod->id, " seasons tot=%5d new=%5d mod=%5d", - stats.seasons.total, stats.seasons.created, - stats.seasons.modified); - tvhlog(LOG_INFO, mod->id, " episodes tot=%5d new=%5d mod=%5d", - stats.episodes.total, stats.episodes.created, - stats.episodes.modified); - tvhlog(LOG_INFO, mod->id, " broadcasts tot=%5d new=%5d mod=%5d", - stats.broadcasts.total, stats.broadcasts.created, - stats.broadcasts.modified); + tvhinfo(mod->subsys, "%s: parse took %"PRId64" seconds", mod->id, mono2sec(tm2 - tm1)); + tvhinfo(mod->subsys, "%s: channels tot=%5d new=%5d mod=%5d", + mod->id, stats.channels.total, stats.channels.created, + stats.channels.modified); + tvhinfo(mod->subsys, "%s: brands tot=%5d new=%5d mod=%5d", + mod->id, stats.brands.total, stats.brands.created, + stats.brands.modified); + tvhinfo(mod->subsys, "%s: seasons tot=%5d new=%5d mod=%5d", + mod->id, stats.seasons.total, stats.seasons.created, + stats.seasons.modified); + tvhinfo(mod->subsys, "%s: episodes tot=%5d new=%5d mod=%5d", + mod->id, stats.episodes.total, stats.episodes.created, + stats.episodes.modified); + tvhinfo(mod->subsys, "%s: broadcasts tot=%5d new=%5d mod=%5d", + mod->id, stats.broadcasts.total, stats.broadcasts.created, + stats.broadcasts.modified); } /* ************************************************************************** @@ -298,7 +299,7 @@ void epggrab_module_channels_load ( const char *modid ) HTSMSG_FOREACH(f, m) { if ((e = htsmsg_get_map_by_field(f))) { id = htsmsg_get_str(e, "modid") ?: modid; - if (mod == NULL || strcmp(mod->id, id)) + if (mod == NULL || strcmp(mod->id, id)) mod = epggrab_module_find_by_id(id); if (mod) epggrab_channel_create(mod, e, f->hmf_name); @@ -325,7 +326,7 @@ epggrab_module_int_done( void *m ) epggrab_module_int_t *epggrab_module_int_create ( epggrab_module_int_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, const char *path, char* (*grab) (void*m), @@ -338,7 +339,7 @@ epggrab_module_int_t *epggrab_module_int_create /* Pass through */ epggrab_module_create((epggrab_module_t*)skel, cls ?: &epggrab_mod_int_class, - id, saveid, name, priority); + id, subsys, saveid, name, priority); /* Int data */ skel->type = EPGGRAB_INT; @@ -361,7 +362,7 @@ char *epggrab_module_grab_spawn ( void *m ) char *path; /* Debug */ - tvhlog(LOG_INFO, mod->id, "grab %s", mod->path); + tvhinfo(mod->subsys, "%s: grab %s", mod->id, mod->path); /* Extra arguments */ if (mod->args && mod->args[0]) { @@ -375,7 +376,7 @@ char *epggrab_module_grab_spawn ( void *m ) /* Arguments */ if (spawn_parse_args(&argv, 64, path, NULL)) { - tvhlog(LOG_ERR, mod->id, "unable to parse arguments"); + tvherror(mod->subsys, "%s: unable to parse arguments", mod->id); return NULL; } @@ -398,7 +399,7 @@ char *epggrab_module_grab_spawn ( void *m ) error: if (rd >= 0) close(rd); - tvhlog(LOG_ERR, mod->id, "no output detected"); + tvherror(mod->subsys, "%s: no output detected", mod->id); return NULL; } @@ -415,7 +416,7 @@ htsmsg_t *epggrab_module_trans_xml ( void *m, char *c ) /* Extract */ ret = htsmsg_xml_deserialize(c, errbuf, sizeof(errbuf)); if (!ret) - tvhlog(LOG_ERR, mod->id, "htsmsg_xml_deserialize error %s", errbuf); + tvherror(mod->subsys, "%s: htsmsg_xml_deserialize error %s", mod->id, errbuf); return ret; } @@ -441,12 +442,12 @@ static void _epggrab_socket_handler ( epggrab_module_ext_t *mod, int s ) /* Process */ if ( data ) { - tvhlog(LOG_INFO, mod->id, "grab took %"PRItime_t" seconds", tm2 - tm1); + tvhinfo(mod->subsys, "%s: grab took %"PRItime_t" seconds", mod->id, tm2 - tm1); epggrab_module_parse(mod, data); /* Failed */ } else { - tvhlog(LOG_ERR, mod->id, "failed to read data"); + tvherror(mod->subsys, "%s: failed to read data", mod->id); } } @@ -458,17 +459,17 @@ static void *_epggrab_socket_thread ( void *p ) { int s; epggrab_module_ext_t *mod = (epggrab_module_ext_t*)p; - tvhlog(LOG_INFO, mod->id, "external socket enabled"); + tvhinfo(mod->subsys, "%s: external socket enabled", mod->id); while ( mod->enabled && mod->sock ) { - tvhlog(LOG_DEBUG, mod->id, "waiting for connection"); + tvhdebug(mod->subsys, "%s: waiting for connection", mod->id); s = accept(mod->sock, NULL, NULL); if (s <= 0) continue; - tvhlog(LOG_DEBUG, mod->id, "got connection %d", s); + tvhdebug(mod->subsys, "%s: got connection %d", mod->id, s); _epggrab_socket_handler(mod, s); close(s); } - tvhlog(LOG_DEBUG, mod->id, "terminated"); + tvhdebug(mod->subsys, "%s: terminated", mod->id); return NULL; } @@ -530,20 +531,20 @@ epggrab_module_activate_socket ( void *m, int a ) strncpy(addr.sun_path, mod->path, 100); if ( bind(mod->sock, (struct sockaddr*)&addr, sizeof(struct sockaddr_un)) != 0 ) { - tvhlog(LOG_ERR, mod->id, "failed to bind socket"); + tvherror(mod->subsys, "%s: failed to bind socket", mod->id); close(mod->sock); mod->sock = 0; return 0; } if ( listen(mod->sock, 5) != 0 ) { - tvhlog(LOG_ERR, mod->id, "failed to listen on socket"); + tvherror(mod->subsys, "%s: failed to listen on socket", mod->id); close(mod->sock); mod->sock = 0; return 0; } - tvhlog(LOG_DEBUG, mod->id, "starting socket thread"); + tvhdebug(mod->subsys, "%s: starting socket thread", mod->id); pthread_attr_init(&tattr); mod->active = 1; tvhthread_create(&mod->tid, &tattr, _epggrab_socket_thread, mod, "epggrabso"); @@ -556,7 +557,7 @@ epggrab_module_activate_socket ( void *m, int a ) */ epggrab_module_ext_t *epggrab_module_ext_create ( epggrab_module_ext_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, const char *sockid, int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta), htsmsg_t* (*trans) (void *mod, char *data) ) @@ -570,7 +571,7 @@ epggrab_module_ext_t *epggrab_module_ext_create hts_settings_buildpath(path, sizeof(path), "epggrab/%s.sock", sockid); epggrab_module_int_create((epggrab_module_int_t*)skel, cls ?: &epggrab_mod_ext_class, - id, saveid, name, priority, path, + id, subsys, saveid, name, priority, path, NULL, parse, trans); /* Local */ @@ -587,7 +588,7 @@ epggrab_module_ext_t *epggrab_module_ext_create epggrab_module_ota_t *epggrab_module_ota_create ( epggrab_module_ota_t *skel, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, epggrab_ota_module_ops_t *ops ) { @@ -596,7 +597,7 @@ epggrab_module_ota_t *epggrab_module_ota_create /* Pass through */ epggrab_module_create((epggrab_module_t*)skel, &epggrab_mod_ota_class, - id, saveid, name, priority); + id, subsys, saveid, name, priority); /* Setup */ skel->type = EPGGRAB_OTA; diff --git a/src/epggrab/module/eit.c b/src/epggrab/module/eit.c index 19505ce55..0e9fd26c6 100644 --- a/src/epggrab/module/eit.c +++ b/src/epggrab/module/eit.c @@ -67,12 +67,12 @@ _eit_dtag_dump #if APS_DEBUG int i = 0, j = 0; char tmp[100]; - tvhlog(LOG_DEBUG, mod->id, " dtag 0x%02X len %d", dtag, dlen); + tvhdebug(mod->subsys, "%s: dtag 0x%02X len %d", mt->mt_name, dtag, dlen); while (i < dlen) { j += sprintf(tmp+j, "%02X ", buf[i]); i++; if ((i % 8) == 0 || (i == dlen)) { - tvhlog(LOG_DEBUG, mod->id, " %s", tmp); + tvhdebug(mod->subsys, "%s: %s", mt->mt_name, tmp); j = 0; } } @@ -436,8 +436,8 @@ static int _eit_process_event_one /* Find broadcast */ ebc = epg_broadcast_find_by_time(ch, mod, start, stop, 1, &save2, &changes2); - tvhtrace("eit", "svc='%s', ch='%s', eid=%5d, start=%"PRItime_t"," - " stop=%"PRItime_t", ebc=%p", + tvhtrace(LS_TBL_EIT, "svc='%s', ch='%s', eid=%5d, start=%"PRItime_t"," + " stop=%"PRItime_t", ebc=%p", svc->s_dvb_svcname ?: "(null)", ch ? channel_get_name(ch) : "(null)", eid, start, stop, ebc); if (!ebc) return 0; @@ -459,8 +459,8 @@ static int _eit_process_event_one ptr += 2; if (dllen < dlen) break; - tvhtrace(mod->id, " dtag %02X dlen %d", dtag, dlen); - tvhlog_hexdump(mod->id, ptr, dlen); + tvhtrace(mod->subsys, "%s: dtag %02X dlen %d", mod->id, dtag, dlen); + tvhlog_hexdump(mod->subsys, ptr, dlen); switch (dtag) { case DVB_DESC_SHORT_EVENT: @@ -680,7 +680,7 @@ _eit_callback !mm->mm_eit_tsid_nocheck) { if (mm->mm_onid != MPEGTS_ONID_NONE && mm->mm_tsid != MPEGTS_TSID_NONE) - tvhtrace("eit", + tvhtrace(LS_TBL_EIT, "invalid tsid found tid 0x%02X, onid:tsid %d:%d != %d:%d", tableid, mm->mm_onid, mm->mm_tsid, onid, tsid); mm = NULL; @@ -692,7 +692,7 @@ _eit_callback /* Get service */ svc = mpegts_mux_find_service(mm, sid); if (!svc) { - tvhtrace("eit", "sid %i not found", sid); + tvhtrace(LS_TBL_EIT, "sid %i not found", sid); goto done; } @@ -762,7 +762,7 @@ static int _eit_start /* Freesat (3002/3003) */ if (!strcmp("uk_freesat", m->id)) { - mpegts_table_add(dm, 0, 0, dvb_bat_callback, NULL, "bat", MT_CRC, 3002, MPS_WEIGHT_EIT); + mpegts_table_add(dm, 0, 0, dvb_bat_callback, NULL, "bat", LS_TBL_BASE, MT_CRC, 3002, MPS_WEIGHT_EIT); pid = 3003; /* Viasat Baltic (0x39) */ @@ -778,9 +778,9 @@ static int _eit_start pid = DVB_EIT_PID; opts = MT_RECORD; } - mpegts_table_add(dm, 0, 0, _eit_callback, map, m->id, MT_CRC | opts, pid, MPS_WEIGHT_EIT); + mpegts_table_add(dm, 0, 0, _eit_callback, map, m->id, LS_TBL_EIT, MT_CRC | opts, pid, MPS_WEIGHT_EIT); // TODO: might want to limit recording to EITpf only - tvhlog(LOG_DEBUG, m->id, "installed table handlers"); + tvhdebug(m->subsys, "%s: installed table handlers", m->id); return 0; } @@ -826,11 +826,11 @@ void eit_init ( void ) .tune = _eit_tune, }; - epggrab_module_ota_create(NULL, "eit", NULL, "EIT: DVB Grabber", 1, &ops); - epggrab_module_ota_create(NULL, "uk_freesat", NULL, "UK: Freesat", 5, &ops); - epggrab_module_ota_create(NULL, "uk_freeview", NULL, "UK: Freeview", 5, &ops); - epggrab_module_ota_create(NULL, "viasat_baltic", NULL, "VIASAT: Baltic", 5, &ops); - epggrab_module_ota_create(NULL, "Bulsatcom_39E", NULL, "Bulsatcom: Bula 39E", 5, &ops); + epggrab_module_ota_create(NULL, "eit", LS_TBL_EIT, NULL, "EIT: DVB Grabber", 1, &ops); + epggrab_module_ota_create(NULL, "uk_freesat", LS_TBL_EIT, NULL, "UK: Freesat", 5, &ops); + epggrab_module_ota_create(NULL, "uk_freeview", LS_TBL_EIT, NULL, "UK: Freeview", 5, &ops); + epggrab_module_ota_create(NULL, "viasat_baltic", LS_TBL_EIT, NULL, "VIASAT: Baltic", 5, &ops); + epggrab_module_ota_create(NULL, "Bulsatcom_39E", LS_TBL_EIT, NULL, "Bulsatcom: Bula 39E", 5, &ops); } void eit_done ( void ) diff --git a/src/epggrab/module/opentv.c b/src/epggrab/module/opentv.c index dc579174a..6abf06f51 100644 --- a/src/epggrab/module/opentv.c +++ b/src/epggrab/module/opentv.c @@ -268,7 +268,7 @@ static int _opentv_parse_event int i = 4, r; if (slen+4 > len) { - tvhtrace("opentv", "event len (%d) > table len (%d)", slen+4, len); + tvhtrace(LS_OPENTV, "event len (%d) > table len (%d)", slen+4, len); return -1; } @@ -300,7 +300,7 @@ static void *_opentv_apply_pattern_list(char *buf, size_t size_buf, const char * memcpy(buf, text + match[1].rm_so, size); buf[size] = '\0'; if (size) { - tvhtrace("opentv"," pattern \"%s\" matches with '%s'", p->text, buf); + tvhtrace(LS_OPENTV," pattern \"%s\" matches with '%s'", p->text, buf); return buf; } } @@ -343,13 +343,13 @@ opentv_parse_event_section_one if (ev.start && ev.stop) { ebc = epg_broadcast_find_by_time(ch, src, ev.start, ev.stop, 1, &save, &changes); - tvhdebug("opentv", "find by time start %"PRItime_t " stop " + tvhdebug(LS_OPENTV, "find by time start %"PRItime_t " stop " "%"PRItime_t " eid %d = %p", ev.start, ev.stop, ev.eid, ebc); save |= epg_broadcast_set_dvb_eid(ebc, ev.eid, &changes); } else { ebc = epg_broadcast_find_by_eid(ch, ev.eid); - tvhdebug("opentv", "find by eid %d = %p", ev.eid, ebc); + tvhdebug(LS_OPENTV, "find by eid %d = %p", ev.eid, ebc); if (ebc && ebc->grabber != src) goto done; merge = 1; @@ -359,13 +359,13 @@ opentv_parse_event_section_one /* Summary / Description */ if (ev.summary) { - tvhdebug("opentv", " summary '%s'", ev.summary); + tvhdebug(LS_OPENTV, " summary '%s'", ev.summary); ls = lang_str_create2(ev.summary, lang); save |= epg_broadcast_set_summary(ebc, ls, &changes); lang_str_destroy(ls); } if (ev.desc) { - tvhdebug("opentv", " desc '%s'", ev.desc); + tvhdebug(LS_OPENTV, " desc '%s'", ev.desc); ls = lang_str_create2(ev.desc, lang); save |= epg_broadcast_set_description(ebc, ls, &changes); lang_str_destroy(ls); @@ -391,13 +391,13 @@ opentv_parse_event_section_one if ((ee = epg_episode_find_by_broadcast(ebc, src, 1, &save, &changes3))) { save |= epg_broadcast_set_episode(ebc, ee, &changes); - tvhdebug("opentv", " find episode %p", ee); + tvhdebug(LS_OPENTV, " find episode %p", ee); if (ev.title) { - tvhdebug("opentv", " title '%s'", ev.title); + tvhdebug(LS_OPENTV, " title '%s'", ev.title); /* try to cleanup the title */ if (_opentv_apply_pattern_list(buffer, sizeof(buffer), ev.title, &mod->p_cleanup_title)) { - tvhtrace("opentv", " clean title '%s'", buffer); + tvhtrace(LS_OPENTV, " clean title '%s'", buffer); s = buffer; } else { s = ev.title; @@ -419,11 +419,11 @@ opentv_parse_event_section_one /* search for season number */ if (_opentv_apply_pattern_list(buffer, sizeof(buffer), ev.summary, &mod->p_snum)) if ((en.s_num = atoi(buffer))) - tvhtrace("opentv"," extract season number %d", en.s_num); + tvhtrace(LS_OPENTV," extract season number %d", en.s_num); /* ...for episode number */ if (_opentv_apply_pattern_list(buffer, sizeof(buffer), ev.summary, &mod->p_enum)) if ((en.e_num = atoi(buffer))) - tvhtrace("opentv"," extract episode number %d", en.e_num); + tvhtrace(LS_OPENTV," extract episode number %d", en.e_num); /* ...for part number */ if (_opentv_apply_pattern_list(buffer, sizeof(buffer), ev.summary, &mod->p_pnum)) { if (buffer[0] >= 'a' && buffer[0] <= 'z') @@ -432,7 +432,7 @@ opentv_parse_event_section_one if (buffer[0] >= 'A' && buffer[0] <= 'Z') en.p_num = buffer[0] - 'A' + 1; if (en.p_num) - tvhtrace("opentv"," extract part number %d", en.p_num); + tvhtrace(LS_OPENTV," extract part number %d", en.p_num); } /* save any found number */ if (en.s_num || en.e_num || en.p_num) @@ -440,7 +440,7 @@ opentv_parse_event_section_one /* ...for subtitle */ if (_opentv_apply_pattern_list(buffer, sizeof(buffer), ev.summary, &mod->p_subt)) { - tvhtrace("opentv", " extract subtitle '%s'", buffer); + tvhtrace(LS_OPENTV, " extract subtitle '%s'", buffer); ls = lang_str_create2(buffer, lang); save |= epg_episode_set_subtitle(ee, ls, &changes3); lang_str_destroy(ls); @@ -520,25 +520,25 @@ opentv_desc_channels cid = ((int)buf[i+3] << 8) | buf[i+4]; cnum = ((int)buf[i+5] << 8) | buf[i+6]; unk = ((int)buf[i+7] << 8) | buf[i+8]; - tvhtrace(mt->mt_name, " sid %04X type %02X cid %04X cnum %d unk %04X", sid, type, cid, cnum, unk); + tvhtrace(LS_OPENTV, "%s: sid %04X type %02X cid %04X cnum %d unk %04X", mt->mt_name, sid, type, cid, cnum, unk); cnum = cnum < 65535 ? cnum : 0; /* Find the service */ svc = mpegts_service_find(mm, sid, 0, 0, NULL); - tvhtrace(mt->mt_name, " svc %p [%s]", svc, svc ? svc->s_nicename : NULL); + tvhtrace(LS_OPENTV, "%s: svc %p [%s]", mt->mt_name, svc, svc ? svc->s_nicename : NULL); if (svc && svc->s_dvb_opentv_chnum != cnum && (!svc->s_dvb_opentv_id || svc->s_dvb_opentv_id == unk)) { if (mod->bouquetid != nbid) { if (mod->bouquet_auto) { if (nbid < mod->bouquetid) { - tvhwarn(mt->mt_name, "bouquet id set to %d, report this!", nbid); + tvhwarn(LS_OPENTV, "%s: bouquet id set to %d, report this!", mt->mt_name, nbid); mod->bouquetid = nbid; } else goto skip_chnum; } else goto skip_chnum; } - tvhtrace(mt->mt_name, " cnum changed (%i != %i)", cnum, (int)svc->s_dvb_opentv_chnum); + tvhtrace(LS_OPENTV, "%s: cnum changed (%i != %i)", mt->mt_name, cnum, (int)svc->s_dvb_opentv_chnum); svc->s_dvb_opentv_chnum = cnum; svc->s_dvb_opentv_id = unk; service_request_save((service_t *)svc, 0); @@ -548,7 +548,7 @@ skip_chnum: ec =_opentv_find_epggrab_channel(mod, cid, 1, &save); ilm = LIST_FIRST(&ec->channels); ch = (channel_t *)LIST_FIRST(&svc->s_channels)->ilm_in2; - tvhtrace(mt->mt_name, " ec = %p, ilm = %p", ec, ilm); + tvhtrace(mt->mt_subsys, "%s: ec = %p, ilm = %p", mt->mt_name, ec, ilm); if (ilm && ilm->ilm_in2 != &ch->ch_id) { epggrab_channel_link_delete(ec, ch, 1); @@ -615,8 +615,8 @@ opentv_table_callback done: if (!r) { sta->os_map->om_first = 0; /* valid data mark */ - tvhtrace(mt->mt_name, "pid %d complete remain %d", - mt->mt_pid, sta->os_refcount-1); + tvhtrace(mt->mt_subsys, "%s: pid %d complete remain %d", + mt->mt_name, mt->mt_pid, sta->os_refcount-1); /* Last PID */ if (sta->os_refcount == 1) { @@ -624,7 +624,7 @@ done: if (mt->mt_table == OPENTV_TITLE_BASE) { if (sta->os_titles_start + sec2mono(mod->titles_time) < mclk()) { int *t; - tvhinfo(mt->mt_name, "titles complete"); + tvhinfo(mt->mt_subsys, "%s: titles complete", mt->mt_name); /* Summaries */ t = mod->summary; @@ -633,7 +633,7 @@ done: mt2 = mpegts_table_add(mt->mt_mux, OPENTV_SUMMARY_BASE, OPENTV_TABLE_MASK, opentv_table_callback, sta, - mod->id, MT_CRC, *t++, + mod->id, LS_OPENTV, MT_CRC, *t++, MPS_WEIGHT_EIT); if (mt2) { sta->os_refcount++; @@ -645,7 +645,7 @@ done: } } else { if (sta->os_summaries_start + sec2mono(mod->summaries_time) < mclk()) { - tvhinfo(mt->mt_name, "summaries complete"); + tvhinfo(mt->mt_subsys, "%s: summaries complete", mt->mt_name); mpegts_table_destroy(mt); if (ota) epggrab_ota_complete((epggrab_module_ota_t*)mod, ota); @@ -692,7 +692,7 @@ opentv_bat_callback /* Complete */ if (!r) { - tvhinfo(mt->mt_name, "channels complete"); + tvhinfo(mt->mt_subsys, "%s: channels complete", mt->mt_name); /* Install event handlers */ t = mod->title; @@ -701,7 +701,7 @@ opentv_bat_callback mt2 = mpegts_table_add(mt->mt_mux, OPENTV_TITLE_BASE, OPENTV_TABLE_MASK, opentv_table_callback, mt->mt_opaque, - mod->id, MT_CRC, *t++, + mod->id, LS_OPENTV, MT_CRC, *t++, MPS_WEIGHT_EIT); if (mt2) { if (!mt2->mt_destroy) { @@ -741,7 +741,7 @@ static int _opentv_start if (mod->tsid != mm->mm_tsid) return -1; /* Install tables */ - tvhdebug(mod->id, "install table handlers"); + tvhdebug(mod->subsys, "%s: install table handlers", mod->id); /* Channels */ t = mod->channel; @@ -753,7 +753,7 @@ static int _opentv_start } mt = mpegts_table_add(mm, DVB_BAT_BASE, DVB_BAT_MASK, opentv_bat_callback, sta, - m->id, MT_CRC, *t++, + m->id, LS_OPENTV, MT_CRC, *t++, MPS_WEIGHT_EIT); if (mt) { mt->mt_mux_cb = bat_desc; @@ -810,11 +810,11 @@ static void _opentv_compile_pattern_list ( opentv_pattern_list_t *list, htsmsg_t pattern = calloc(1, sizeof(opentv_pattern_t)); pattern->text = strdup(s); if (regcomp(&pattern->compiled, pattern->text, REG_EXTENDED)) { - tvhlog(LOG_WARNING, "opentv", "error compiling pattern \"%s\"", pattern->text); + tvhwarn(LS_OPENTV, "error compiling pattern \"%s\"", pattern->text); free(pattern->text); free(pattern); } else { - tvhtrace("opentv", "compiled pattern \"%s\"", pattern->text); + tvhtrace(LS_OPENTV, "compiled pattern \"%s\"", pattern->text); TAILQ_INSERT_TAIL(list, pattern, p_links); } } @@ -826,7 +826,7 @@ static int _opentv_genre_load_one ( const char *id, htsmsg_t *m ) opentv_genre_t *genre = calloc(1, sizeof(opentv_genre_t)); genre->id = (char*)id; if (RB_INSERT_SORTED(&_opentv_genres, genre, h_link, _genre_cmp)) { - tvhlog(LOG_DEBUG, "opentv", "ignore duplicate genre map %s", id); + tvhdebug(LS_OPENTV, "ignore duplicate genre map %s", id); free(genre); return 0; } else { @@ -849,9 +849,9 @@ static void _opentv_genre_load ( htsmsg_t *m ) if ((e = htsmsg_get_list(m, f->hmf_name))) { if ((r = _opentv_genre_load_one(f->hmf_name, e))) { if (r > 0) - tvhlog(LOG_DEBUG, "opentv", "genre map %s loaded", f->hmf_name); + tvhdebug(LS_OPENTV, "genre map %s loaded", f->hmf_name); else - tvhlog(LOG_WARNING, "opentv", "genre map %s failed", f->hmf_name); + tvhwarn(LS_OPENTV, "genre map %s failed", f->hmf_name); } } } @@ -863,7 +863,7 @@ static int _opentv_dict_load_one ( const char *id, htsmsg_t *m ) opentv_dict_t *dict = calloc(1, sizeof(opentv_dict_t)); dict->id = (char*)id; if (RB_INSERT_SORTED(&_opentv_dicts, dict, h_link, _dict_cmp)) { - tvhlog(LOG_DEBUG, "opentv", "ignore duplicate dictionary %s", id); + tvhdebug(LS_OPENTV, "ignore duplicate dictionary %s", id); free(dict); return 0; } else { @@ -888,9 +888,9 @@ static void _opentv_dict_load ( htsmsg_t *m ) if ((e = htsmsg_get_list(m, f->hmf_name))) { if ((r = _opentv_dict_load_one(f->hmf_name, e))) { if (r > 0) - tvhlog(LOG_DEBUG, "opentv", "dictionary %s loaded", f->hmf_name); + tvhdebug(LS_OPENTV, "dictionary %s loaded", f->hmf_name); else - tvhlog(LOG_WARNING, "opentv", "dictionary %s failed", f->hmf_name); + tvhwarn(LS_OPENTV, "dictionary %s failed", f->hmf_name); } } } @@ -984,7 +984,7 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m ) sprintf(nbuf, "OpenTV: %s", name); mod = (opentv_module_t *) epggrab_module_ota_create(calloc(1, sizeof(opentv_module_t)), - ibuf, NULL, nbuf, 2, &ops); + ibuf, LS_OPENTV, NULL, nbuf, 2, &ops); /* Add provider details */ mod->dict = dict; @@ -994,8 +994,8 @@ static int _opentv_prov_load_one ( const char *id, htsmsg_t *m ) mod->sid = sid; mod->bouquetid = bouquetid; mod->bouquet_auto = bouquetid == 0; - mod->titles_time = MINMAX(titles_time, 0, 120); - mod->summaries_time = MINMAX(summaries_time, 0, 600); + mod->titles_time = MAX(titles_time, 120); + mod->summaries_time = MAX(summaries_time, 600); mod->channel = _pid_list_to_array(cl); mod->title = _pid_list_to_array(tl); mod->summary = _pid_list_to_array(sl); @@ -1017,9 +1017,9 @@ static void _opentv_prov_load ( htsmsg_t *m ) if ((e = htsmsg_get_map_by_field(f))) { if ((r = _opentv_prov_load_one(f->hmf_name, e))) { if (r > 0) - tvhlog(LOG_DEBUG, "opentv", "provider %s loaded", f->hmf_name); + tvhdebug(LS_OPENTV, "provider %s loaded", f->hmf_name); else - tvhlog(LOG_WARNING, "opentv", "provider %s failed", f->hmf_name); + tvhwarn(LS_OPENTV, "provider %s failed", f->hmf_name); } } } @@ -1037,17 +1037,17 @@ void opentv_init ( void ) /* Load dictionaries */ if ((m = hts_settings_load("epggrab/opentv/dict"))) _opentv_dict_load(m); - tvhlog(LOG_DEBUG, "opentv", "dictonaries loaded"); + tvhdebug(LS_OPENTV, "dictonaries loaded"); /* Load genres */ if ((m = hts_settings_load("epggrab/opentv/genre"))) _opentv_genre_load(m); - tvhlog(LOG_DEBUG, "opentv", "genre maps loaded"); + tvhdebug(LS_OPENTV, "genre maps loaded"); /* Load providers */ if ((m = hts_settings_load("epggrab/opentv/prov"))) _opentv_prov_load(m); - tvhlog(LOG_DEBUG, "opentv", "providers loaded"); + tvhdebug(LS_OPENTV, "providers loaded"); } void opentv_done ( void ) diff --git a/src/epggrab/module/psip.c b/src/epggrab/module/psip.c index cf6b38782..1ea46a26b 100644 --- a/src/epggrab/module/psip.c +++ b/src/epggrab/module/psip.c @@ -149,13 +149,13 @@ psip_activate_table(psip_status_t *ps, psip_table_t *pt) if (IS_EIT(pt->pt_type)) { /* This is an EIT table */ mt = mpegts_table_add(ps->ps_mm, DVB_ATSC_EIT_BASE, DVB_ATSC_EIT_MASK, - _psip_eit_callback, ps, "aeit", + _psip_eit_callback, ps, "aeit", LS_PSIP, MT_CRC | MT_RECORD, pt->pt_pid, MPS_WEIGHT_EIT); } else if (IS_ETT(pt->pt_type)) { /* This is an ETT table */ mt = mpegts_table_add(ps->ps_mm, DVB_ATSC_ETT_BASE, DVB_ATSC_ETT_MASK, - _psip_ett_callback, ps, "ett", + _psip_ett_callback, ps, "ett", LS_PSIP, MT_CRC | MT_RECORD, pt->pt_pid, MPS_WEIGHT_ETT); } else { @@ -165,7 +165,7 @@ psip_activate_table(psip_status_t *ps, psip_table_t *pt) mt->mt_destroy = psip_status_destroy; pt->pt_start = mclk(); pt->pt_table = mt; - tvhtrace("psip", "table activated - pid 0x%04X type 0x%04X", mt->mt_pid, pt->pt_type); + tvhtrace(LS_PSIP, "table activated - pid 0x%04X type 0x%04X", mt->mt_pid, pt->pt_type); return mt; } @@ -204,14 +204,14 @@ psip_reschedule_tables(psip_status_t *ps) TAILQ_FOREACH(pt, &ps->ps_tables, pt_link) { total++; if (pt->pt_table && pt->pt_start + sec2mono(10) < mclk()) { - tvhtrace("psip", "table late: pid = 0x%04X, type = 0x%04X\n", pt->pt_pid, pt->pt_type); + tvhtrace(LS_PSIP, "table late: pid = 0x%04X, type = 0x%04X\n", pt->pt_pid, pt->pt_type); mpegts_table_destroy(pt->pt_table); pt->pt_table = NULL; } } tables = malloc(total * sizeof(psip_table_t *)); - tvhtrace("psip", "reschedule tables, total %d", total); + tvhtrace(LS_PSIP, "reschedule tables, total %d", total); i = 0; TAILQ_FOREACH(pt, &ps->ps_tables, pt_link) @@ -222,7 +222,7 @@ psip_reschedule_tables(psip_status_t *ps) #if 0 for (i = 0; i < total; i++) { pt = tables[i]; - tvhtrace("psip", "sorted: pid = 0x%04X, type = 0x%04X, time = %"PRId64", complete %d\n", + tvhtrace(LS_PSIP, "sorted: pid = 0x%04X, type = 0x%04X, time = %"PRId64", complete %d\n", pt->pt_pid, pt->pt_type, pt->pt_start, pt->pt_complete); } #endif @@ -255,7 +255,7 @@ psip_complete_table(psip_status_t *ps, mpegts_table_t *mt) break; } - tvhtrace("psip", "pid 0x%04X completed, found = %d", mt->mt_pid, pt != NULL); + tvhtrace(LS_PSIP, "pid 0x%04X completed, found = %d", mt->mt_pid, pt != NULL); mpegts_table_destroy(mt); @@ -374,21 +374,21 @@ _psip_eit_callback_channel dlen = ((ptr[10+titlelen] & 0x0f) << 8) | ptr[11+titlelen]; size = titlelen + dlen + 12; - tvhtrace("psip", " %03d: titlelen %d, dlen %d", i, titlelen, dlen); + tvhtrace(LS_PSIP, " %03d: titlelen %d, dlen %d", i, titlelen, dlen); if (size > len) break; title = atsc_get_string(ptr+10, titlelen); if (title == NULL) continue; - tvhtrace("psip", " %03d: [%s] eventid 0x%04x at %"PRItime_t", duration %d, title: '%s' (%d bytes)", + tvhtrace(LS_PSIP, " %03d: [%s] eventid 0x%04x at %"PRItime_t", duration %d, title: '%s' (%d bytes)", i, ch ? channel_get_name(ch) : "(null)", eventid, start, length, lang_str_get(title, NULL), titlelen); save2 = save3 = changes2 = changes3 = 0; ebc = epg_broadcast_find_by_time(ch, mod, start, stop, 1, &save2, &changes2); - tvhtrace("psip", " eid=%5d, start=%"PRItime_t", stop=%"PRItime_t", ebc=%p", + tvhtrace(LS_PSIP, " eid=%5d, start=%"PRItime_t", stop=%"PRItime_t", ebc=%p", eventid, start, stop, ebc); if (!ebc) goto next; @@ -480,7 +480,7 @@ _psip_eit_callback break; } if (!svc) { - tvhtrace("psip", "EIT with no associated channel found (tsid 0x%04x)", tsid); + tvhtrace(LS_PSIP, "EIT with no associated channel found (tsid 0x%04x)", tsid); return -1; } @@ -493,12 +493,12 @@ _psip_eit_callback &st, §, &last, &ver); if (r == 0) goto complete; if (r != 1) return r; - tvhtrace("psip", "0x%04x: EIT tsid %04X (%s), ver %d", + tvhtrace(LS_PSIP, "0x%04x: EIT tsid %04X (%s), ver %d", mt->mt_pid, tsid, svc->s_dvb_svcname, ver); /* # events */ count = ptr[6]; - tvhtrace("psip", "event count %d data len %d", count, len); + tvhtrace(LS_PSIP, "event count %d data len %d", count, len); ptr += 7; len -= 7; @@ -582,7 +582,7 @@ _psip_ett_callback break; } if (!svc) { - tvhtrace("psip", "ETT with no associated channel found (sourceid 0x%04x)", sourceid); + tvhtrace(LS_PSIP, "ETT with no associated channel found (sourceid 0x%04x)", sourceid); return -1; } @@ -591,7 +591,7 @@ _psip_ett_callback goto done; if (!isevent) { - tvhtrace("psip", "0x%04x: channel ETT tableid 0x%04X [%s], ver %d", mt->mt_pid, tsid, svc->s_dvb_svcname, ver); + tvhtrace(LS_PSIP, "0x%04x: channel ETT tableid 0x%04X [%s], ver %d", mt->mt_pid, tsid, svc->s_dvb_svcname, ver); } else { found = 1; description = atsc_get_string(ptr+10, len-10); @@ -603,7 +603,7 @@ _psip_ett_callback if (ebc && ebc->grabber == mod) { save |= epg_broadcast_set_description(ebc, description, &changes); save |= epg_broadcast_change_finish(ebc, changes, 1); - tvhtrace("psip", "0x%04x: ETT tableid 0x%04X [%s], eventid 0x%04X (%d) ['%s'], ver %d", + tvhtrace(LS_PSIP, "0x%04x: ETT tableid 0x%04X [%s], eventid 0x%04X (%d) ['%s'], ver %d", mt->mt_pid, tsid, svc->s_dvb_svcname, eventid, eventid, lang_str_get(ebc->episode->title, "eng"), ver); } else { @@ -611,7 +611,7 @@ _psip_ett_callback } } if (found == 0) { - tvhtrace("psip", "0x%04x: ETT tableid 0x%04X [%s], eventid 0x%04X (%d), ver %d - no matching broadcast found [%.80s]", + tvhtrace(LS_PSIP, "0x%04x: ETT tableid 0x%04X [%s], eventid 0x%04X (%d), ver %d - no matching broadcast found [%.80s]", mt->mt_pid, tsid, svc->s_dvb_svcname, eventid, eventid, ver, lang_str_get(description, NULL)); psip_add_desc(ps, eventid, ptr+10, len-10); } @@ -668,7 +668,7 @@ _psip_mgt_callback ptr += 8; len -= 8; - tvhtrace("psip", "0x%04x: MGT tsid %04X (%d), ver %d, count %d", mt->mt_pid, tsid, tsid, ver, count); + tvhtrace(LS_PSIP, "0x%04x: MGT tsid %04X (%d), ver %d, count %d", mt->mt_pid, tsid, tsid, ver, count); for (i = 0; i < count && len >= 11; i++) { unsigned int type, tablepid, tablever, tablesize; @@ -681,7 +681,7 @@ _psip_mgt_callback tablever = ptr[4] & 0x1f; tablesize = ptr[5] << 24 | ptr[6] << 16 | ptr[7] << 8 | ptr[8]; - tvhdebug("psip", "table %d - type 0x%04X, pid 0x%04X, ver 0x%04X, size 0x%08X", + tvhdebug(LS_PSIP, "table %d - type 0x%04X, pid 0x%04X, ver 0x%04X, size 0x%08X", i, type, tablepid, tablever, tablesize); psip_update_table(ps, tablepid, type); @@ -718,13 +718,13 @@ static int _psip_start /* Listen for Master Guide Table */ mt = mpegts_table_add(dm, DVB_ATSC_MGT_BASE, DVB_ATSC_MGT_MASK, - _psip_mgt_callback, ps, "mgt", + _psip_mgt_callback, ps, "mgt", LS_TBL_EIT, MT_CRC | MT_QUICKREQ | MT_RECORD, DVB_ATSC_MGT_PID, MPS_WEIGHT_MGT); if (mt && !mt->mt_destroy) { ps->ps_refcount++; mt->mt_destroy = psip_status_destroy; - tvhlog(LOG_DEBUG, m->id, "installed table handlers"); + tvhdebug(mt->mt_subsys, "%s: installed table handlers", mt->mt_name); } if (!ps->ps_refcount) free(ps); @@ -775,7 +775,7 @@ void psip_init ( void ) .tune = _psip_tune, }; - epggrab_module_ota_create(NULL, "psip", NULL, "PSIP: ATSC Grabber", 1, &ops); + epggrab_module_ota_create(NULL, "psip", LS_PSIP, NULL, "PSIP: ATSC Grabber", 1, &ops); } void psip_done ( void ) diff --git a/src/epggrab/module/pyepg.c b/src/epggrab/module/pyepg.c index 6131a76fa..7e3a409c1 100644 --- a/src/epggrab/module/pyepg.c +++ b/src/epggrab/module/pyepg.c @@ -479,12 +479,13 @@ void pyepg_init ( void ) /* Internal module */ if (find_exec("pyepg", buf, sizeof(buf)-1)) epggrab_module_int_create(NULL, &epggrab_mod_int_pyepg_class, - "pyepg-internal", "pyepg", "PyEPG", 4, buf, + "pyepg-internal", LS_PYEPG, "pyepg", + "PyEPG", 4, buf, NULL, _pyepg_parse, NULL); /* External module */ epggrab_module_ext_create(NULL, &epggrab_mod_ext_pyepg_class, - "pyepg", "pyepg", "PyEPG", 4, "pyepg", + "pyepg", LS_PYEPG, "pyepg", "PyEPG", 4, "pyepg", _pyepg_parse, NULL); } diff --git a/src/epggrab/module/xmltv.c b/src/epggrab/module/xmltv.c index 580fe6f87..7751c3749 100644 --- a/src/epggrab/module/xmltv.c +++ b/src/epggrab/module/xmltv.c @@ -823,7 +823,7 @@ static void _xmltv_load_grabbers ( void ) outbuf[i] = '\0'; sprintf(name, "XMLTV: %s", &outbuf[n]); epggrab_module_int_create(NULL, &epggrab_mod_int_xmltv_class, - &outbuf[p], "xmltv", + &outbuf[p], LS_XMLTV, "xmltv", name, 3, &outbuf[p], NULL, _xmltv_parse, NULL); p = n = i + 1; @@ -842,7 +842,7 @@ static void _xmltv_load_grabbers ( void ) /* Internal search */ } else if ((tmp = getenv("PATH"))) { - tvhdebug("epggrab", "using internal grab search"); + tvhdebug(LS_XMLTV, "using internal grab search"); char bin[256]; char *argv[] = { NULL, @@ -871,7 +871,7 @@ static void _xmltv_load_grabbers ( void ) if (outbuf[outlen-1] == '\n') outbuf[outlen-1] = '\0'; snprintf(name, sizeof(name), "XMLTV: %s", outbuf); epggrab_module_int_create(NULL, &epggrab_mod_int_xmltv_class, - bin, "xmltv", name, 3, bin, + bin, LS_XMLTV, "xmltv", name, 3, bin, NULL, _xmltv_parse, NULL); free(outbuf); } else { @@ -891,7 +891,7 @@ void xmltv_init ( void ) { /* External module */ epggrab_module_ext_create(NULL, &epggrab_mod_ext_xmltv_class, - "xmltv", "xmltv", "XMLTV", 3, "xmltv", + "xmltv", LS_XMLTV, "xmltv", "XMLTV", 3, "xmltv", _xmltv_parse, NULL); /* Standard modules */ diff --git a/src/epggrab/otamux.c b/src/epggrab/otamux.c index 4c29cb3e6..87b883953 100644 --- a/src/epggrab/otamux.c +++ b/src/epggrab/otamux.c @@ -195,7 +195,7 @@ epggrab_ota_done ( epggrab_ota_mux_t *om, int reason ) mm = mpegts_mux_find(om->om_mux_uuid); mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhdebug("epggrab", "grab done for %s (%s)", name, reasons[reason]); + tvhdebug(LS_EPGGRAB, "grab done for %s (%s)", name, reasons[reason]); mtimer_disarm(&om->om_timer); mtimer_disarm(&om->om_data_timer); @@ -215,7 +215,7 @@ epggrab_ota_done ( epggrab_ota_mux_t *om, int reason ) om->om_requeue = 0; LIST_FOREACH(map, &om->om_modules, om_link) if (!map->om_complete) - tvhlog(LOG_WARNING, "epggrab", "%s - data completion timeout for %s", map->om_module->name, name); + tvhwarn(LS_EPGGRAB, "%s - data completion timeout for %s", map->om_module->name, name); } else { om->om_requeue = 0; } @@ -276,7 +276,7 @@ epggrab_ota_start ( epggrab_ota_mux_t *om, mpegts_mux_t *mm ) if (map->om_module->start(map, mm) < 0) { map->om_complete = 1; } else - tvhdebug(map->om_module->id, "grab started"); + tvhdebug(map->om_module->subsys, "%s: grab started", map->om_module->id); } } @@ -321,7 +321,7 @@ epggrab_mux_stop ( mpegts_mux_t *mm, void *p, int reason ) if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "mux %s (%p) stop", name, mm); + tvhtrace(LS_EPGGRAB, "mux %s (%p) stop", name, mm); } TAILQ_FOREACH(ota, &epggrab_ota_active, om_q_link) if (!strcmp(ota->om_mux_uuid, uuid)) { @@ -355,7 +355,7 @@ epggrab_ota_register if (!ota) { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhinfo(mod->id, "registering mux %s", buf); + tvhinfo(mod->subsys, "%s: registering mux %s", buf, mod->id); ota = epggrab_ota_mux_skel; SKEL_USED(epggrab_ota_mux_skel); ota->om_mux_uuid = strdup(uuid); @@ -394,7 +394,7 @@ epggrab_ota_complete lock_assert(&global_lock); if (!ota->om_complete) - tvhdebug(mod->id, "grab complete"); + tvhdebug(mod->subsys, "%s: grab complete", mod->id); /* Test for completion */ LIST_FOREACH(map, &ota->om_modules, om_link) { @@ -403,7 +403,7 @@ epggrab_ota_complete } else if (!map->om_complete && !map->om_first) { done = 0; } - tvhtrace("epggrab", "%s complete %i first %i", + tvhtrace(LS_EPGGRAB, "%s complete %i first %i", map->om_module->id, map->om_complete, map->om_first); } @@ -464,7 +464,7 @@ epggrab_ota_data_timeout_cb ( void *p ) /* Not completed, but no data - wait for a manual mux tuning */ epggrab_ota_complete_mark(om, 1); } else { - tvhtrace("epggrab", "data timeout check succeed"); + tvhtrace(LS_EPGGRAB, "data timeout check succeed"); } } @@ -504,7 +504,7 @@ epggrab_ota_kick_cb ( void *p ) if (!om) return; - tvhtrace("epggrab", "ota - kick callback"); + tvhtrace(LS_EPGGRAB, "ota - kick callback"); next_one: /* Find the mux */ @@ -550,7 +550,7 @@ next_one: if (epg_flag < 0 || epg_flag == MM_EPG_DISABLE) { if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "epg mux %s is disabled, skipping", name); + tvhtrace(LS_EPGGRAB, "epg mux %s is disabled, skipping", name); } goto done; } @@ -566,7 +566,7 @@ next_one: } if ((i == 0 || (r == 0 && modname)) && epg_flag != MM_EPG_FORCE) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhdebug("epggrab", "no OTA modules active for %s, check again next time", name); + tvhdebug(LS_EPGGRAB, "no OTA modules active for %s, check again next time", name); goto done; } @@ -584,7 +584,7 @@ next_one: if (r != SM_CODE_NO_ADAPTERS) { if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "subscription failed for %s (result %d)", name, r); + tvhtrace(LS_EPGGRAB, "subscription failed for %s (result %d)", name, r); } TAILQ_INSERT_TAIL(&epggrab_ota_pending, om, om_q_link); om->om_q_type = EPGGRAB_OTA_MUX_PENDING; @@ -595,14 +595,14 @@ next_one: } else { if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "no free adapter for %s (subscribe)", name); + tvhtrace(LS_EPGGRAB, "no free adapter for %s (subscribe)", name); } net->fatal = 1; } } else { if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "mux %s (%p), started", name, mm); + tvhtrace(LS_EPGGRAB, "mux %s (%p), started", name, mm); } kick = 0; /* note: it is possible that the mux_start listener is not called */ @@ -623,7 +623,7 @@ done: i++; TAILQ_FOREACH(om, &epggrab_ota_pending, om_q_link) r++; - tvhtrace("epggrab", "mux stats - all %i pending %i", i, r); + tvhtrace(LS_EPGGRAB, "mux stats - all %i pending %i", i, r); } } @@ -637,7 +637,7 @@ epggrab_ota_start_cb ( void *p ); static void epggrab_ota_next_arm( time_t next ) { - tvhtrace("epggrab", "next ota start event in %li seconds", next - time(NULL)); + tvhtrace(LS_EPGGRAB, "next ota start event in %li seconds", next - time(NULL)); gtimer_arm_absn(&epggrab_ota_start_timer, epggrab_ota_start_cb, NULL, next); dbus_emit_signal_s64("/epggrab/ota", "next", next); } @@ -647,7 +647,7 @@ epggrab_ota_start_cb ( void *p ) { time_t next; - tvhtrace("epggrab", "ota start callback"); + tvhtrace(LS_EPGGRAB, "ota start callback"); epggrab_ota_pending_flag = 1; @@ -657,7 +657,7 @@ epggrab_ota_start_cb ( void *p ) if (!cron_multi_next(epggrab_ota_cron_multi, gclk(), &next)) epggrab_ota_next_arm(next); else - tvhwarn("epggrab", "ota cron config invalid or unset"); + tvhwarn(LS_EPGGRAB, "ota cron config invalid or unset"); pthread_mutex_unlock(&epggrab_ota_mutex); } @@ -674,7 +674,7 @@ epggrab_ota_arm ( time_t last ) next = last + 1800; epggrab_ota_next_arm(next); } else { - tvhwarn("epggrab", "ota cron config invalid or unset"); + tvhwarn(LS_EPGGRAB, "ota cron config invalid or unset"); } pthread_mutex_unlock(&epggrab_ota_mutex); @@ -700,9 +700,9 @@ epggrab_ota_service_trace ( epggrab_ota_mux_t *ota, svc = mpegts_service_find_by_uuid(svcl->uuid); if (mm && svc) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("epggrab", "ota %s %s service %s", buf, op, svc->s_nicename); + tvhtrace(LS_EPGGRAB, "ota %s %s service %s", buf, op, svc->s_nicename); } else if (tvheadend_is_running()) - tvhtrace("epggrab", "ota %s, problem? (%p %p)", op, mm, svc); + tvhtrace(LS_EPGGRAB, "ota %s, problem? (%p %p)", op, mm, svc); } void @@ -792,7 +792,7 @@ epggrab_ota_load_one if (tvhtrace_enabled()) { char name[256]; mpegts_mux_nice_name(mm, name, sizeof(name)); - tvhtrace("epggrab", "loading config for %s", name); + tvhtrace(LS_EPGGRAB, "loading config for %s", name); } ota = calloc(1, sizeof(epggrab_ota_mux_t)); diff --git a/src/epggrab/private.h b/src/epggrab/private.h index 8e6290e04..b56f7bb91 100644 --- a/src/epggrab/private.h +++ b/src/epggrab/private.h @@ -27,7 +27,7 @@ struct mpegts_mux; epggrab_module_t *epggrab_module_create ( epggrab_module_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority ); char *epggrab_module_grab_spawn ( void *m ); @@ -75,7 +75,7 @@ void epggrab_channel_done(void); epggrab_module_int_t *epggrab_module_int_create ( epggrab_module_int_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, const char *path, char* (*grab) (void*m), @@ -88,7 +88,7 @@ epggrab_module_int_t *epggrab_module_int_create epggrab_module_ext_t *epggrab_module_ext_create ( epggrab_module_ext_t *skel, const idclass_t *cls, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, const char *sockid, int (*parse) (void *m, htsmsg_t *data, epggrab_stats_t *sta), @@ -108,7 +108,7 @@ typedef struct epggrab_ota_module_ops { epggrab_module_ota_t *epggrab_module_ota_create ( epggrab_module_ota_t *skel, - const char *id, const char *saveid, + const char *id, int subsys, const char *saveid, const char *name, int priority, epggrab_ota_module_ops_t *ops ); diff --git a/src/esfilter.c b/src/esfilter.c index 1c9cb9d68..a974bc6fb 100644 --- a/src/esfilter.c +++ b/src/esfilter.c @@ -158,12 +158,12 @@ esfilter_create } } if (!c) { - tvherror("esfilter", "wrong class %d!", cls); + tvherror(LS_ESFILTER, "wrong class %d!", cls); abort(); } if (idnode_insert(&esf->esf_id, uuid, c, 0)) { if (uuid) - tvherror("esfilter", "invalid uuid '%s'", uuid); + tvherror(LS_ESFILTER, "invalid uuid '%s'", uuid); free(esf); return NULL; } @@ -172,7 +172,7 @@ esfilter_create if (ESF_CLASS_IS_VALID(cls)) esf->esf_class = cls; else if (!ESF_CLASS_IS_VALID(esf->esf_class)) { - tvherror("esfilter", "wrong class %d!", esf->esf_class); + tvherror(LS_ESFILTER, "wrong class %d!", esf->esf_class); abort(); } if (esf->esf_index) { diff --git a/src/fsmonitor.c b/src/fsmonitor.c index bf2f3a6a8..5993b1d83 100644 --- a/src/fsmonitor.c +++ b/src/fsmonitor.c @@ -72,7 +72,7 @@ fsmonitor_thread ( void* p ) i += sizeof(struct inotify_event) + ev->len; if (i > c) break; - tvhtrace("fsmonitor", "event fd %d name %s mask %08X", + tvhtrace(LS_FSMONITOR, "event fd %d name %s mask %08X", ev->wd, ev->len ? ev->name : NULL, ev->mask); /* Find */ @@ -158,14 +158,14 @@ fsmonitor_add ( const char *path, fsmonitor_t *fsm ) if (fmp->fmp_fd <= 0) { RB_REMOVE(&fsmonitor_paths, fmp, fmp_link); free(fmp); - tvhdebug("fsmonitor", "failed to add %s (exists?)", path); + tvhdebug(LS_FSMONITOR, "failed to add %s (exists?)", path); printf("ERROR: failed to add %s\n", path); return -1; } /* Setup */ fmp->fmp_path = strdup(path); - tvhdebug("fsmonitor", "watch %s", fmp->fmp_path); + tvhdebug(LS_FSMONITOR, "watch %s", fmp->fmp_path); } else { free(skel); } @@ -218,7 +218,7 @@ fsmonitor_del ( const char *path, fsmonitor_t *fsm ) /* Remove path */ if (LIST_EMPTY(&fmp->fmp_monitors)) { - tvhdebug("fsmonitor", "unwatch %s", fmp->fmp_path); + tvhdebug(LS_FSMONITOR, "unwatch %s", fmp->fmp_path); RB_REMOVE(&fsmonitor_paths, fmp, fmp_link); fd = atomic_get(&fsmonitor_fd); if (fd >= 0) diff --git a/src/htsp_server.c b/src/htsp_server.c index badd22292..8cec35c15 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -239,7 +239,7 @@ typedef struct htsp_file { * *************************************************************************/ static void -htsp_trace(htsp_connection_t *htsp, const char *subsystem, +htsp_trace(htsp_connection_t *htsp, int subsystem, const char *prefix, htsmsg_t *m) { htsbuf_queue_t q; @@ -432,7 +432,7 @@ htsp_send_subscription(htsp_connection_t *htsp, htsmsg_t *m, pktbuf_t *pb, tvh_strlcatf(buf, sizeof(buf), l, "subscription %i", hs->hs_sid); if (payloadsize) tvh_strlcatf(buf, sizeof(buf), l, " (payload %d)", payloadsize); - htsp_trace(htsp, "htsp-sub", buf, m); + htsp_trace(htsp, LS_HTSP_SUB, buf, m); } htsp_send(htsp, m, pb, &hs->hs_q, payloadsize); @@ -448,7 +448,7 @@ htsp_send_message(htsp_connection_t *htsp, htsmsg_t *m, htsp_msg_q_t *hmq) const char *qname = "answer"; if (hmq == &htsp->htsp_hmq_qstatus) qname = "status"; - htsp_trace(htsp, "htsp-ans", qname, m); + htsp_trace(htsp, LS_HTSP_ANS, qname, m); } htsp_send(htsp, m, NULL, hmq ?: &htsp->htsp_hmq_ctrl, 0); @@ -543,7 +543,7 @@ htsp_dvr_config_name( htsp_connection_t *htsp, const char *config_name ) } if (!cfg && perm->aa_username) - tvhlog(LOG_INFO, "htsp", "User '%s' has no valid dvr config in ACL, using default...", perm->aa_username); + tvhinfo(LS_HTSP, "User '%s' has no valid dvr config in ACL, using default...", perm->aa_username); return cfg ? idnode_uuid_as_str(&cfg->dvr_id, ubuf) : NULL; } @@ -704,7 +704,7 @@ htsp_file_open(htsp_connection_t *htsp, const char *path, int fd) if (fd <= 0) { fd = tvh_open(path, O_RDONLY, 0); - tvhlog(LOG_DEBUG, "htsp", "Opening file %s -- %s", path, fd < 0 ? strerror(errno) : "OK"); + tvhdebug(LS_HTSP, "Opening file %s -- %s", path, fd < 0 ? strerror(errno) : "OK"); if(fd == -1) return htsp_error(htsp, N_("Unable to open file")); } @@ -749,7 +749,7 @@ htsp_file_find(const htsp_connection_t *htsp, htsmsg_t *in) static void htsp_file_destroy(htsp_file_t *hf) { - tvhlog(LOG_DEBUG, "htsp", "Closed opened file %s", hf->hf_path); + tvhdebug(LS_HTSP, "Closed opened file %s", hf->hf_path); free(hf->hf_path); close(hf->hf_fd); LIST_REMOVE(hf, hf_link); @@ -1246,8 +1246,8 @@ htsp_method_hello(htsp_connection_t *htsp, htsmsg_t *in) tvh_str_update(&htsp->htsp_clientname, htsmsg_get_str(in, "clientname")); - tvhlog(LOG_INFO, "htsp", "%s: Welcomed client software: %s (HTSPv%d)", - htsp->htsp_logname, name, v); + tvhinfo(LS_HTSP, "%s: Welcomed client software: %s (HTSPv%d)", + htsp->htsp_logname, name, v); htsmsg_add_u32(r, "htspversion", HTSP_PROTO_VERSION); htsmsg_add_str(r, "servername", config_get_server_name()); @@ -1663,7 +1663,7 @@ htsp_method_epgQuery(htsp_connection_t *htsp, htsmsg_t *in) eq.duration.comp = EC_RG; eq.duration.val1 = min_duration; eq.duration.val2 = max_duration; - tvhtrace("htsp", "min_duration %d and max_duration %d", min_duration, max_duration); + tvhtrace(LS_HTSP, "min_duration %d and max_duration %d", min_duration, max_duration); /* Check access */ if (ch && !htsp_user_access_channel(htsp, ch)) @@ -2383,9 +2383,9 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in) #if ENABLE_TIMESHIFT if (timeshiftPeriod != 0) { if (timeshiftPeriod == ~0) - tvhlog(LOG_DEBUG, "htsp", "using timeshift buffer (unlimited)"); + tvhdebug(LS_HTSP, "using timeshift buffer (unlimited)"); else - tvhlog(LOG_DEBUG, "htsp", "using timeshift buffer (%u mins)", timeshiftPeriod / 60); + tvhdebug(LS_HTSP, "using timeshift buffer (%u mins)", timeshiftPeriod / 60); } #endif @@ -2393,7 +2393,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in) "htsp", SUBSCRIPTION_PACKET | SUBSCRIPTION_HTSP); profile_chain_init(&hs->hs_prch, pro, ch); if (profile_chain_work(&hs->hs_prch, &hs->hs_input, timeshiftPeriod, 0)) { - tvhlog(LOG_ERR, "htsp", "unable to create profile chain '%s'", profile_get_name(pro)); + tvherror(LS_HTSP, "unable to create profile chain '%s'", profile_get_name(pro)); profile_chain_close(&hs->hs_prch); free(hs); return htsp_error(htsp, N_("Stream setup error")); @@ -2427,7 +2427,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in) */ LIST_INSERT_HEAD(&htsp->htsp_subscriptions, hs, hs_link); - tvhdebug("htsp", "%s - subscribe to %s using profile %s", + tvhdebug(LS_HTSP, "%s - subscribe to %s using profile %s", htsp->htsp_logname, channel_get_name(ch), profile_get_name(pro)); hs->hs_s = subscription_create_from_channel(&hs->hs_prch, NULL, weight, htsp->htsp_logname, @@ -2525,12 +2525,12 @@ htsp_method_skip(htsp_connection_t *htsp, htsmsg_t *in) if(!htsmsg_get_s64(in, "time", &s64)) { skip.type = abs ? SMT_SKIP_ABS_TIME : SMT_SKIP_REL_TIME; skip.time = hs->hs_90khz ? s64 : ts_rescale_inv(s64, 1000000); - tvhtrace("htsp-sub", "skip: %s %"PRId64" (%s)", abs ? "abs" : "rel", + tvhtrace(LS_HTSP_SUB, "skip: %s %"PRId64" (%s)", abs ? "abs" : "rel", skip.time, hs->hs_90khz ? "90kHz" : "1MHz"); } else if (!htsmsg_get_s64(in, "size", &s64)) { skip.type = abs ? SMT_SKIP_ABS_SIZE : SMT_SKIP_REL_SIZE; skip.size = s64; - tvhtrace("htsp-sub", "skip: %s by size %"PRId64, abs ? "abs" : "rel", s64); + tvhtrace(LS_HTSP_SUB, "skip: %s by size %"PRId64, abs ? "abs" : "rel", s64); } else { return htsp_error(htsp, N_("Invalid arguments")); } @@ -2563,7 +2563,7 @@ htsp_method_speed(htsp_connection_t *htsp, htsmsg_t *in) if(hs == NULL) return htsp_error(htsp, N_("Subscription does not exist")); - tvhtrace("htsp-sub", "speed: %d", speed); + tvhtrace(LS_HTSP_SUB, "speed: %d", speed); subscription_set_speed(hs->hs_s, speed); htsp_reply(htsp, in, htsmsg_create_map()); @@ -2592,7 +2592,7 @@ htsp_method_live(htsp_connection_t *htsp, htsmsg_t *in) memset(&skip, 0, sizeof(skip)); skip.type = SMT_SKIP_LIVE; - tvhtrace("htsp-sub", "live"); + tvhtrace(LS_HTSP_SUB, "live"); subscription_set_skip(hs->hs_s, &skip); htsp_reply(htsp, in, htsmsg_create_map()); @@ -2938,7 +2938,7 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m) htsp_verify_callback, &vs); if (rights->aa_rights == 0) { - tvhlog(LOG_INFO, "htsp", "%s: Unauthorized access", htsp->htsp_logname); + tvhinfo(LS_HTSP, "%s: Unauthorized access", htsp->htsp_logname); access_destroy(rights); return 0; } @@ -2948,12 +2948,12 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m) htsp->htsp_granted_access->aa_rights) != htsp->htsp_granted_access->aa_rights; - tvhlog(LOG_INFO, "htsp", "%s: Identified as user '%s'", - htsp->htsp_logname, username); + tvhinfo(LS_HTSP, "%s: Identified as user '%s'", + htsp->htsp_logname, username); tvh_str_update(&htsp->htsp_username, username); htsp_update_logname(htsp); if(privgain) - tvhlog(LOG_INFO, "htsp", "%s: Privileges updated", htsp->htsp_logname); + tvhinfo(LS_HTSP, "%s: Privileges updated", htsp->htsp_logname); access_destroy(htsp->htsp_granted_access); htsp->htsp_granted_access = rights; @@ -2963,8 +2963,8 @@ htsp_authenticate(htsp_connection_t *htsp, htsmsg_t *m) } else { - tvhlog(LOG_INFO, "htsp", "%s: Identified as user '%s' (unverified)", - htsp->htsp_logname, username); + tvhinfo(LS_HTSP, "%s: Identified as user '%s' (unverified)", + htsp->htsp_logname, username); tvh_str_update(&htsp->htsp_username, username); htsp_update_logname(htsp); @@ -3047,8 +3047,8 @@ htsp_read_loop(htsp_connection_t *htsp) void *tcp_id = NULL;; if(htsp_generate_challenge(htsp)) { - tvhlog(LOG_ERR, "htsp", "%s: Unable to generate challenge", - htsp->htsp_logname); + tvherror(LS_HTSP, "%s: Unable to generate challenge", + htsp->htsp_logname); return 1; } @@ -3066,7 +3066,7 @@ htsp_read_loop(htsp_connection_t *htsp) if (tcp_id == NULL) return 0; - tvhlog(LOG_INFO, "htsp", "Got connection from %s", htsp->htsp_logname); + tvhinfo(LS_HTSP, "Got connection from %s", htsp->htsp_logname); /* Session main loop */ @@ -3090,9 +3090,9 @@ readmsg: } if((method = htsmsg_get_str(m, "method")) != NULL) { - tvhtrace("htsp", "%s - method %s", htsp->htsp_logname, method); + tvhtrace(LS_HTSP, "%s - method %s", htsp->htsp_logname, method); if (tvhtrace_enabled()) - htsp_trace(htsp, "htsp-req", "request", m); + htsp_trace(htsp, LS_HTSP_REQ, "request", m); for(i = 0; i < NUM_METHODS; i++) { if(!strcmp(method, htsp_methods[i].name)) { @@ -3181,8 +3181,7 @@ htsp_write_scheduler(void *aux) pthread_mutex_unlock(&htsp->htsp_out_mutex); if (htsmsg_binary_serialize(hm->hm_msg, &dptr, &dlen, INT32_MAX) != 0) { - tvhlog(LOG_WARNING, "htsp", "%s: failed to serialize data", - htsp->htsp_logname); + tvhwarn(LS_HTSP, "%s: failed to serialize data", htsp->htsp_logname); htsp_msg_destroy(hm); pthread_mutex_lock(&htsp->htsp_out_mutex); continue; @@ -3195,8 +3194,8 @@ htsp_write_scheduler(void *aux) pthread_mutex_lock(&htsp->htsp_out_mutex); if (r) { - tvhlog(LOG_INFO, "htsp", "%s: Write error -- %s", - htsp->htsp_logname, strerror(errno)); + tvhinfo(LS_HTSP, "%s: Write error -- %s", + htsp->htsp_logname, strerror(errno)); break; } } @@ -3250,7 +3249,7 @@ htsp_serve(int fd, void **opaque, struct sockaddr_storage *source, htsp_read_loop(&htsp); - tvhlog(LOG_INFO, "htsp", "%s: Disconnected", htsp.htsp_logname); + tvhinfo(LS_HTSP, "%s: Disconnected", htsp.htsp_logname); /** * Ok, we're back, other end disconnected. Clean up stuff. @@ -3336,9 +3335,9 @@ htsp_init(const char *bindaddr) .stop = NULL, .cancel = htsp_server_cancel }; - htsp_server = tcp_server_create("htsp", "HTSP", bindaddr, tvheadend_htsp_port, &ops, NULL); + htsp_server = tcp_server_create(LS_HTSP, "HTSP", bindaddr, tvheadend_htsp_port, &ops, NULL); if(tvheadend_htsp_port_extra) - htsp_server_2 = tcp_server_create("htsp", "HTSP2", bindaddr, tvheadend_htsp_port_extra, &ops, NULL); + htsp_server_2 = tcp_server_create(LS_HTSP, "HTSP2", bindaddr, tvheadend_htsp_port_extra, &ops, NULL); } /* @@ -3884,7 +3883,7 @@ htsp_subscription_start(htsp_subscription_t *hs, const streaming_start_t *ss) int i; const source_info_t *si; - tvhdebug("htsp", "%s - subscription start", hs->hs_htsp->htsp_logname); + tvhdebug(LS_HTSP, "%s - subscription start", hs->hs_htsp->htsp_logname); for(i = 0; i < ss->ss_num_components; i++) { const streaming_start_component_t *ssc = &ss->ss_components[i]; @@ -3992,7 +3991,7 @@ htsp_subscription_stop(htsp_subscription_t *hs, const char *err, const char *sub htsmsg_t *m = htsmsg_create_map(); htsmsg_add_str(m, "method", "subscriptionStop"); htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); - tvhdebug("htsp", "%s - subscription stop", hs->hs_htsp->htsp_logname); + tvhdebug(LS_HTSP, "%s - subscription stop", hs->hs_htsp->htsp_logname); if(err != NULL) htsmsg_add_str(m, "status", err); @@ -4013,7 +4012,7 @@ htsp_subscription_grace(htsp_subscription_t *hs, int grace) htsmsg_add_str(m, "method", "subscriptionGrace"); htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); htsmsg_add_u32(m, "graceTimeout", grace); - tvhdebug("htsp", "%s - subscription grace %i seconds", hs->hs_htsp->htsp_logname, grace); + tvhdebug(LS_HTSP, "%s - subscription grace %i seconds", hs->hs_htsp->htsp_logname, grace); htsp_send_subscription(hs->hs_htsp, m, NULL, hs, 0); } @@ -4149,7 +4148,7 @@ static void htsp_subscription_speed(htsp_subscription_t *hs, int speed) { htsmsg_t *m = htsmsg_create_map(); - tvhdebug("htsp", "%s - subscription speed", hs->hs_htsp->htsp_logname); + tvhdebug(LS_HTSP, "%s - subscription speed", hs->hs_htsp->htsp_logname); htsmsg_add_str(m, "method", "subscriptionSpeed"); htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); htsmsg_add_s32(m, "speed", speed); @@ -4183,7 +4182,7 @@ static void htsp_subscription_skip(htsp_subscription_t *hs, streaming_skip_t *skip) { htsmsg_t *m = htsmsg_create_map(); - tvhdebug("htsp", "%s - subscription skip", hs->hs_htsp->htsp_logname); + tvhdebug(LS_HTSP, "%s - subscription skip", hs->hs_htsp->htsp_logname); htsmsg_add_str(m, "method", "subscriptionSkip"); htsmsg_add_u32(m, "subscriptionId", hs->hs_sid); @@ -4219,7 +4218,7 @@ htsp_streaming_input(void *opaque, streaming_message_t *sm) if (hs->hs_wait_for_video) break; if (!hs->hs_first) - tvhdebug("htsp", "%s - first packet", hs->hs_htsp->htsp_logname); + tvhdebug(LS_HTSP, "%s - first packet", hs->hs_htsp->htsp_logname); hs->hs_first = 1; htsp_stream_deliver(hs, sm->sm_data); // reference is transfered diff --git a/src/http.c b/src/http.c index 37dcc8112..81a47e5d2 100644 --- a/src/http.c +++ b/src/http.c @@ -562,7 +562,7 @@ http_error(http_connection_t *hc, int error) level = LOG_DEBUG; else if (error == HTTP_STATUS_BAD_REQUEST || error > HTTP_STATUS_UNAUTHORIZED) level = LOG_ERR; - tvhlog(level, "http", "%s: %s %s %s -- %d", + tvhlog(level, LS_HTTP, "%s: %s %s %s -- %d", hc->hc_peer_ipstr, http_ver2str(hc->hc_version), http_cmd2str(hc->hc_cmd), hc->hc_url, error); } @@ -718,8 +718,8 @@ http_access_verify_ticket(http_connection_t *hc) hc->hc_access = access_ticket_verify2(ticket_id, hc->hc_url); if (hc->hc_access == NULL) return; - tvhlog(LOG_INFO, "http", "%s: using ticket %s for %s", - hc->hc_peer_ipstr, ticket_id, hc->hc_url); + tvhinfo(LS_HTTP, "%s: using ticket %s for %s", + hc->hc_peer_ipstr, ticket_id, hc->hc_url); } /** @@ -957,7 +957,7 @@ dump_request(http_connection_t *hc) if (!first) tvh_strlcatf(buf, sizeof(buf), ptr, "}}"); - tvhtrace("http", "%s %s %s%s", http_ver2str(hc->hc_version), + tvhtrace(LS_HTTP, "%s %s %s%s", http_ver2str(hc->hc_version), http_cmd2str(hc->hc_cmd), hc->hc_url, buf); } @@ -1554,7 +1554,7 @@ http_server_init(const char *bindaddr) .cancel = http_cancel }; RB_INIT(&http_nonces); - http_server = tcp_server_create("http", "HTTP", bindaddr, tvheadend_webui_port, &ops, NULL); + http_server = tcp_server_create(LS_HTTP, "HTTP", bindaddr, tvheadend_webui_port, &ops, NULL); atomic_set(&http_server_running, 1); } diff --git a/src/httpc.c b/src/httpc.c index de5ea527e..0c9bbcdde 100644 --- a/src/httpc.c +++ b/src/httpc.c @@ -112,7 +112,7 @@ http_port( http_client_t *hc, const char *scheme, int port ) else if (scheme && strcmp(scheme, "rtsp") == 0) port = 554; else { - tvhlog(LOG_ERR, "httpc", "%04X: Unknown scheme '%s'", shortid(hc), scheme ? scheme : ""); + tvherror(LS_HTTPC, "%04X: Unknown scheme '%s'", shortid(hc), scheme ? scheme : ""); return -EINVAL; } } @@ -227,7 +227,7 @@ static int http_client_flush( http_client_t *hc, int result ) { hc->hc_result = result; - tvhtrace("httpc", "%04X: client flush %i", shortid(hc), result); + tvhtrace(LS_HTTPC, "%04X: client flush %i", shortid(hc), result); if (result < 0) http_client_shutdown(hc, 0, 0); hc->hc_in_data = 0; @@ -422,7 +422,7 @@ http_client_ssl_send( http_client_t *hc, const void *buf, size_t len ) if (hc->hc_verify_peer > 0) { if (SSL_get_peer_certificate(ssl->ssl) == NULL || SSL_get_verify_result(ssl->ssl) != X509_V_OK) { - tvhlog(LOG_ERR, "httpc", "%04X: SSL peer verification failed (%s:%i)%s %li", + tvherror(LS_HTTPC, "%04X: SSL peer verification failed (%s:%i)%s %li", shortid(hc), hc->hc_host, hc->hc_port, SSL_get_peer_certificate(ssl->ssl) ? " X509" : "", SSL_get_verify_result(ssl->ssl)); @@ -638,8 +638,8 @@ error: htsbuf_read(&q, body, body_size); if (tvhtrace_enabled()) { - tvhtrace("httpc", "%04X: sending %s cmd", shortid(hc), http_ver2str(hc->hc_version)); - tvhlog_hexdump("httpc", body, body_size); + tvhtrace(LS_HTTPC, "%04X: sending %s cmd", shortid(hc), http_ver2str(hc->hc_version)); + tvhlog_hexdump(LS_HTTPC, body, body_size); } wcmd->wbuf = body; @@ -662,8 +662,8 @@ http_client_finish( http_client_t *hc ) int res; if (hc->hc_data && tvhtrace_enabled()) { - tvhtrace("httpc", "%04X: received %s data", shortid(hc), http_ver2str(hc->hc_version)); - tvhlog_hexdump("httpc", hc->hc_data, hc->hc_csize); + tvhtrace(LS_HTTPC, "%04X: received %s data", shortid(hc), http_ver2str(hc->hc_version)); + tvhlog_hexdump(LS_HTTPC, hc->hc_data, hc->hc_csize); } if (hc->hc_in_rtp_data && hc->hc_rtp_data_complete) { pthread_mutex_unlock(&hc->hc_mutex); @@ -964,8 +964,8 @@ retry: return http_client_flush(hc, -errno); } if (r > 0 && tvhtrace_enabled()) { - tvhtrace("httpc", "%04X: received %s answer (len = %zd)", shortid(hc), http_ver2str(hc->hc_version), r); - tvhlog_hexdump("httpc", buf, MIN(64, r)); + tvhtrace(LS_HTTPC, "%04X: received %s answer (len = %zd)", shortid(hc), http_ver2str(hc->hc_version), r); + tvhlog_hexdump(LS_HTTPC, buf, MIN(64, r)); } if (hc->hc_in_data && !hc->hc_in_rtp_data) { @@ -1011,9 +1011,9 @@ header: p = strtok_r(hc->hc_rbuf, "\r\n", &saveptr); if (p == NULL) return http_client_flush(hc, -EINVAL); - tvhtrace("httpc", "%04X: %s answer '%s' (rcseq: %d)", + tvhtrace(LS_HTTPC, "%04X: %s answer '%s' (rcseq: %d)", shortid(hc), http_ver2str(hc->hc_version), p, hc->hc_rcseq); - tvhlog_hexdump("httpc", hc->hc_rbuf, hc->hc_hsize); + tvhlog_hexdump(LS_HTTPC, hc->hc_rbuf, hc->hc_hsize); if (http_tokenize(p, argv, 3, -1) != 3) return http_client_flush(hc, -EINVAL); if ((ver = http_str2ver(argv[0])) < 0) @@ -1243,7 +1243,7 @@ http_client_simple_reconnect ( http_client_t *hc, const url_t *u, if (u->scheme == NULL || u->scheme[0] == '\0' || u->host == NULL || u->host[0] == '\0' || u->port < 0) { - tvherror("httpc", "Invalid url '%s'", u->raw); + tvherror(LS_HTTPC, "Invalid url '%s'", u->raw); return -EINVAL; } if (strcmp(u->scheme, hc->hc_scheme) || @@ -1304,7 +1304,7 @@ http_client_redirected ( http_client_t *hc ) urlinit(&u); if (urlparse(location2 ? location2 : location, &u)) { - tvherror("httpc", "%04X: redirection - cannot parse url '%s'", + tvherror(LS_HTTPC, "%04X: redirection - cannot parse url '%s'", shortid(hc), location2 ? location2 : location); free(location); return -EIO; @@ -1345,14 +1345,14 @@ http_client_ssl_peer_verify( http_client_t *hc, int verify ) hc->hc_verify_peer = verify ? 1 : 0; if ((ssl = hc->hc_ssl) != NULL) { if (!SSL_CTX_set_default_verify_paths(ssl->ctx)) - tvherror("httpc", "%04X: SSL - unable to load CA certificates for verification", shortid(hc)); + tvherror(LS_HTTPC, "%04X: SSL - unable to load CA certificates for verification", shortid(hc)); SSL_CTX_set_verify_depth(ssl->ctx, 1); SSL_CTX_set_verify(ssl->ctx, hc->hc_verify_peer ? SSL_VERIFY_PEER : SSL_VERIFY_NONE, NULL); } } else { - tvherror("httpc", "%04X: SSL peer verification method must be set only once", shortid(hc)); + tvherror(LS_HTTPC, "%04X: SSL peer verification method must be set only once", shortid(hc)); } } @@ -1371,7 +1371,7 @@ http_client_thread ( void *p ) n = tvhpoll_wait(http_poll, &ev, 1, -1); if (n < 0) { if (atomic_get(&http_running) && !ERRNO_AGAIN(errno)) - tvherror("httpc", "tvhpoll_wait() error"); + tvherror(LS_HTTPC, "tvhpoll_wait() error"); } else if (n > 0) { if (&http_pipe == ev.data.ptr) { if (read(http_pipe.rd, &c, 1) == 1) { @@ -1450,37 +1450,37 @@ http_client_reconnect hc->hc_port = port; hc->hc_fd = tcp_connect(host, port, hc->hc_bindaddr, errbuf, sizeof(errbuf), -1); if (hc->hc_fd < 0) { - tvhlog(LOG_ERR, "httpc", "%04X: Unable to connect to %s:%i - %s", shortid(hc), host, port, errbuf); + tvherror(LS_HTTPC, "%04X: Unable to connect to %s:%i - %s", shortid(hc), host, port, errbuf); goto errnval; } hc->hc_einprogress = 1; - tvhtrace("httpc", "%04X: Connected to %s:%i", shortid(hc), host, port); + tvhtrace(LS_HTTPC, "%04X: Connected to %s:%i", shortid(hc), host, port); http_client_ssl_free(hc); if (strcasecmp(scheme, "https") == 0 || strcasecmp(scheme, "rtsps") == 0) { ssl = calloc(1, sizeof(*ssl)); hc->hc_ssl = ssl; ssl->ctx = SSL_CTX_new(SSLv23_client_method()); if (ssl->ctx == NULL) { - tvhlog(LOG_ERR, "httpc", "%04X: Unable to get SSL_CTX", shortid(hc)); + tvherror(LS_HTTPC, "%04X: Unable to get SSL_CTX", shortid(hc)); goto err1; } /* do not use SSLv2 */ SSL_CTX_set_options(ssl->ctx, SSL_OP_NO_SSLv2 | SSL_OP_NO_COMPRESSION); /* adjust cipher list */ if (SSL_CTX_set_cipher_list(ssl->ctx, "HIGH:MEDIUM") != 1) { - tvhlog(LOG_ERR, "httpc", "%04X: Unable to adjust SSL cipher list", shortid(hc)); + tvherror(LS_HTTPC, "%04X: Unable to adjust SSL cipher list", shortid(hc)); goto err2; } ssl->rbio = BIO_new(BIO_s_mem()); ssl->wbio = BIO_new(BIO_s_mem()); ssl->ssl = SSL_new(ssl->ctx); if (ssl->ssl == NULL || ssl->rbio == NULL || ssl->wbio == NULL) { - tvhlog(LOG_ERR, "httpc", "%04X: Unable to get SSL handle", shortid(hc)); + tvherror(LS_HTTPC, "%04X: Unable to get SSL handle", shortid(hc)); goto err3; } SSL_set_bio(ssl->ssl, ssl->rbio, ssl->wbio); if (!SSL_set_tlsext_host_name(ssl->ssl, host)) { - tvhlog(LOG_ERR, "httpc", "%04X: Unable to set SSL hostname", shortid(hc)); + tvherror(LS_HTTPC, "%04X: Unable to set SSL hostname", shortid(hc)); goto err4; } } @@ -1589,7 +1589,7 @@ http_client_close ( http_client_t *hc ) pthread_mutex_lock(&hc->hc_mutex); http_client_shutdown(hc, 1, 0); http_client_flush(hc, 0); - tvhtrace("httpc", "%04X: Closed", shortid(hc)); + tvhtrace(LS_HTTPC, "%04X: Closed", shortid(hc)); while ((wcmd = TAILQ_FIRST(&hc->hc_wqueue)) != NULL) http_client_cmd_destroy(hc, wcmd); http_client_ssl_free(hc); @@ -1889,7 +1889,7 @@ http_client_testsuite_run( void ) path = TVHEADEND_DATADIR "/support/httpc-test.txt"; fp = tvh_fopen(path, "r"); if (fp == NULL) { - tvhlog(LOG_NOTICE, "httpc", "Test: unable to open '%s': %s", path, strerror(errno)); + tvhnotice(LS_HTTPC, "Test: unable to open '%s': %s", path, strerror(errno)); return; } urlinit(&u1); diff --git a/src/idnode.c b/src/idnode.c index 0ab797753..7ddfaf1f0 100644 --- a/src/idnode.c +++ b/src/idnode.c @@ -128,18 +128,18 @@ idnode_insert(idnode_t *in, const char *uuid, const idclass_t *class, int flags) } while (c != NULL && --retries > 0); if(c != NULL) { - tvherror("idnode", "Id node collission (%s) %s", + tvherror(LS_IDNODE, "Id node collission (%s) %s", uuid, (flags & IDNODE_SHORT_UUID) ? " (short)" : ""); fprintf(stderr, "Id node collision (%s) %s\n", uuid, (flags & IDNODE_SHORT_UUID) ? " (short)" : ""); abort(); } - tvhtrace("idnode", "insert node %s", idnode_uuid_as_str(in, ubuf)); + tvhtrace(LS_IDNODE, "insert node %s", idnode_uuid_as_str(in, ubuf)); /* Register the class */ in->in_domain = idclass_find_domain(class); if (in->in_domain == NULL) { - tvherror("idnode", "classs '%s' is not registered", class->ic_class); + tvherror(LS_IDNODE, "classs '%s' is not registered", class->ic_class); abort(); } c = RB_INSERT_SORTED(in->in_domain, in, in_domain_link, in_cmp); @@ -162,7 +162,7 @@ idnode_unlink(idnode_t *in) lock_assert(&global_lock); RB_REMOVE(&idnodes, in, in_link); RB_REMOVE(in->in_domain, in, in_domain_link); - tvhtrace("idnode", "unlink node %s", idnode_uuid_as_str(in, ubuf)); + tvhtrace(LS_IDNODE, "unlink node %s", idnode_uuid_as_str(in, ubuf)); idnode_notify(in, "delete"); assert(in->in_save == NULL || in->in_save == SAVEPTR_OUTOFSERVICE); } @@ -612,7 +612,7 @@ idnode_find ( const char *uuid, const idclass_t *idc, const idnodes_rb_t *domain { idnode_t skel, *r; - tvhtrace("idnode", "find node %s class %s", uuid, idc ? idc->ic_class : NULL); + tvhtrace(LS_IDNODE, "find node %s class %s", uuid, idc ? idc->ic_class : NULL); if(uuid == NULL || strlen(uuid) != UUID_HEX_SIZE - 1) return NULL; if(hex2bin(skel.in_uuid.bin, sizeof(skel.in_uuid.bin), uuid)) @@ -640,7 +640,7 @@ idnode_find_all ( const idclass_t *idc, const idnodes_rb_t *domain ) idnode_t *in; const idclass_t *ic; char ubuf[UUID_HEX_SIZE]; - tvhtrace("idnode", "find class %s", idc->ic_class); + tvhtrace(LS_IDNODE, "find class %s", idc->ic_class); idnode_set_t *is = calloc(1, sizeof(idnode_set_t)); if (domain == NULL) domain = idnode_domain(idc); @@ -649,7 +649,7 @@ idnode_find_all ( const idclass_t *idc, const idnodes_rb_t *domain ) ic = in->in_class; while (ic) { if (ic == idc) { - tvhtrace("idnode", " add node %s", idnode_uuid_as_str(in, ubuf)); + tvhtrace(LS_IDNODE, " add node %s", idnode_uuid_as_str(in, ubuf)); idnode_set_add(is, in, NULL, NULL); break; } @@ -661,7 +661,7 @@ idnode_find_all ( const idclass_t *idc, const idnodes_rb_t *domain ) ic = in->in_class; while (ic) { if (ic == idc) { - tvhtrace("idnode", " add node %s", idnode_uuid_as_str(in, ubuf)); + tvhtrace(LS_IDNODE, " add node %s", idnode_uuid_as_str(in, ubuf)); idnode_set_add(is, in, NULL, NULL); break; } @@ -1363,7 +1363,7 @@ idclass_root_register(const idclass_t *idc) if (r) return; RB_INIT(&idclasses_skel->nodes); SKEL_USED(idclasses_skel); - tvhtrace("idnode", "register root class %s", idc->ic_class); + tvhtrace(LS_IDNODE, "register root class %s", idc->ic_class); } void @@ -1379,7 +1379,7 @@ idclass_register(const idclass_t *idc) } RB_INIT(&idclasses_skel->nodes); /* not used, but for sure */ SKEL_USED(idclasses_skel); - tvhtrace("idnode", "register class %s", idc->ic_class); + tvhtrace(LS_IDNODE, "register class %s", idc->ic_class); prev = idc; idc = idc->ic_super; } @@ -1394,7 +1394,7 @@ idclass_find ( const char *class ) idclass_t idc; skel.idc = &idc; idc.ic_class = class; - tvhtrace("idnode", "find class %s", class); + tvhtrace(LS_IDNODE, "find class %s", class); t = RB_FIND(&idclasses, &skel, link, ic_cmp); return t ? t->idc : NULL; } diff --git a/src/imagecache.c b/src/imagecache.c index 17156bf44..25f0b51aa 100644 --- a/src/imagecache.c +++ b/src/imagecache.c @@ -240,7 +240,7 @@ imagecache_new_contents ( imagecache_image_t *img, } if (!r) { if (rename(tpath, path)) - tvherror("imagecache", "unable to rename file '%s' to '%s'", tpath, path); + tvherror(LS_IMAGECACHE, "unable to rename file '%s' to '%s'", tpath, path); } imagecache_image_save(img); pthread_mutex_unlock(&global_lock); @@ -276,10 +276,10 @@ imagecache_image_fetch ( imagecache_image_t *img ) pthread_mutex_unlock(&global_lock); /* Build command */ - tvhdebug("imagecache", "fetch %s", img->url); + tvhdebug(LS_IMAGECACHE, "fetch %s", img->url); memset(&url, 0, sizeof(url)); if (urlparse(img->url, &url)) { - tvherror("imagecache", "Unable to parse url '%s'", img->url); + tvherror(LS_IMAGECACHE, "Unable to parse url '%s'", img->url); goto error_lock; } @@ -329,9 +329,9 @@ error: img->failed = 1; imagecache_image_save(img); } - tvhwarn("imagecache", "failed to download %s", img->url); + tvhwarn(LS_IMAGECACHE, "failed to download %s", img->url); } else { - tvhdebug("imagecache", "downloaded %s", img->url); + tvhdebug(LS_IMAGECACHE, "downloaded %s", img->url); } tvh_cond_signal(&imagecache_cond, 1); @@ -546,10 +546,10 @@ imagecache_clean( void ) } #endif - tvhinfo("imagecache", "clean request"); + tvhinfo(LS_IMAGECACHE, "clean request"); /* remove unassociated data */ if (hts_settings_buildpath(path, sizeof(path), "imagecache/data")) { - tvherror("imagecache", "clean - buildpath"); + tvherror(LS_IMAGECACHE, "clean - buildpath"); return; } if((n = fb_scandir(path, &namelist)) < 0) @@ -562,7 +562,7 @@ imagecache_clean( void ) img = RB_FIND(&imagecache_by_id, &skel, id_link, id_cmp); if (img) continue; - tvhinfo("imagecache", "clean: removing unassociated file '%s/%s'", path, name); + tvhinfo(LS_IMAGECACHE, "clean: removing unassociated file '%s/%s'", path, name); hts_settings_remove("imagecache/meta/%s", name); hts_settings_remove("imagecache/data/%s", name); } @@ -581,7 +581,7 @@ imagecache_trigger( void ) lock_assert(&global_lock); - tvhinfo("imagecache", "load triggered"); + tvhinfo(LS_IMAGECACHE, "load triggered"); RB_FOREACH(img, &imagecache_by_url, url_link) { if (img->state != IDLE) continue; imagecache_image_add(img); diff --git a/src/input/mpegts.c b/src/input/mpegts.c index 72265cde5..e02d491f1 100644 --- a/src/input/mpegts.c +++ b/src/input/mpegts.c @@ -91,25 +91,25 @@ mpegts_init ( int linuxdvb_mask, int nosatip, str_list_t *satip_client, void mpegts_done ( void ) { - tvhftrace("main", mpegts_network_scan_done); - tvhftrace("main", mpegts_mux_sched_done); + tvhftrace(LS_MAIN, mpegts_network_scan_done); + tvhftrace(LS_MAIN, mpegts_mux_sched_done); #if ENABLE_MPEGTS_DVB - tvhftrace("main", dvb_network_done); + tvhftrace(LS_MAIN, dvb_network_done); #endif #if ENABLE_IPTV - tvhftrace("main", iptv_done); + tvhftrace(LS_MAIN, iptv_done); #endif #if ENABLE_LINUXDVB - tvhftrace("main", linuxdvb_done); + tvhftrace(LS_MAIN, linuxdvb_done); #endif #if ENABLE_SATIP_CLIENT - tvhftrace("main", satip_done); + tvhftrace(LS_MAIN, satip_done); #endif #if ENABLE_HDHOMERUN_CLIENT - tvhftrace("main", tvhdhomerun_done); + tvhftrace(LS_MAIN, tvhdhomerun_done); #endif #if ENABLE_TSFILE - tvhftrace("main", tsfile_done); + tvhftrace(LS_MAIN, tsfile_done); #endif dvb_fastscan_done(); } diff --git a/src/input/mpegts.h b/src/input/mpegts.h index 7f512e97e..f958131a7 100644 --- a/src/input/mpegts.h +++ b/src/input/mpegts.h @@ -1034,7 +1034,7 @@ int mpegts_table_type mpegts_table_t *mpegts_table_add (mpegts_mux_t *mm, int tableid, int mask, mpegts_table_callback_t callback, void *opaque, - const char *name, int flags, int pid, int weight); + const char *name, int subsys, int flags, int pid, int weight); void mpegts_table_flush_all (mpegts_mux_t *mm); void mpegts_table_destroy ( mpegts_table_t *mt ); diff --git a/src/input/mpegts/dvb.h b/src/input/mpegts/dvb.h index d0ccb4b5c..a4217dba1 100644 --- a/src/input/mpegts/dvb.h +++ b/src/input/mpegts/dvb.h @@ -222,34 +222,34 @@ void atsc_utf16_to_utf8(const uint8_t *src, int len, char *buf, int buflen); * PSI processing */ -#define DVB_LOOP_INIT(ptr, len, off, lptr, llen)\ +#define DVB_LOOP_INIT(mt, ptr, len, off, lptr, llen)\ do {\ llen = ((ptr[off] & 0xF) << 8) | ptr[off+1];\ lptr = 2 + off + ptr;\ ptr += 2 + off + llen;\ len -= 2 + off + llen;\ - if (len < 0) {tvhtrace("psi", "len < 0"); return -1; }\ + if (len < 0) {tvhtrace(mt->mt_subsys, "%s: len < 0", mt->mt_name); return -1; }\ } while(0) #define DVB_LOOP_EACH(ptr, len, min)\ for ( ; len > min ; )\ -#define DVB_LOOP_FOREACH(ptr, len, off, lptr, llen, min)\ - DVB_LOOP_INIT(ptr, len, off, lptr, llen);\ +#define DVB_LOOP_FOREACH(mt, ptr, len, off, lptr, llen, min)\ + DVB_LOOP_INIT(mt, ptr, len, off, lptr, llen);\ DVB_LOOP_EACH(lptr, llen, min) -#define DVB_DESC_EACH(ptr, len, dtag, dlen, dptr)\ +#define DVB_DESC_EACH(mt, ptr, len, dtag, dlen, dptr)\ DVB_LOOP_EACH(ptr, len, 2)\ - if (!(dtag = ptr[0])) {tvhtrace("psi", "1");return -1;}\ - else if ((dlen = ptr[1]) < 0) {tvhtrace("psi", "2");return -1;}\ - else if (!(dptr = ptr+2)) {tvhtrace("psi", "3");return -1;}\ - else if ( (len -= 2 + dlen) < 0) {tvhtrace("psi", "4");return -1;}\ - else if (!(ptr += 2 + dlen)) {tvhtrace("psi", "5");return -1;}\ + if (!(dtag = ptr[0])) {tvhtrace(mt->mt_subsys, "%s: 1", mt->mt_name);return -1;}\ + else if ((dlen = ptr[1]) < 0) {tvhtrace(mt->mt_subsys, "%s: 2", mt->mt_name);return -1;}\ + else if (!(dptr = ptr+2)) {tvhtrace(mt->mt_subsys, "%s: 3", mt->mt_name);return -1;}\ + else if ( (len -= 2 + dlen) < 0) {tvhtrace(mt->mt_subsys, "%s: 4", mt->mt_name);return -1;}\ + else if (!(ptr += 2 + dlen)) {tvhtrace(mt->mt_subsys, "%s: 5", mt->mt_name);return -1;}\ else -#define DVB_DESC_FOREACH(ptr, len, off, lptr, llen, dtag, dlen, dptr)\ - DVB_LOOP_INIT(ptr, len, off, lptr, llen);\ - DVB_DESC_EACH(lptr, llen, dtag, dlen, dptr)\ +#define DVB_DESC_FOREACH(mt, ptr, len, off, lptr, llen, dtag, dlen, dptr)\ + DVB_LOOP_INIT(mt, ptr, len, off, lptr, llen);\ + DVB_DESC_EACH(mt, lptr, llen, dtag, dlen, dptr)\ /* * SI typedefs @@ -285,6 +285,7 @@ typedef struct mpegts_psi_table LIST_ENTRY(mpegts_table) mt_link; RB_HEAD(,mpegts_psi_table_state) mt_state; + int mt_subsys; char *mt_name; void *mt_opaque; @@ -327,7 +328,7 @@ typedef void (*mpegts_psi_parse_callback_t) ( mpegts_psi_table_t *, const uint8_t *buf, int len ); void dvb_table_parse_init - ( mpegts_psi_table_t *mt, const char *name, int pid, void *opaque ); + ( mpegts_psi_table_t *mt, const char *name, int subsys, int pid, void *opaque ); void dvb_table_parse_done ( mpegts_psi_table_t *mt); diff --git a/src/input/mpegts/dvb_charset.c b/src/input/mpegts/dvb_charset.c index 3436e2c1e..ff44da15e 100644 --- a/src/input/mpegts/dvb_charset.c +++ b/src/input/mpegts/dvb_charset.c @@ -67,7 +67,7 @@ static void _charset_load_file() }; if (i > 0) - tvhlog(LOG_INFO, "charset", "%d entries loaded", i); + tvhinfo(LS_CHARSET, "%d entries loaded", i); } /* diff --git a/src/input/mpegts/dvb_psi.c b/src/input/mpegts/dvb_psi.c index 0b8f64add..7302e8c1e 100644 --- a/src/input/mpegts/dvb_psi.c +++ b/src/input/mpegts/dvb_psi.c @@ -88,7 +88,7 @@ typedef struct dvb_bat { int dvb_bouquets_parse = 1; static int -psi_parse_pmt(mpegts_mux_t *mux, mpegts_service_t *t, +psi_parse_pmt(mpegts_table_t *mt, mpegts_service_t *t, const uint8_t *ptr, int len, int *_update); static inline int @@ -116,7 +116,7 @@ static void dvb_service_autoenable( mpegts_service_t *s, const char *where ) { if (!s->s_enabled && s->s_auto == SERVICE_AUTO_PAT_MISSING) { - tvhinfo("mpegts", "enabling service %s [sid %04X/%d] (found in %s)", + tvhinfo(LS_MPEGTS, "enabling service %s [sid %04X/%d] (found in %s)", s->s_nicename, s->s_dvb_service_id, s->s_dvb_service_id, where); service_set_enabled((service_t *)s, 1, SERVICE_AUTO_NORMAL); } @@ -169,7 +169,7 @@ dvb_fs_mux_add ( mpegts_table_t *mt, mpegts_mux_t *mm, mpegts_mux_t *mux ) return; } } - tvherror(mt->mt_name, "fastscan mux count overflow"); + tvherror(mt->mt_subsys, "%s: fastscan mux count overflow", mt->mt_name); } #endif @@ -213,11 +213,11 @@ dvb_desc_sat_del bcdtoint(ptr[7]) * 100000 + bcdtoint(ptr[8]) * 1000 + bcdtoint(ptr[9]) * 10 + (ptr[10] >> 4); if (!frequency) { - tvhlog(LOG_WARNING, mt->mt_name, "dvb-s frequency error"); + tvhwarn(mt->mt_subsys, "%s: dvb-s frequency error", mt->mt_name); return NULL; } if (!symrate) { - tvhlog(LOG_WARNING, mt->mt_name, "dvb-s symbol rate error"); + tvhwarn(mt->mt_subsys, "%s: dvb-s symbol rate error", mt->mt_name); return NULL; } @@ -255,13 +255,13 @@ dvb_desc_sat_del dmc.dmc_fe_rolloff = rtab[(ptr[6] >> 3) & 0x3]; if (dmc.dmc_fe_delsys == DVB_SYS_DVBS && dmc.dmc_fe_rolloff != DVB_ROLLOFF_35) { - tvhwarn(mt->mt_name, "dvb-s rolloff error"); + tvhwarn(mt->mt_subsys, "%s: dvb-s rolloff error", mt->mt_name); return NULL; } /* Debug */ dvb_mux_conf_str(&dmc, buf, sizeof(buf)); - tvhdebug(mt->mt_name, " %s", buf); + tvhdebug(mt->mt_subsys, "%s: %s", mt->mt_name, buf); /* Create */ return mm->mm_network->mn_create_mux(mm->mm_network, mm, onid, tsid, &dmc, force); @@ -296,11 +296,11 @@ dvb_desc_cable_del bcdtoint(ptr[7]) * 100000 + bcdtoint(ptr[8]) * 1000 + bcdtoint(ptr[9]) * 10 + (ptr[10] >> 4); if (!frequency) { - tvhwarn(mt->mt_name, "dvb-c frequency error"); + tvhwarn(mt->mt_subsys, "%s: dvb-c frequency error", mt->mt_name); return NULL; } if (!symrate) { - tvhwarn(mt->mt_name, "dvb-c symbol rate error"); + tvhwarn(mt->mt_subsys, "%s: dvb-c symbol rate error", mt->mt_name); return NULL; } @@ -317,7 +317,7 @@ dvb_desc_cable_del /* Debug */ dvb_mux_conf_str(&dmc, buf, sizeof(buf)); - tvhdebug(mt->mt_name, " %s", buf); + tvhdebug(mt->mt_subsys, "%s: %s", mt->mt_name, buf); /* Create */ return mm->mm_network->mn_create_mux(mm->mm_network, mm, onid, tsid, &dmc, 0); @@ -366,7 +366,7 @@ dvb_desc_terr_del /* Extract data */ frequency = ((ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3]); if (frequency < 1000000 || frequency > 200000000) { - tvhdebug(mt->mt_name, "dvb-t frequency error (%d)", frequency); + tvhdebug(mt->mt_subsys, "%s: dvb-t frequency error (%d)", mt->mt_name, frequency); return NULL; } @@ -384,7 +384,7 @@ dvb_desc_terr_del /* Debug */ dvb_mux_conf_str(&dmc, buf, sizeof(buf)); - tvhdebug(mt->mt_name, " %s", buf); + tvhdebug(mt->mt_subsys, "%s: %s", mt->mt_name, buf); /* Create */ return mm->mm_network->mn_create_mux(mm->mm_network, mm, onid, tsid, &dmc, 0); @@ -454,7 +454,7 @@ dvb_bat_find_service( dvb_bat_id_t *bi, mpegts_service_t *s, static int dvb_desc_service_list - ( const char *dstr, const uint8_t *ptr, int len, mpegts_mux_t *mm, + ( mpegts_table_t *mt, const uint8_t *ptr, int len, mpegts_mux_t *mm, dvb_bat_id_t *bi ) { uint16_t stype, sid; @@ -464,7 +464,7 @@ dvb_desc_service_list for (i = 0; i < len; i += 3) { sid = (ptr[i] << 8) | ptr[i+1]; stype = ptr[i+2]; - tvhdebug(dstr, " service %04X (%d) type %02X (%d)", sid, sid, stype, stype); + tvhdebug(mt->mt_subsys, "%s: service %04X (%d) type %02X (%d)", mt->mt_name, sid, sid, stype, stype); if (mm) { int save = 0; s = mpegts_service_find(mm, sid, 0, 1, &save); @@ -479,7 +479,7 @@ dvb_desc_service_list static int dvb_desc_local_channel - ( const char *dstr, const uint8_t *ptr, int len, + ( mpegts_table_t *mt, const uint8_t *ptr, int len, uint8_t dtag, mpegts_mux_t *mm, dvb_bat_id_t *bi, int prefer ) { int save = 0; @@ -492,7 +492,7 @@ dvb_desc_local_channel while(len >= 4) { sid = (ptr[0] << 8) | ptr[1]; lcn = ((ptr[2] & 3) << 8) | ptr[3]; - tvhdebug(dstr, " sid %d lcn %d", sid, lcn); + tvhdebug(mt->mt_subsys, "%s: sid %d lcn %d", mt->mt_name, sid, lcn); if (sid && lcn && mm) { s = mpegts_service_find(mm, sid, 0, 0, &save); if (s) { @@ -522,7 +522,7 @@ dvb_desc_local_channel static void dvb_freesat_local_channels - ( dvb_bat_id_t *bi, const char *dstr, const uint8_t *ptr, int len ) + ( dvb_bat_id_t *bi, mpegts_table_t *mt, const uint8_t *ptr, int len ) { uint16_t sid, lcn, regionid; uint16_t unk; @@ -537,11 +537,11 @@ dvb_freesat_local_channels len -= 5; if (len2 > len) break; - tvhtrace(dstr, " sid %04X (%d) uknown %04X (%d)", sid, sid, unk, unk); + tvhtrace(mt->mt_subsys, "%s: sid %04X (%d) uknown %04X (%d)", mt->mt_name, sid, sid, unk, unk); while (len2 > 3) { lcn = ((ptr[0] & 0x0f) << 8) | ptr[1]; regionid = (ptr[2] << 8) | ptr[3]; - tvhtrace(dstr, " lcn %d region %d", lcn, regionid); + tvhtrace(mt->mt_subsys, "%s: lcn %d region %d", mt->mt_name, lcn, regionid); TAILQ_FOREACH(fs, &bi->fservices, link) if (fs->sid == sid && fs->regionid == regionid) @@ -563,7 +563,7 @@ dvb_freesat_local_channels static void dvb_freesat_regions - ( dvb_bat_id_t *bi, const char *dstr, const uint8_t *ptr, int len ) + ( dvb_bat_id_t *bi, mpegts_table_t *mt, const uint8_t *ptr, int len ) { uint16_t id; char name[32]; @@ -578,7 +578,7 @@ dvb_freesat_regions /* language: ptr[2-4]: 'eng' */ if ((r = dvb_get_string_with_len(name, sizeof(name), ptr + 5, len - 5, NULL, NULL)) < 0) break; - tvhtrace(dstr, " region %u - '%s'", id, name); + tvhtrace(mt->mt_subsys, "%s: region %u - '%s'", mt->mt_name, id, name); LIST_FOREACH(fr, &bi->fregions, link) if (fr->regionid == id) @@ -618,7 +618,7 @@ dvb_freesat_add_service static void dvb_freesat_completed - ( dvb_bat_t *b, dvb_bat_id_t *bi, const char *dstr ) + ( dvb_bat_t *b, dvb_bat_id_t *bi, mpegts_table_t *mt ) { dvb_bat_svc_t *bs; dvb_freesat_svc_t *fs; @@ -626,8 +626,8 @@ dvb_freesat_completed uint16_t sid; uint32_t total = 0, regions = 0, uregions = 0; - tvhtrace(dstr, "completed %s [%04X] bouquets '%s'", - bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name); + tvhtrace(mt->mt_subsys, "%s: completed %s [%04X] bouquets '%s'", + mt->mt_name, bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name); /* Find all "fallback" services and region specific */ TAILQ_FOREACH(bs, &bi->services, link) { @@ -645,7 +645,7 @@ dvb_freesat_completed if (fr->regionid == fs->regionid) break; if (!fr) - tvhtrace(dstr, "cannot find freesat region id %u", fs->regionid); + tvhtrace(mt->mt_subsys, "%s: cannot find freesat region id %u", mt->mt_name, fs->regionid); else TAILQ_INSERT_TAIL(&fr->services, fs, region_link); } @@ -680,8 +680,8 @@ dvb_freesat_completed } } - tvhtrace(dstr, "completed %s [%04X] bouquets '%s' total %u regions %u (%u)", - bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name, + tvhtrace(mt->mt_subsys, "%s: completed %s [%04X] bouquets '%s' total %u regions %u (%u)", + mt->mt_name, bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name, total, regions, uregions); /* Remove all services associated to region, notify the completed status */ @@ -698,8 +698,8 @@ dvb_freesat_completed TAILQ_FOREACH(bs, &bi->services, link) bs->fallback = NULL; - tvhtrace(dstr, "completed %s [%04X] bouquets '%s' update finished", - bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name); + tvhtrace(mt->mt_subsys, "%s: completed %s [%04X] bouquets '%s' update finished", + mt->mt_name, bi->freesat ? "freesat" : "bskyb", bi->nbid, bi->name); } @@ -759,7 +759,7 @@ static struct strtab bskyb_regions[] = { static void dvb_bskyb_local_channels - ( dvb_bat_id_t *bi, const char *dstr, + ( dvb_bat_id_t *bi, mpegts_table_t *mt, const uint8_t *ptr, int len, mpegts_mux_t *mm ) { uint16_t sid, lcn, regionid; @@ -790,8 +790,8 @@ dvb_bskyb_local_channels len -= 2; ptr += 2; - tvhtrace(dstr, " region id %04X (%d) unknown %02X (%d)", - regionid, regionid, ptr[0], ptr[0]); + tvhtrace(mt->mt_subsys, "%s: region id %04X (%d) unknown %02X (%d)", + mt->mt_name, regionid, regionid, ptr[0], ptr[0]); while (len > 8) { sid = (ptr[0] << 8) | ptr[1]; @@ -801,8 +801,8 @@ dvb_bskyb_local_channels ptr += 9; len -= 9; - tvhtrace(dstr, " sid %04X (%d) type %02X (%d) lcn %d unknown %04X (%d)", - sid, sid, stype, stype, lcn, unk, unk); + tvhtrace(mt->mt_subsys, "%s: sid %04X (%d) type %02X (%d) lcn %d unknown %04X (%d)", + mt->mt_name, sid, sid, stype, stype, lcn, unk, unk); TAILQ_FOREACH(fs, &bi->fservices, link) if (fs->sid == sid && fs->regionid == regionid) @@ -876,24 +876,24 @@ dvb_pat_callback if (tsid == 0 && !mm->mm_tsid_accept_zero_value) { if (tvhlog_limit(&mm->mm_tsid_loglimit, 2)) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhwarn("pat", "%s: TSID zero value detected, ignoring", buf); + tvhwarn(mt->mt_subsys, "%s: %s: TSID zero value detected, ignoring", mt->mt_name, buf); } goto end; } /* Multiplex */ - tvhdebug("pat", "%p: tsid %04X (%d)", mm, tsid, tsid); + tvhdebug(mt->mt_subsys, "%s: %p: tsid %04X (%d)", mt->mt_name, mm, tsid, tsid); if (mm->mm_tsid != MPEGTS_TSID_NONE) { if (mm->mm_tsid && mm->mm_tsid != tsid) { if (++mm->mm_tsid_checks > 12) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhwarn("pat", "%s: TSID change detected - old %04x (%d), new %04x (%d)", - buf, mm->mm_tsid, mm->mm_tsid, tsid, tsid); + tvhwarn(mt->mt_subsys, "%s: %s: TSID change detected - old %04x (%d), new %04x (%d)", + mt->mt_name, buf, mm->mm_tsid, mm->mm_tsid, tsid, tsid); } else { if (tvhtrace_enabled()) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("pat", "%s: ignore TSID - old %04x (%d), new %04x (%d) (checks %d)", - buf, mm->mm_tsid, mm->mm_tsid, tsid, tsid, mm->mm_tsid_checks); + tvhtrace(mt->mt_subsys, "%s: %s: ignore TSID - old %04x (%d), new %04x (%d) (checks %d)", + mt->mt_name, buf, mm->mm_tsid, mm->mm_tsid, tsid, tsid, mm->mm_tsid_checks); } return 0; /* keep rolling */ } @@ -913,16 +913,16 @@ dvb_pat_callback if (sid == 0) { if (pid) { nit_pid = pid; - tvhdebug("pat", " nit on pid %04X (%d)", pid, pid); + tvhdebug(mt->mt_subsys, "%s: nit on pid %04X (%d)", mt->mt_name, pid, pid); } /* Service */ } else if (pid) { - tvhdebug("pat", " sid %04X (%d) on pid %04X (%d)", sid, sid, pid, pid); + tvhdebug(mt->mt_subsys, "%s: sid %04X (%d) on pid %04X (%d)", mt->mt_name, sid, sid, pid, pid); int save = 0; if ((s = mpegts_service_find(mm, sid, pid, 1, &save))) { mpegts_table_add(mm, DVB_PMT_BASE, DVB_PMT_MASK, dvb_pmt_callback, - NULL, "pmt", + NULL, "pmt", LS_TBL_BASE, MT_CRC | MT_QUICKREQ | MT_ONESHOT | MT_SCANSUBS, pid, MPS_WEIGHT_PMT_SCAN); @@ -939,7 +939,7 @@ dvb_pat_callback /* Install NIT handler */ if (nit_pid) mpegts_table_add(mm, DVB_NIT_BASE, DVB_NIT_MASK, dvb_nit_callback, - NULL, "nit", MT_QUICKREQ | MT_CRC, nit_pid, + NULL, "nit", LS_TBL_BASE, MT_QUICKREQ | MT_CRC, nit_pid, MPS_WEIGHT_NIT); /* End */ @@ -981,8 +981,8 @@ dvb_cat_callback if (len >= 4 && dlen >= 4) { caid = ( ptr[0] << 8) | ptr[1]; pid = ((ptr[2] & 0x1f) << 8) | ptr[3]; - tvhdebug("cat", " caid %04X (%d) pid %04X (%d)", - (uint16_t)caid, (uint16_t)caid, pid, pid); + tvhdebug(mt->mt_subsys, "%s: caid %04X (%d) pid %04X (%d)", + mt->mt_name, (uint16_t)caid, (uint16_t)caid, pid, pid); } break; default: @@ -1040,10 +1040,10 @@ dvb_pmt_callback if (!s) return -1; /* Process */ - tvhdebug("pmt", "sid %04X (%d)", sid, sid); + tvhdebug(mt->mt_subsys, "%s: sid %04X (%d)", mt->mt_name, sid, sid); update = 0; pthread_mutex_lock(&s->s_stream_mutex); - r = psi_parse_pmt(mt->mt_mux, s, ptr, len, &update); + r = psi_parse_pmt(mt, s, ptr, len, &update); pthread_mutex_unlock(&s->s_stream_mutex); if (r) service_restart((service_t*)s); @@ -1108,7 +1108,7 @@ dvb_bat_destroy( mpegts_table_t *mt ) static void dvb_bat_completed - ( dvb_bat_t *b, const char *dstr, int tableid, int tsid, int nbid, + ( dvb_bat_t *b, mpegts_table_t *mt, int tableid, int tsid, int nbid, mpegts_mux_t *mux, bouquet_t *bq_alt ) { dvb_bat_id_t *bi; @@ -1128,7 +1128,7 @@ dvb_bat_completed if (bi->freesat || bi->bskyb) { #if ENABLE_MPEGTS_DVB - dvb_freesat_completed(b, bi, dstr); + dvb_freesat_completed(b, bi, mt); #endif goto complete; } @@ -1199,11 +1199,11 @@ dvb_nit_mux mpegts_mux_nice_name(mux, buf, sizeof(buf)); else strcpy(buf, ""); - tvhdebug(mt->mt_name, " onid %04X (%d) tsid %04X (%d) mux %s%s", - onid, onid, tsid, tsid, buf, discovery ? " (discovery)" : ""); + tvhdebug(mt->mt_subsys, "%s: onid %04X (%d) tsid %04X (%d) mux %s%s", + mt->mt_name, onid, onid, tsid, tsid, buf, discovery ? " (discovery)" : ""); - DVB_DESC_FOREACH(lptr, llen, 4, dlptr, dllen, dtag, dlen, dptr) { - tvhtrace(mt->mt_name, " dtag %02X dlen %d", dtag, dlen); + DVB_DESC_FOREACH(mt, lptr, llen, 4, dlptr, dllen, dtag, dlen, dptr) { + tvhtrace(mt->mt_subsys, "%s: dtag %02X dlen %d", mt->mt_name, dtag, dlen); #if ENABLE_MPEGTS_DVB /* Limit delivery descriptiors only in the discovery phase */ @@ -1262,7 +1262,7 @@ dvb_nit_mux case DVB_DESC_DEF_AUTHORITY: if (dvb_get_string(dauth, sizeof(dauth), dptr, dlen, charset, NULL)) return -1; - tvhdebug(mt->mt_name, " default auth [%s]", dauth); + tvhdebug(mt->mt_subsys, "%s: default auth [%s]", mt->mt_name, dauth); if (mux && *dauth) mpegts_mux_set_crid_authority(mux, dauth); break; @@ -1273,7 +1273,7 @@ dvb_nit_mux case DVB_DESC_PRIVATE_DATA: if (dlen == 4) { priv = (dptr[0] << 24) | (dptr[1] << 16) | (dptr[2] << 8) | dptr[3]; - tvhtrace(mt->mt_name, " private %08X", priv); + tvhtrace(mt->mt_subsys, "%s: private %08X", mt->mt_name, priv); } break; case 0x81: @@ -1425,8 +1425,8 @@ dvb_nit_callback /* Network Descriptors */ *name = 0; charset = dvb_charset_find(mn, NULL, NULL); - DVB_DESC_FOREACH(ptr, len, 5, lptr, llen, dtag, dlen, dptr) { - tvhtrace(mt->mt_name, " dtag %02X dlen %d", dtag, dlen); + DVB_DESC_FOREACH(mt, ptr, len, 5, lptr, llen, dtag, dlen, dptr) { + tvhtrace(mt->mt_subsys, "%s: dtag %02X dlen %d", mt->mt_name, dtag, dlen); switch (dtag) { case DVB_DESC_BOUQUET_NAME: @@ -1440,7 +1440,7 @@ dvb_nit_callback case DVB_DESC_PRIVATE_DATA: if (tableid == 0x4A && dlen == 4) { priv = (dptr[0] << 24) | (dptr[1] << 16) | (dptr[2] << 8) | dptr[3]; - tvhtrace(mt->mt_name, " private %08X", priv); + tvhtrace(mt->mt_subsys, "%s: private %08X", mt->mt_name, priv); } break; case DVB_DESC_FREESAT_REGIONS: @@ -1454,7 +1454,7 @@ dvb_nit_callback /* Fastscan */ if (tableid == DVB_FASTSCAN_NIT_BASE) { - tvhdebug(mt->mt_name, "fastscan %04X (%d) [%s]", nbid, nbid, name); + tvhdebug(mt->mt_subsys, "%s: fastscan %04X (%d) [%s]", mt->mt_name, nbid, nbid, name); if (bq && bi) { dvb_bouquet_comment(bq, mm); bq->bq_fastscan_bi = bi; @@ -1462,7 +1462,7 @@ dvb_nit_callback /* BAT */ } else if (tableid == 0x4A) { - tvhdebug(mt->mt_name, "bouquet %04X (%d) [%s]", nbid, nbid, name); + tvhdebug(mt->mt_subsys, "%s: bouquet %04X (%d) [%s]", mt->mt_name, nbid, nbid, name); if (bi && *name) { strncpy(bi->name, name, sizeof(bi->name)-1); bi->name[sizeof(bi->name)-1] = '\0'; @@ -1470,7 +1470,7 @@ dvb_nit_callback /* NIT */ } else { - tvhdebug(mt->mt_name, "network %04X (%d) [%s]", nbid, nbid, name); + tvhdebug(mt->mt_subsys, "%s: network %04X (%d) [%s]", mt->mt_name, nbid, nbid, name); save |= mpegts_network_set_network_name(mn, name); if (save) idnode_changed(&mn->mn_id); @@ -1479,7 +1479,7 @@ dvb_nit_callback } /* Transport length */ - DVB_LOOP_FOREACH(ptr, len, 0, lptr, llen, 6) { + DVB_LOOP_FOREACH(mt, ptr, len, 0, lptr, llen, 6) { tsid = (lptr[0] << 8) | lptr[1]; onid = (lptr[2] << 8) | lptr[3]; @@ -1534,7 +1534,7 @@ dvb_sdt_mux mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhdebug("sdt", "mux %s", buf); + tvhdebug(mt->mt_subsys, "%s: mux %s", mt->mt_name, buf); /* Service loop */ while(len >= 5) { @@ -1547,11 +1547,11 @@ dvb_sdt_mux int running_status = (ptr[3] >> 5) & 0x7; const char *charset; *sprov = *sname = *sauth = 0; - tvhdebug("sdt", " sid %04X (%d) running %d free_ca %d", - service_id, service_id, running_status, free_ca_mode); + tvhdebug(mt->mt_subsys, "%s: sid %04X (%d) running %d free_ca %d", + mt->mt_name, service_id, service_id, running_status, free_ca_mode); /* Initialise the loop */ - DVB_LOOP_INIT(ptr, len, 3, lptr, llen); + DVB_LOOP_INIT(mt, ptr, len, 3, lptr, llen); /* Find service */ s = mpegts_service_find(mm, service_id, 0, 1, &save); @@ -1561,8 +1561,8 @@ dvb_sdt_mux dvb_service_autoenable(s, "SDT"); /* Descriptor loop */ - DVB_DESC_EACH(lptr, llen, dtag, dlen, dptr) { - tvhtrace("sdt", " dtag %02X dlen %d", dtag, dlen); + DVB_DESC_EACH(mt, lptr, llen, dtag, dlen, dptr) { + tvhtrace(mt->mt_subsys, "%s: dtag %02X dlen %d", mt->mt_name, dtag, dlen); switch (dtag) { case DVB_DESC_SERVICE: if (dvb_desc_service(dptr, dlen, &stype, sprov, @@ -1576,7 +1576,7 @@ dvb_sdt_mux case DVB_DESC_PRIVATE_DATA: if (dlen == 4) { priv = (dptr[0] << 24) | (dptr[1] << 16) | (dptr[2] << 8) | dptr[3]; - tvhtrace(mt->mt_name, " private %08X", priv); + tvhtrace(mt->mt_subsys, "%s: private %08X", mt->mt_name, priv); } break; case DVB_DESC_BSKYB_NVOD: @@ -1587,8 +1587,8 @@ dvb_sdt_mux } } - tvhtrace("sdt", " type %02X (%d) name [%s] provider [%s] def_auth [%s]", - stype, stype, sname, sprov, sauth); + tvhtrace(mt->mt_subsys, "%s: type %02X (%d) name [%s] provider [%s] def_auth [%s]", + mt->mt_name, stype, stype, sname, sprov, sauth); if (!s) continue; /* Update service type */ @@ -1596,8 +1596,8 @@ dvb_sdt_mux int r; s->s_dvb_servicetype = stype; save = 1; - tvhtrace("sdt", " type changed / old %02X (%i)", - s->s_dvb_servicetype, s->s_dvb_servicetype); + tvhtrace(mt->mt_subsys, "%s: type changed / old %02X (%i)", + mt->mt_name, s->s_dvb_servicetype, s->s_dvb_servicetype); /* Set tvh service type */ if ((r = dvb_servicetype_lookup(stype)) != -1) @@ -1614,7 +1614,7 @@ dvb_sdt_mux if (*sauth && strcmp(s->s_dvb_cridauth ?: "", sauth)) { tvh_str_update(&s->s_dvb_cridauth, sauth); save = 1; - tvhtrace("sdt", " cridauth changed"); + tvhtrace(mt->mt_subsys, "%s: cridauth changed", mt->mt_name); } /* Update name */ @@ -1622,7 +1622,7 @@ dvb_sdt_mux if (!s->s_dvb_svcname || master) { tvh_str_update(&s->s_dvb_svcname, sname); save2 = 1; - tvhtrace("sdt", " name changed"); + tvhtrace(mt->mt_subsys, "%s: name changed", mt->mt_name); } } @@ -1631,7 +1631,7 @@ dvb_sdt_mux if (!s->s_dvb_provider || master) { tvh_str_update(&s->s_dvb_provider, sprov); save2 = 1; - tvhtrace("sdt", " provider changed"); + tvhtrace(mt->mt_subsys, "%s: provider changed", mt->mt_name); } } @@ -1640,7 +1640,7 @@ dvb_sdt_mux pthread_mutex_lock(&s->s_stream_mutex); service_make_nicename((service_t*)s); pthread_mutex_unlock(&s->s_stream_mutex); - tvhdebug("sdt", " nicename %s", s->s_nicename); + tvhdebug(mt->mt_subsys, "%s: nicename %s", mt->mt_name, s->s_nicename); save = 1; } @@ -1674,7 +1674,8 @@ dvb_sdt_callback if (r != 1) return r; /* ID */ - tvhdebug("sdt", "onid %04X (%d) tsid %04X (%d)", onid, onid, tsid, tsid); + tvhdebug(mt->mt_subsys, "%s: onid %04X (%d) tsid %04X (%d)", + mt->mt_name, onid, onid, tsid, tsid); /* Service descriptors */ len -= 8; @@ -1732,11 +1733,11 @@ atsc_vct_callback r = dvb_table_begin((mpegts_psi_table_t *)mt, ptr, len, tableid, extraid, 7, &st, §, &last, &ver); if (r != 1) return r; - tvhdebug("vct", "tsid %04X (%d)", tsid, tsid); + tvhdebug(mt->mt_subsys, "%s: tsid %04X (%d)", mt->mt_name, tsid, tsid); /* # channels */ count = ptr[6]; - tvhdebug("vct", "channel count %d", count); + tvhdebug(mt->mt_subsys, "%s: channel count %d", mt->mt_name, count); ptr += 7; len -= 7; for (i = 0; i < count && len >= 32; i++) { @@ -1751,13 +1752,13 @@ atsc_vct_callback sid = (ptr[24]) << 8 | ptr[25]; type = ptr[27] & 0x3f; srcid = (ptr[28]) << 8 | ptr[29]; - tvhdebug("vct", "tsid %04X (%d)", tsid, tsid); - tvhdebug("vct", "sid %04X (%d)", sid, sid); - tvhdebug("vct", "chname %s", chname); - tvhdebug("vct", "chnum %d.%d", maj, min); - tvhdebug("vct", "type %02X (%d)", type, type); - tvhdebug("vct", "srcid %04X (%d)", srcid, srcid); - tvhdebug("vct", "dlen %d", dlen); + tvhdebug(mt->mt_subsys, "%s: tsid %04X (%d)", mt->mt_name, tsid, tsid); + tvhdebug(mt->mt_subsys, "%s: sid %04X (%d)", mt->mt_name, sid, sid); + tvhdebug(mt->mt_subsys, "%s: chname %s", mt->mt_name, chname); + tvhdebug(mt->mt_subsys, "%s: chnum %d.%d", mt->mt_name, maj, min); + tvhdebug(mt->mt_subsys, "%s: type %02X (%d)", mt->mt_name, type, type); + tvhdebug(mt->mt_subsys, "%s: srcid %04X (%d)", mt->mt_name, srcid, srcid); + tvhdebug(mt->mt_subsys, "%s: dlen %d", mt->mt_name, dlen); /* Skip */ if (type > 3) @@ -1783,11 +1784,11 @@ atsc_vct_callback x = lang_str_get(ls, "eng"); if (x) snprintf(chname, sizeof(chname), "%s", x); - tvhdebug("vct", " extended channel name: '%s' (%d bytes)", x, len); + tvhdebug(mt->mt_subsys, "%s: extended channel name: '%s' (%d bytes)", mt->mt_name, x, len); lang_str_destroy(ls); } } else { - tvhdebug("vct", " tag 0x%02x, len %d", tag, len); + tvhdebug(mt->mt_subsys, "%s: tag 0x%02x, len %d", mt->mt_name, tag, len); } j += len + 2; } @@ -1849,8 +1850,8 @@ atsc_stt_callback gps_utc_offset = ptr[10]; is_dst = ptr[11] >> 7; - tvhdebug("stt", "system_time %d, gps_utc_offset %d, is DST %d", - systemtime, gps_utc_offset, is_dst); + tvhdebug(mt->mt_subsys, "%s: system_time %d, gps_utc_offset %d, is DST %d", + mt->mt_name, systemtime, gps_utc_offset, is_dst); return dvb_table_end((mpegts_psi_table_t *)mt, st, sect); } @@ -1894,15 +1895,15 @@ dvb_fs_sdt_mux /* (ptr[14] << 8) | ptr[15] - pcr pid */ /* Initialise the loop */ - DVB_LOOP_INIT(ptr, len, 16, lptr, llen); + DVB_LOOP_INIT(mt, ptr, len, 16, lptr, llen); if (discovery) { /* Descriptor loop */ - DVB_DESC_EACH(lptr, llen, dtag, dlen, dptr) { + DVB_DESC_EACH(mt, lptr, llen, dtag, dlen, dptr) { switch (dtag) { case DVB_DESC_SAT_DEL: - tvhtrace(mt->mt_name, " dtag %02X dlen %d (discovery) onid %04X (%d) tsid %04X (%d)", - dtag, dlen, onid, onid, tsid, tsid); + tvhtrace(mt->mt_subsys, "%s: dtag %02X dlen %d (discovery) onid %04X (%d) tsid %04X (%d)", + mt->mt_name, dtag, dlen, onid, onid, tsid, tsid); mux = dvb_desc_sat_del(mt, mm, onid, tsid, dptr, dlen, 1); if (mux) { mpegts_mux_set_onid(mux, onid); @@ -1915,13 +1916,13 @@ dvb_fs_sdt_mux continue; } - tvhdebug(mt->mt_name, " service %04X (%d) onid %04X (%d) tsid %04X (%d)", - service_id, service_id, onid, onid, tsid, tsid); + tvhdebug(mt->mt_subsys, "%s: service %04X (%d) onid %04X (%d) tsid %04X (%d)", + mt->mt_name, service_id, service_id, onid, onid, tsid, tsid); /* Find existing mux */ mux = dvb_fs_mux_find(mm, onid, tsid); if (mux == NULL) { - tvhtrace(mt->mt_name, " mux not found"); + tvhtrace(mt->mt_subsys, "%s: mux not found", mt->mt_name); continue; } mn = mux->mm_network; @@ -1931,8 +1932,8 @@ dvb_fs_sdt_mux charset = dvb_charset_find(mn, mux, s); /* Descriptor loop */ - DVB_DESC_EACH(lptr, llen, dtag, dlen, dptr) { - tvhtrace(mt->mt_name, " dtag %02X dlen %d", dtag, dlen); + DVB_DESC_EACH(mt, lptr, llen, dtag, dlen, dptr) { + tvhtrace(mt->mt_subsys, "%s: dtag %02X dlen %d", mt->mt_name, dtag, dlen); switch (dtag) { case DVB_DESC_SERVICE: if (dvb_desc_service(dptr, dlen, &stype, sprov, @@ -1942,8 +1943,8 @@ dvb_fs_sdt_mux } } - tvhtrace(mt->mt_name, " type %d name [%s] provider [%s]", - stype, sname, sprov); + tvhtrace(mt->mt_subsys, "%s: type %d name [%s] provider [%s]", + mt->mt_name, stype, sname, sprov); if (bi) dvb_bat_find_service(bi, s, 0, UINT_MAX); @@ -1953,7 +1954,7 @@ dvb_fs_sdt_mux int r; s->s_dvb_servicetype = stype; save = 1; - tvhtrace(mt->mt_name, " type changed"); + tvhtrace(mt->mt_subsys, "%s: type changed", mt->mt_name); /* Set tvh service type */ if ((r = dvb_servicetype_lookup(stype)) != -1) @@ -1965,7 +1966,7 @@ dvb_fs_sdt_mux if (!s->s_dvb_svcname) { tvh_str_update(&s->s_dvb_svcname, sname); save = 1; - tvhtrace(mt->mt_name, " name changed"); + tvhtrace(mt->mt_subsys, "%s: name changed", mt->mt_name); } } @@ -1974,7 +1975,7 @@ dvb_fs_sdt_mux if (!s->s_dvb_provider) { tvh_str_update(&s->s_dvb_provider, sprov); save = 1; - tvhtrace(mt->mt_name, " provider changed"); + tvhtrace(mt->mt_subsys, "%s: provider changed", mt->mt_name); } } @@ -1983,7 +1984,7 @@ dvb_fs_sdt_mux pthread_mutex_lock(&s->s_stream_mutex); service_make_nicename((service_t*)s); pthread_mutex_unlock(&s->s_stream_mutex); - tvhdebug(mt->mt_name, " nicename %s", s->s_nicename); + tvhdebug(mt->mt_subsys, "%s: nicename %s", mt->mt_name, s->s_nicename); /* Save changes */ idnode_changed(&s->s_id); service_refresh_channel((service_t*)s); @@ -2053,14 +2054,15 @@ dvb_fs_sdt_callback */ static int psi_desc_add_ca - (mpegts_service_t *t, uint16_t caid, uint32_t provid, uint16_t pid) + (mpegts_table_t *mt, mpegts_service_t *t, + uint16_t caid, uint32_t provid, uint16_t pid) { elementary_stream_t *st; caid_t *c; int r = 0; - tvhdebug("pmt", " caid %04X (%s) provider %08X pid %04X", - caid, caid2name(caid), provid, pid); + tvhdebug(mt->mt_subsys, "%s: caid %04X (%s) provider %08X pid %04X", + mt->mt_name, caid, caid2name(caid), provid, pid); if((st = service_stream_find((service_t*)t, pid)) == NULL) { st = service_stream_create((service_t*)t, pid, SCT_CA); @@ -2100,7 +2102,7 @@ psi_desc_add_ca * Parser for CA descriptors */ static int -psi_desc_ca(mpegts_service_t *t, const uint8_t *buffer, int size) +psi_desc_ca(mpegts_table_t *mt, mpegts_service_t *t, const uint8_t *buffer, int size) { int r = 0; int i; @@ -2117,7 +2119,7 @@ psi_desc_ca(mpegts_service_t *t, const uint8_t *buffer, int size) uint16_t xpid = ((buffer[i]&0x1F) << 8) | buffer[i + 1]; uint16_t xprovid = (buffer[i + 2] << 8) | buffer[i + 3]; - r |= psi_desc_add_ca(t, caid, xprovid, xpid); + r |= psi_desc_add_ca(mt, t, caid, xprovid, xpid); } break; case 0x0500:// Viaccess @@ -2145,7 +2147,7 @@ psi_desc_ca(mpegts_service_t *t, const uint8_t *buffer, int size) break; } - r |= psi_desc_add_ca(t, caid, provid, pid); + r |= psi_desc_add_ca(mt, t, caid, provid, pid); return r; } @@ -2209,7 +2211,7 @@ psi_desc_teletext(mpegts_service_t *t, const uint8_t *ptr, int size, */ static int psi_parse_pmt - (mpegts_mux_t *mux, mpegts_service_t *t, const uint8_t *ptr, int len, int *_update) + (mpegts_table_t *mt, mpegts_service_t *t, const uint8_t *ptr, int len, int *_update) { int ret = 0; uint16_t pcr_pid, pid; @@ -2227,7 +2229,7 @@ psi_parse_pmt int video_stream; const char *lang; uint8_t audio_type; - + mpegts_mux_t *mux = mt->mt_mux; caid_t *c, *cn; lock_assert(&t->s_stream_mutex); @@ -2240,7 +2242,7 @@ psi_parse_pmt t->s_pcr_pid = pcr_pid; update |= PMT_UPDATE_PCR; } - tvhdebug("pmt", " pcr_pid %04X", pcr_pid); + tvhdebug(mt->mt_subsys, "%s: pcr_pid %04X", mt->mt_name, pcr_pid); ptr += 9; len -= 9; @@ -2258,14 +2260,14 @@ psi_parse_pmt dtag = ptr[0]; dlen = ptr[1]; - tvhlog_hexdump("pmt", ptr, dlen + 2); + tvhlog_hexdump(mt->mt_subsys, ptr, dlen + 2); len -= 2; ptr += 2; dllen -= 2; if(dlen > len) break; switch(dtag) { case DVB_DESC_CA: - update |= psi_desc_ca(t, ptr, dlen); + update |= psi_desc_ca(mt, t, ptr, dlen); break; default: @@ -2278,8 +2280,8 @@ psi_parse_pmt estype = ptr[0]; pid = (ptr[1] & 0x1f) << 8 | ptr[2]; dllen = (ptr[3] & 0xf) << 8 | ptr[4]; - tvhdebug("pmt", " pid %04X estype %d", pid, estype); - tvhlog_hexdump("pmt", ptr, 5); + tvhdebug(mt->mt_subsys, "%s: pid %04X estype %d", mt->mt_name, pid, estype); + tvhlog_hexdump(mt->mt_subsys, ptr, 5); ptr += 5; len -= 5; @@ -2339,14 +2341,14 @@ psi_parse_pmt dtag = ptr[0]; dlen = ptr[1]; - tvhlog_hexdump("pmt", ptr, dlen + 2); + tvhlog_hexdump(mt->mt_subsys, ptr, dlen + 2); len -= 2; ptr += 2; dllen -= 2; if(dlen > len) break; switch(dtag) { case DVB_DESC_CA: - update |= psi_desc_ca(t, ptr, dlen); + update |= psi_desc_ca(mt, t, ptr, dlen); break; case DVB_DESC_VIDEO_STREAM: @@ -2417,14 +2419,14 @@ psi_parse_pmt st->es_delete_me = 0; - tvhdebug("pmt", " type %s position %d", - streaming_component_type2txt(st->es_type), position); + tvhdebug(mt->mt_subsys, "%s: type %s position %d", + mt->mt_name, streaming_component_type2txt(st->es_type), position); if (lang) - tvhdebug("pmt", " language %s", lang); + tvhdebug(mt->mt_subsys, "%s: language %s", mt->mt_name, lang); if (composition_id != -1) - tvhdebug("pmt", " composition_id %d", composition_id); + tvhdebug(mt->mt_subsys, "%s: composition_id %d", mt->mt_name, composition_id); if (ancillary_id != -1) - tvhdebug("pmt", " ancillary_id %d", ancillary_id); + tvhdebug(mt->mt_subsys, "%s: ancillary_id %d", mt->mt_name, ancillary_id); if(st->es_position != position) { update |= PMT_REORDERED; @@ -2478,8 +2480,9 @@ psi_parse_pmt sort_elementary_streams((service_t*)t); if(update) { - tvhdebug("pmt", "Service \"%s\" PMT (version %d) updated" + tvhdebug(mt->mt_subsys, "%s: Service \"%s\" PMT (version %d) updated" "%s%s%s%s%s%s%s%s%s%s%s%s%s%s", + mt->mt_name, service_nicename((service_t*)t), version, update&PMT_UPDATE_PCR ? ", PCR PID changed":"", update&PMT_UPDATE_NEW_STREAM ? ", New elementary stream":"", @@ -2570,10 +2573,10 @@ static void psi_tables_default ( mpegts_mux_t *mm ) { mpegts_table_add(mm, DVB_PAT_BASE, DVB_PAT_MASK, dvb_pat_callback, - NULL, "pat", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "pat", LS_TBL_BASE, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_PAT_PID, MPS_WEIGHT_PAT); mpegts_table_add(mm, DVB_CAT_BASE, DVB_CAT_MASK, dvb_cat_callback, - NULL, "cat", MT_QUICKREQ | MT_CRC, DVB_CAT_PID, + NULL, "cat", LS_TBL_BASE, MT_QUICKREQ | MT_CRC, DVB_CAT_PID, MPS_WEIGHT_CAT); } @@ -2581,14 +2584,14 @@ psi_tables_default ( mpegts_mux_t *mm ) static void psi_tables_dvb_fastscan( void *aux, bouquet_t *bq, const char *name, int pid ) { - tvhtrace("fastscan", "adding table %04X (%i) for '%s'", pid, pid, name); + tvhtrace(LS_FASTSCAN, "adding table %04X (%i) for '%s'", pid, pid, name); bq->bq_fastscan_nit = 1; bq->bq_fastscan_sdt = 1; mpegts_table_add(aux, DVB_FASTSCAN_NIT_BASE, DVB_FASTSCAN_MASK, - dvb_nit_callback, bq, "fs_nit", MT_CRC, pid, + dvb_nit_callback, bq, "fs_nit", LS_FASTSCAN, MT_CRC, pid, MPS_WEIGHT_NIT2); mpegts_table_add(aux, DVB_FASTSCAN_SDT_BASE, DVB_FASTSCAN_MASK, - dvb_fs_sdt_callback, bq, "fs_sdt", MT_CRC, pid, + dvb_fs_sdt_callback, bq, "fs_sdt", LS_FASTSCAN, MT_CRC, pid, MPS_WEIGHT_SDT2); } #endif @@ -2597,19 +2600,19 @@ static void psi_tables_dvb ( mpegts_mux_t *mm ) { mpegts_table_add(mm, DVB_NIT_BASE, DVB_NIT_MASK, dvb_nit_callback, - NULL, "nit", MT_QUICKREQ | MT_CRC, DVB_NIT_PID, + NULL, "nit", LS_TBL_BASE, MT_QUICKREQ | MT_CRC, DVB_NIT_PID, MPS_WEIGHT_NIT); mpegts_table_add(mm, DVB_SDT_BASE, DVB_SDT_MASK, dvb_sdt_callback, - NULL, "sdt", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "sdt", LS_TBL_BASE, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_SDT_PID, MPS_WEIGHT_SDT); mpegts_table_add(mm, DVB_BAT_BASE, DVB_BAT_MASK, dvb_bat_callback, - NULL, "bat", MT_CRC, DVB_BAT_PID, MPS_WEIGHT_BAT); + NULL, "bat", LS_TBL_BASE, MT_CRC, DVB_BAT_PID, MPS_WEIGHT_BAT); if (config.tvhtime_update_enabled) { mpegts_table_add(mm, DVB_TDT_BASE, DVB_TDT_MASK, dvb_tdt_callback, - NULL, "tdt", MT_ONESHOT | MT_QUICKREQ | MT_RECORD, + NULL, "tdt", LS_TBL_TIME, MT_ONESHOT | MT_QUICKREQ | MT_RECORD, DVB_TDT_PID, MPS_WEIGHT_TDT); mpegts_table_add(mm, DVB_TOT_BASE, DVB_TOT_MASK, dvb_tot_callback, - NULL, "tot", MT_ONESHOT | MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "tot", LS_TBL_TIME, MT_ONESHOT | MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_TDT_PID, MPS_WEIGHT_TDT); } #if ENABLE_MPEGTS_DVB @@ -2626,10 +2629,10 @@ static void psi_tables_atsc_c ( mpegts_mux_t *mm ) { mpegts_table_add(mm, DVB_VCT_C_BASE, DVB_VCT_MASK, atsc_vct_callback, - NULL, "vct", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "vct", LS_TBL_ATSC, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_VCT_PID, MPS_WEIGHT_VCT); mpegts_table_add(mm, DVB_ATSC_STT_BASE, DVB_ATSC_STT_MASK, atsc_stt_callback, - NULL, "stt", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "stt", LS_TBL_ATSC, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_ATSC_STT_PID, MPS_WEIGHT_STT); } @@ -2637,10 +2640,10 @@ static void psi_tables_atsc_t ( mpegts_mux_t *mm ) { mpegts_table_add(mm, DVB_VCT_T_BASE, DVB_VCT_MASK, atsc_vct_callback, - NULL, "vct", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "vct", LS_TBL_ATSC, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_VCT_PID, MPS_WEIGHT_VCT); mpegts_table_add(mm, DVB_ATSC_STT_BASE, DVB_ATSC_STT_MASK, atsc_stt_callback, - NULL, "stt", MT_QUICKREQ | MT_CRC | MT_RECORD, + NULL, "stt", LS_TBL_ATSC, MT_QUICKREQ | MT_CRC | MT_RECORD, DVB_ATSC_STT_PID, MPS_WEIGHT_STT); } diff --git a/src/input/mpegts/dvb_psi_lib.c b/src/input/mpegts/dvb_psi_lib.c index 3dc0ed5b4..aa2ec3ef6 100644 --- a/src/input/mpegts/dvb_psi_lib.c +++ b/src/input/mpegts/dvb_psi_lib.c @@ -109,8 +109,8 @@ mpegts_psi_section_reassemble0 if(crc && tvh_crc32(p, tsize, 0xffffffff)) { if (tvhlog_limit(&mt->mt_err_log, 10)) { - tvhwarn(mt->mt_name, "%s: invalid checksum (len %i, errors %zi)", - logpref, tsize, mt->mt_err_log.count); + tvhwarn(mt->mt_subsys, "%s: %s: invalid checksum (len %i, errors %zi)", + mt->mt_name, logpref, tsize, mt->mt_err_log.count); } return -1; } @@ -141,8 +141,8 @@ mpegts_psi_section_reassemble if (cc & 0x10) { if (mt->mt_sect.ps_cc != -1 && mt->mt_sect.ps_cc != (cc & 0x0f)) { uint16_t pid = ((tsb[1] & 0x1f) << 8) | tsb[2]; - tvhdebug(mt->mt_name, "%s: PID %04X CC error %d != %d", - logprefix, pid, cc & 0x0f, mt->mt_sect.ps_cc); + tvhdebug(mt->mt_subsys, "%s: %s: PID %04X CC error %d != %d", + mt->mt_name, logprefix, pid, cc & 0x0f, mt->mt_sect.ps_cc); mt->mt_sect.ps_lock = 0; } mt->mt_sect.ps_cc = (cc + 1) & 0x0f; @@ -239,12 +239,13 @@ dvb_table_complete mpegts_psi_table_state_t *st; RB_FOREACH(st, &mt->mt_state, link) total++; - tvhtrace(mt->mt_name, "incomplete %d complete %d total %d", - mt->mt_incomplete, mt->mt_complete, total); + tvhtrace(mt->mt_subsys, "%s: incomplete %d complete %d total %d", + mt->mt_name, mt->mt_incomplete, mt->mt_complete, total); return 2; } if (!mt->mt_finished) - tvhdebug(mt->mt_name, "completed pid %d table %08X / %08x", mt->mt_pid, mt->mt_table, mt->mt_mask); + tvhdebug(mt->mt_subsys, "%s: completed pid %d table %08X / %08x", + mt->mt_name, mt->mt_pid, mt->mt_table, mt->mt_mask); mt->mt_finished = 1; return 0; } @@ -265,8 +266,8 @@ dvb_table_end for (sa = 0; sa < 8; sa++) rem |= st->sections[sa]; if (rem) return 1; - tvhtrace(mt->mt_name, " tableid %02X extraid %016" PRIx64 " completed", - st->tableid, st->extraid); + tvhtrace(mt->mt_subsys, "%s: tableid %02X extraid %016" PRIx64 " completed", + mt->mt_name, st->tableid, st->extraid); st->complete = 1; mt->mt_incomplete--; return dvb_table_complete(mt); @@ -290,7 +291,7 @@ dvb_table_begin /* Not long enough */ if (len < minlen) { - tvhdebug(mt->mt_name, "invalid table length %d min %d", len, minlen); + tvhdebug(mt->mt_subsys, "%s: invalid table length %d min %d", mt->mt_name, len, minlen); return -1; } @@ -298,8 +299,8 @@ dvb_table_begin if((ptr[2] & 1) == 0) return -1; - tvhtrace(mt->mt_name, "pid %02X tableid %02X extraid %016" PRIx64 " len %d", - mt->mt_pid, tableid, extraid, len); + tvhtrace(mt->mt_subsys, "%s: pid %02X tableid %02X extraid %016" PRIx64 " len %d", + mt->mt_name, mt->mt_pid, tableid, extraid, len); /* Section info */ if (sect && ret) { @@ -307,8 +308,8 @@ dvb_table_begin *last = ptr[4]; *ver = (ptr[2] >> 1) & 0x1F; *ret = st = mpegts_table_state_find(mt, tableid, extraid, *last); - tvhtrace(mt->mt_name, " section %d last %d ver %d (ver %d st %d incomp %d comp %d)", - *sect, *last, *ver, st->version, st->complete, mt->mt_incomplete, mt->mt_complete); + tvhtrace(mt->mt_subsys, "%s: section %d last %d ver %d (ver %d st %d incomp %d comp %d)", + mt->mt_name, *sect, *last, *ver, st->version, st->complete, mt->mt_incomplete, mt->mt_complete); #if 0 // FIXME, cannot be enabled in this form /* Ignore previous version */ @@ -326,14 +327,14 @@ dvb_table_begin mt->mt_complete--; if (st->complete) mt->mt_incomplete++; - tvhtrace(mt->mt_name, " new version, restart"); + tvhtrace(mt->mt_subsys, "%s: new version, restart", mt->mt_name); mpegts_table_state_reset(mt, st, *last); st->version = *ver; } /* Complete? */ if (st->complete) { - tvhtrace(mt->mt_name, " skip, already complete (%i)", st->complete); + tvhtrace(mt->mt_subsys, "%s: skip, already complete (%i)", mt->mt_name, st->complete); if (st->complete == 1) { st->complete = 2; mt->mt_complete++; @@ -348,12 +349,12 @@ dvb_table_begin sa = *sect / 32; sb = *sect % 32; if (!(st->sections[sa] & (0x1 << (31 - sb)))) { - tvhtrace(mt->mt_name, " skip, already seen"); + tvhtrace(mt->mt_subsys, "%s: skip, already seen", mt->mt_name); return -1; } } - tvhlog_hexdump(mt->mt_name, ptr, len); + tvhlog_hexdump(mt->mt_subsys, ptr, len); return 1; } @@ -363,7 +364,7 @@ dvb_table_reset(mpegts_psi_table_t *mt) { mpegts_psi_table_state_t *st; - tvhtrace(mt->mt_name, "pid %02X complete reset", mt->mt_pid); + tvhtrace(mt->mt_subsys, "%s: pid %02X complete reset", mt->mt_name, mt->mt_pid); mt->mt_incomplete = 0; mt->mt_complete = 0; while ((st = RB_FIRST(&mt->mt_state)) != NULL) { @@ -388,10 +389,11 @@ dvb_table_release(mpegts_psi_table_t *mt) */ void dvb_table_parse_init - ( mpegts_psi_table_t *mt, const char *name, int pid, void *opaque ) + ( mpegts_psi_table_t *mt, const char *name, int subsys, int pid, void *opaque ) { memset(mt, 0, sizeof(*mt)); mt->mt_name = strdup(name); + mt->mt_subsys = subsys; mt->mt_opaque = opaque; mt->mt_pid = pid; mt->mt_sect.ps_cc = -1; diff --git a/src/input/mpegts/dvb_support.c b/src/input/mpegts/dvb_support.c index f3a14680a..be8e76cc9 100644 --- a/src/input/mpegts/dvb_support.c +++ b/src/input/mpegts/dvb_support.c @@ -404,7 +404,7 @@ atsc_get_string char buf[256]; stringcount = src[0]; - tvhtrace("atsc-str", "%d strings", stringcount); + tvhtrace(LS_MPEGTS, "atsc-str: %d strings", stringcount); src++; srclen--; @@ -417,7 +417,7 @@ atsc_get_string langcode[2] = src[2]; segmentcount = src[3]; - tvhtrace("atsc-str", " %d: lang '%s', segments %d", i, langcode, segmentcount); + tvhtrace(LS_MPEGTS, "atsc-str: %d: lang '%s', segments %d", i, langcode, segmentcount); src += 4; srclen -= 4; @@ -434,7 +434,7 @@ atsc_get_string return ls; if (mode == 0 && compressiontype == 0) { - tvhtrace("atsc-str", " %d: comptype 0x%02x, mode 0x%02x, %d bytes: '%.*s'", + tvhtrace(LS_MPEGTS, "atsc-str: %d: comptype 0x%02x, mode 0x%02x, %d bytes: '%.*s'", j, compressiontype, mode, bytecount, bytecount, src); memcpy(buf, src, bytecount); buf[bytecount] = '\0'; @@ -442,7 +442,7 @@ atsc_get_string ls = lang_str_create(); lang_str_append(ls, buf, langcode); } else { - tvhtrace("atsc-str", " %d: comptype 0x%02x, mode 0x%02x, %d bytes", + tvhtrace(LS_MPEGTS, "atsc-str: %d: comptype 0x%02x, mode 0x%02x, %d bytes", j, compressiontype, mode, bytecount); } diff --git a/src/input/mpegts/fastscan.c b/src/input/mpegts/fastscan.c index 998955840..d9e955be4 100644 --- a/src/input/mpegts/fastscan.c +++ b/src/input/mpegts/fastscan.c @@ -146,7 +146,7 @@ dvb_fastscan_create(htsmsg_t *e) return; fail: - tvhwarn("fastscan", "wrong entry format"); + tvhwarn(LS_FASTSCAN, "wrong entry format"); } /* @@ -158,7 +158,7 @@ void dvb_fastscan_init ( void ) htsmsg_field_t *f; if (!(c = hts_settings_load("fastscan"))) { - tvhwarn("fastscan", "configuration file missing"); + tvhwarn(LS_FASTSCAN, "configuration file missing"); return; } diff --git a/src/input/mpegts/iptv/iptv.c b/src/input/mpegts/iptv/iptv.c index 1ff3db061..3e0477944 100644 --- a/src/input/mpegts/iptv/iptv.c +++ b/src/input/mpegts/iptv/iptv.c @@ -67,7 +67,7 @@ iptv_handler_register ( iptv_handler_t *ih, int num ) while (num) { r = RB_INSERT_SORTED(&iptv_handlers, ih, link, ih_cmp); if (r) - tvhwarn("iptv", "attempt to re-register handler for %s", + tvhwarn(LS_IPTV, "attempt to re-register handler for %s", ih->scheme); num--; ih++; @@ -332,7 +332,7 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi, int weigh } else { if (urlparse(raw ?: "", &url)) { - tvherror("iptv", "%s - invalid URL [%s]", buf, raw); + tvherror(LS_IPTV, "%s - invalid URL [%s]", buf, raw); return ret; } scheme = url.scheme; @@ -342,7 +342,7 @@ iptv_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi, int weigh /* Find scheme handler */ ih = iptv_handler_find(scheme ?: ""); if (!ih) { - tvherror("iptv", "%s - unsupported scheme [%s]", buf, scheme ?: "none"); + tvherror(LS_IPTV, "%s - unsupported scheme [%s]", buf, scheme ?: "none"); return ret; } @@ -423,7 +423,7 @@ iptv_input_pause_check ( iptv_mux_t *im ) im->im_pcr_start += s64; im->im_pcr += (((s64 / 10LL) * 9LL) + 4LL) / 10LL; im->im_pcr &= PTS_MASK; - tvhtrace("iptv-pcr", "pcr: updated %"PRId64", time start %"PRId64", limit %"PRId64, + tvhtrace(LS_IPTV_PCR, "pcr: updated %"PRId64", time start %"PRId64", limit %"PRId64, im->im_pcr, im->im_pcr_start, limit); /* queued more than 3 seconds? trigger the pause */ @@ -439,7 +439,7 @@ iptv_input_unpause ( void *aux ) if (iptv_input_pause_check(im)) { pause = 1; } else { - tvhtrace("iptv-pcr", "unpause timer callback"); + tvhtrace(LS_IPTV_PCR, "unpause timer callback"); im->im_handler->pause(im, 0); pause = 0; } @@ -460,8 +460,8 @@ iptv_input_thread ( void *aux ) nfds = tvhpoll_wait(iptv_poll, &ev, 1, -1); if ( nfds < 0 ) { if (tvheadend_is_running() && !ERRNO_AGAIN(errno)) { - tvhlog(LOG_ERR, "iptv", "poll() error %s, sleeping 1 second", - strerror(errno)); + tvherror(LS_IPTV, "poll() error %s, sleeping 1 second", + strerror(errno)); sleep(1); } continue; @@ -477,7 +477,7 @@ iptv_input_thread ( void *aux ) if (im->mm_active) { /* Get data */ if ((n = im->im_handler->read(im)) < 0) { - tvhlog(LOG_ERR, "iptv", "read() error %s", strerror(errno)); + tvherror(LS_IPTV, "read() error %s", strerror(errno)); im->im_handler->stop(im); break; } @@ -542,7 +542,7 @@ iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) if (in->in_max_bandwidth && in->in_bps > in->in_max_bandwidth * 1024) { if (!in->in_bw_limited) { - tvhinfo("iptv", "%s bandwidth limited exceeded", + tvhinfo(LS_IPTV, "%s bandwidth limited exceeded", idnode_get_title(&in->mn_id, NULL)); in->in_bw_limited = 1; } @@ -555,7 +555,7 @@ iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) mmi = im->mm_active; if (mmi) { if (iptv_input_pause_check(im)) { - tvhtrace("iptv-pcr", "pcr: paused"); + tvhtrace(LS_IPTV_PCR, "pcr: paused"); return 1; } mpegts_input_recv_packets((mpegts_input_t*)iptv_input, mmi, @@ -568,18 +568,18 @@ iptv_input_recv_packets ( iptv_mux_t *im, ssize_t len ) im->im_pcr = pcr.pcr_first; im->im_pcr_start = getfastmonoclock(); im->im_pcr_end = im->im_pcr_start + ((s64 * 100LL) + 50LL) / 9LL; - tvhtrace("iptv-pcr", "pcr: first %"PRId64" last %"PRId64", time start %"PRId64", end %"PRId64, + tvhtrace(LS_IPTV_PCR, "pcr: first %"PRId64" last %"PRId64", time start %"PRId64", end %"PRId64, pcr.pcr_first, pcr.pcr_last, im->im_pcr_start, im->im_pcr_end); } } else { s64 = pts_diff(im->im_pcr, pcr.pcr_last); if (s64 != PTS_UNSET) { im->im_pcr_end = im->im_pcr_start + ((s64 * 100LL) + 50LL) / 9LL; - tvhtrace("iptv-pcr", "pcr: last %"PRId64", time end %"PRId64, pcr.pcr_last, im->im_pcr_end); + tvhtrace(LS_IPTV_PCR, "pcr: last %"PRId64", time end %"PRId64, pcr.pcr_last, im->im_pcr_end); } } if (iptv_input_pause_check(im)) { - tvhtrace("iptv-pcr", "pcr: paused"); + tvhtrace(LS_IPTV_PCR, "pcr: paused"); return 1; } } @@ -603,7 +603,7 @@ iptv_input_fd_started ( iptv_mux_t *im ) /* Error? */ if (tvhpoll_add(iptv_poll, &ev, 1) == -1) { mpegts_mux_nice_name((mpegts_mux_t*)im, buf, sizeof(buf)); - tvherror("iptv", "%s - failed to add to poll q", buf); + tvherror(LS_IPTV, "%s - failed to add to poll q", buf); close(im->mm_iptv_fd); im->mm_iptv_fd = -1; return -1; @@ -619,7 +619,7 @@ iptv_input_fd_started ( iptv_mux_t *im ) /* Error? */ if (tvhpoll_add(iptv_poll, &ev, 1) == -1) { mpegts_mux_nice_name((mpegts_mux_t*)im, buf, sizeof(buf)); - tvherror("iptv", "%s - failed to add to poll q (2)", buf); + tvherror(LS_IPTV, "%s - failed to add to poll q (2)", buf); close(im->mm_iptv_fd2); im->mm_iptv_fd2 = -1; return -1; diff --git a/src/input/mpegts/iptv/iptv_auto.c b/src/input/mpegts/iptv/iptv_auto.c index f193c3765..e0b8d964e 100644 --- a/src/input/mpegts/iptv/iptv_auto.c +++ b/src/input/mpegts/iptv/iptv_auto.c @@ -317,7 +317,7 @@ iptv_auto_network_process_m3u(iptv_network_t *in, char *data, if (total == 0) ret = -1; else - tvhinfo("iptv", "m3u parse: %d new mux(es) in network '%s' (total %d)", + tvhinfo(LS_IPTV, "m3u parse: %d new mux(es) in network '%s' (total %d)", count, in->mn_network_name, total); return ret; } @@ -369,11 +369,11 @@ iptv_auto_network_process(void *aux, const char *last_url, } } if (count > 0) - tvhinfo("iptv", "removed %d mux(es) from network '%s'", count, in->mn_network_name); + tvhinfo(LS_IPTV, "removed %d mux(es) from network '%s'", count, in->mn_network_name); } else { LIST_FOREACH(mm, &in->mn_muxes, mm_network_link) ((iptv_mux_t *)mm)->im_delete_flag = 0; - tvherror("iptv", "unknown playlist format for network '%s'", in->mn_network_name); + tvherror(LS_IPTV, "unknown playlist format for network '%s'", in->mn_network_name); } return -1; @@ -425,7 +425,7 @@ iptv_auto_network_init( iptv_network_t *in ) auto_private_t *ap = calloc(1, sizeof(auto_private_t)); ap->in_network = in; in->in_auto = ap; - download_init(&ap->in_download, "iptv"); + download_init(&ap->in_download, LS_IPTV); ap->in_download.process = iptv_auto_network_process; ap->in_download.stop = iptv_auto_network_stop; iptv_auto_network_trigger(in); diff --git a/src/input/mpegts/iptv/iptv_file.c b/src/input/mpegts/iptv/iptv_file.c index 8abd359c9..94a5a4b5e 100644 --- a/src/input/mpegts/iptv/iptv_file.c +++ b/src/input/mpegts/iptv/iptv_file.c @@ -99,7 +99,7 @@ iptv_file_start ( iptv_mux_t *im, const char *raw, const url_t *url ) int fd = tvh_open(raw + 7, O_RDONLY | O_NONBLOCK, 0); if (fd < 0) { - tvherror("iptv", "unable to open file '%s'", raw + 7); + tvherror(LS_IPTV, "unable to open file '%s'", raw + 7); return -1; } diff --git a/src/input/mpegts/iptv/iptv_http.c b/src/input/mpegts/iptv/iptv_http.c index aea12161c..e05cd45f5 100644 --- a/src/input/mpegts/iptv/iptv_http.c +++ b/src/input/mpegts/iptv/iptv_http.c @@ -176,7 +176,7 @@ iptv_http_get_url( http_priv_t *hp, htsmsg_t *m ) if (sel && hp->hls_url == NULL) { inf = htsmsg_get_map(sel, "stream-inf"); bandwidth = htsmsg_get_s64_or_default(inf, "BANDWIDTH", 0); - tvhdebug("iptv", "HLS - selected stream %s, %"PRId64"kb/s, %s", + tvhdebug(LS_IPTV, "HLS - selected stream %s, %"PRId64"kb/s, %s", htsmsg_get_str(inf, "RESOLUTION"), bandwidth / 1024, htsmsg_get_str(inf, "CODECS")); @@ -364,9 +364,9 @@ iptv_http_reconnect ( http_client_t *hc, const char *url ) hc->hc_keepalive = 0; r = http_client_simple_reconnect(hc, &u, HTTP_VERSION_1_1); if (r < 0) - tvherror("iptv", "cannot reopen http client: %d'", r); + tvherror(LS_IPTV, "cannot reopen http client: %d'", r); } else { - tvherror("iptv", "m3u url invalid '%s'", url); + tvherror(LS_IPTV, "m3u url invalid '%s'", url); } urlreset(&u); } @@ -402,7 +402,7 @@ url: if (hp->hls_key) { s = htsmsg_get_str(hp->hls_key, "METHOD"); if (s == NULL || strcmp(s, "AES-128")) { - tvherror("iptv", "unknown crypto method '%s'", s); + tvherror(LS_IPTV, "unknown crypto method '%s'", s); goto end; } memset(&hp->hls_aes128.iv, 0, sizeof(hp->hls_aes128.iv)); @@ -410,14 +410,14 @@ url: if (s != NULL) { if (s[0] != '0' || (s[1] != 'x' && s[1] != 'X') || strlen(s) != (AES_BLOCK_SIZE * 2) + 2) { - tvherror("iptv", "unknown IV type or length (%s)", s); + tvherror(LS_IPTV, "unknown IV type or length (%s)", s); goto end; } hex2bin(hp->hls_aes128.iv, sizeof(hp->hls_aes128.iv), s + 2); } s = htsmsg_get_str(hp->hls_key, "URI"); if (s == NULL) { - tvherror("iptv", "no URI in KEY attribute"); + tvherror(LS_IPTV, "no URI in KEY attribute"); goto end; } hp->hls_encrypted = 1; @@ -431,9 +431,9 @@ url: sbuf_reset(&hp->key_sbuf, 32); } } - tvhtrace("iptv", "m3u url: '%s'", url); + tvhtrace(LS_IPTV, "m3u url: '%s'", url); if (url == NULL) { - tvherror("iptv", "m3u contents parsing failed"); + tvherror(LS_IPTV, "m3u contents parsing failed"); goto fin; } new_m3u: @@ -471,9 +471,9 @@ iptv_http_complete_key if (hp == NULL) return 0; - tvhtrace("iptv", "received key len %d", hp->key_sbuf.sb_ptr); + tvhtrace(LS_IPTV, "received key len %d", hp->key_sbuf.sb_ptr); if (hp->key_sbuf.sb_ptr != AES_BLOCK_SIZE) { - tvherror("iptv", "AES-128 key wrong length (%d)\n", hp->key_sbuf.sb_ptr); + tvherror(LS_IPTV, "AES-128 key wrong length (%d)\n", hp->key_sbuf.sb_ptr); return 0; } AES_set_decrypt_key(hp->key_sbuf.sb_data, 128, &hp->hls_aes128.key); diff --git a/src/input/mpegts/iptv/iptv_pipe.c b/src/input/mpegts/iptv/iptv_pipe.c index 8b657b75b..f744c532c 100644 --- a/src/input/mpegts/iptv/iptv_pipe.c +++ b/src/input/mpegts/iptv/iptv_pipe.c @@ -49,7 +49,7 @@ iptv_pipe_start ( iptv_mux_t *im, const char *raw, const url_t *url ) goto err; if (spawn_and_give_stdout(argv[0], argv, envp, &rd, &pid, 1)) { - tvherror("iptv", "Unable to start pipe '%s' (wrong executable?)", raw); + tvherror(LS_IPTV, "Unable to start pipe '%s' (wrong executable?)", raw); goto err; } @@ -124,7 +124,7 @@ iptv_pipe_read ( iptv_mux_t *im ) im->mm_iptv_fd = -1; im->im_data = NULL; if (mclk() < im->mm_iptv_respawn_last + sec2mono(2)) { - tvherror("iptv", "stdin pipe unexpectedly closed: %s", + tvherror(LS_IPTV, "stdin pipe unexpectedly closed: %s", r < 0 ? strerror(errno) : "No data"); } else { /* avoid deadlock here */ @@ -133,7 +133,7 @@ iptv_pipe_read ( iptv_mux_t *im ) pthread_mutex_lock(&iptv_lock); if (im->mm_active) { if (iptv_pipe_start(im, im->mm_iptv_url_raw, NULL)) { - tvherror("iptv", "unable to respawn %s", im->mm_iptv_url_raw); + tvherror(LS_IPTV, "unable to respawn %s", im->mm_iptv_url_raw); } else { iptv_input_fd_started(im); im->mm_iptv_respawn_last = mclk(); diff --git a/src/input/mpegts/iptv/iptv_rtcp.c b/src/input/mpegts/iptv/iptv_rtcp.c index fbac7b6fb..702b78b6d 100644 --- a/src/input/mpegts/iptv/iptv_rtcp.c +++ b/src/input/mpegts/iptv/iptv_rtcp.c @@ -242,7 +242,7 @@ rtcp_append_rr(sbuf_t *buffer, rtcp_t *packet) static void rtcp_send(iptv_rtcp_info_t *info, sbuf_t *buffer) { - tvhlog(LOG_DEBUG, "rtsp", "Sending receiver report"); + tvhdebug(LS_IPTV, "RTCP: Sending receiver report"); // We don't care of the result right now udp_write(info->connection, buffer->sb_data, buffer->sb_ptr, & info->connection->peer); } diff --git a/src/input/mpegts/iptv/iptv_rtsp.c b/src/input/mpegts/iptv/iptv_rtsp.c index 5b254ffe2..ac0f550e2 100644 --- a/src/input/mpegts/iptv/iptv_rtsp.c +++ b/src/input/mpegts/iptv/iptv_rtsp.c @@ -83,14 +83,14 @@ iptv_rtsp_header ( http_client_t *hc ) } if (hc->hc_cmd == RTSP_CMD_GET_PARAMETER && hc->hc_code != HTTP_STATUS_OK) { - tvhtrace("iptv", "GET_PARAMETER command returned invalid error code %d for '%s', " + tvhtrace(LS_IPTV, "GET_PARAMETER command returned invalid error code %d for '%s', " "fall back to OPTIONS in keep alive loop.", hc->hc_code, im->mm_iptv_url_raw); hc->hc_rtsp_keep_alive_cmd = RTSP_CMD_OPTIONS; return 0; } if (hc->hc_code != HTTP_STATUS_OK) { - tvherror("iptv", "invalid error code %d for '%s'", hc->hc_code, im->mm_iptv_url_raw); + tvherror(LS_IPTV, "invalid error code %d for '%s'", hc->hc_code, im->mm_iptv_url_raw); return 0; } @@ -108,7 +108,7 @@ iptv_rtsp_header ( http_client_t *hc ) // Now let's set peer port for RTCP // Use the HTTP host for sending RTCP reports, NOT the hc_rtp_dest (which is where the stream is sent) if (udp_connect(rp->rtcp_info->connection, "rtcp", hc->hc_host, hc->hc_rtcp_server_port)) { - tvhlog(LOG_WARNING, "rtsp", "Can't connect to remote, RTCP receiver reports won't be sent"); + tvhwarn(LS_RTSP, "Can't connect to remote, RTCP receiver reports won't be sent"); } hc->hc_cmd = HTTP_CMD_NONE; pthread_mutex_lock(&global_lock); @@ -137,7 +137,7 @@ iptv_rtsp_data return 0; if (len > 0) - tvherror("iptv", "unknown data %zd received for '%s'", len, im->mm_iptv_url_raw); + tvherror(LS_IPTV, "unknown data %zd received for '%s'", len, im->mm_iptv_url_raw); return 0; } @@ -164,7 +164,7 @@ iptv_rtsp_start hc->hc_rtsp_pass = strdup(u->pass); if (udp_bind_double(&rtp, &rtcp, - "IPTV", "rtp", "rtcp", + LS_IPTV, "rtp", "rtcp", NULL, 0, NULL, 128*1024, 16384, 4*1024, 4*1024) < 0) { http_client_close(hc); diff --git a/src/input/mpegts/iptv/iptv_udp.c b/src/input/mpegts/iptv/iptv_udp.c index 25c851579..7f5f3bff2 100644 --- a/src/input/mpegts/iptv/iptv_udp.c +++ b/src/input/mpegts/iptv/iptv_udp.c @@ -40,7 +40,7 @@ iptv_udp_start ( iptv_mux_t *im, const char *raw, const url_t *url ) mpegts_mux_nice_name((mpegts_mux_t*)im, name, sizeof(name)); - conn = udp_bind("iptv", name, url->host, url->port, + conn = udp_bind(LS_IPTV, name, url->host, url->port, im->mm_iptv_interface, IPTV_BUF_SIZE, 4*1024); if (conn == UDP_FATAL_ERROR) return SM_CODE_TUNING_FAILED; @@ -99,7 +99,7 @@ iptv_udp_read ( iptv_mux_t *im ) if (im->mm_iptv_rtp_seq < 0xffff && im->mm_iptv_rtp_seq > 0x3ff) { mpegts_mux_nice_name((mpegts_mux_t*)im, name, sizeof(name)); - tvherror("iptv", "receving non-raw UDP data for %s!", name); + tvherror(LS_IPTV, "receving non-raw UDP data for %s!", name); im->mm_iptv_rtp_seq = 0x10000; /* no further logs! */ } @@ -163,7 +163,7 @@ iptv_rtp_read ( iptv_mux_t *im, udp_multirecv_t *um, seq = nseq; else if (((seq + 1) & 0xffff) != nseq) { unc += (len / 188) * (uint32_t)((uint16_t)nseq-(uint16_t)(seq+1)); - tvhtrace("iptv", "RTP discontinuity (%i != %i)", seq + 1, nseq); + tvhtrace(LS_IPTV, "RTP discontinuity (%i != %i)", seq + 1, nseq); } seq = nseq; diff --git a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c index 409618ad3..5183fe307 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_adapter.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_adapter.c @@ -202,7 +202,7 @@ linuxdvb_adapter_new(const char *path, int a, const char *name, return NULL; } - tvhinfo("linuxdvb", "adapter added %s", path); + tvhinfo(LS_LINUXDVB, "adapter added %s", path); return la; } @@ -326,7 +326,7 @@ linuxdvb_adapter_add ( const char *path ) tvh_safe_usleep(100000); } if (fd < 0) { - tvhlog(LOG_ERR, "linuxdvb", "unable to open %s", fe_path); + tvherror(LS_LINUXDVB, "unable to open %s", fe_path); continue; } #if DVB_VER_ATLEAST(5,5) @@ -335,12 +335,12 @@ linuxdvb_adapter_add ( const char *path ) r = ioctl(fd, FE_GET_INFO, &dfi); close(fd); if(r) { - tvhlog(LOG_ERR, "linuxdvb", "unable to query %s", fe_path); + tvherror(LS_LINUXDVB, "unable to query %s", fe_path); continue; } type = linuxdvb_get_type(dfi.type); if (type == DVB_TYPE_NONE) { - tvhlog(LOG_ERR, "linuxdvb", "unable to determine FE type %s - %i", fe_path, dfi.type); + tvherror(LS_LINUXDVB, "unable to determine FE type %s - %i", fe_path, dfi.type); continue; } @@ -362,7 +362,7 @@ linuxdvb_adapter_add ( const char *path ) if (!la) { la = linuxdvb_adapter_new(path, a, dfi.name, &conf, &save); if (la == NULL) { - tvhlog(LOG_ERR, "linuxdvb", "failed to create %s", path); + tvherror(LS_LINUXDVB, "failed to create %s", path); return; // Note: save to return here as global_lock is held } if (conf) @@ -416,13 +416,13 @@ linuxdvb_adapter_add ( const char *path ) tvh_safe_usleep(100000); } if (fd < 0) { - tvhlog(LOG_ERR, "linuxdvb", "unable to open %s", ca_path); + tvherror(LS_LINUXDVB, "unable to open %s", ca_path); continue; } r = ioctl(fd, CA_RESET, NULL); close(fd); if(r) { - tvhlog(LOG_ERR, "linuxdvb", "unable to query %s", ca_path); + tvherror(LS_LINUXDVB, "unable to query %s", ca_path); continue; } @@ -431,7 +431,7 @@ linuxdvb_adapter_add ( const char *path ) if (!la) { la = linuxdvb_adapter_new(path, a, ca_path, &conf, &save); if (la == NULL) { - tvhlog(LOG_ERR, "linuxdvb", "failed to create %s", path); + tvherror(LS_LINUXDVB, "failed to create %s", path); return; // Note: save to return here as global_lock is held } } @@ -469,11 +469,11 @@ linuxdvb_adapter_add ( const char *path ) la->la_exclusive = 1; for (i = 0; i < ARRAY_SIZE(fetypes); i++) if (fetypes[i] > 0) - tvhwarn("linuxdvb", "adapter %d has tuner count %d for type %s (wrong config)", + tvhwarn(LS_LINUXDVB, "adapter %d has tuner count %d for type %s (wrong config)", a, fetypes[i], dvb_type2str(i)); } else if (!r && j > 1) { la->la_exclusive = 1; - tvhinfo("linuxdvb", "adapter %d setting exlusive flag", a); + tvhinfo(LS_LINUXDVB, "adapter %d setting exlusive flag", a); } #endif @@ -554,7 +554,7 @@ devdvb_create ( fsmonitor_t *fsm, const char *path ) static void devdvb_delete ( fsmonitor_t *fsm, const char *path ) { - tvhinfo("linuxdvb", "adapter removed %s", path); + tvhinfo(LS_LINUXDVB, "adapter removed %s", path); linuxdvb_adapter_del(path); } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_ca.c b/src/input/mpegts/linuxdvb/linuxdvb_ca.c index c28b4d44a..5f16fd082 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_ca.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_ca.c @@ -1,4 +1,4 @@ -/* + /* * Tvheadend - Linux DVB CA * * Copyright (C) 2015 Damjan Marion @@ -109,7 +109,7 @@ ciplus13_app_ai_data_rate_info(linuxdvb_ca_t *lca, ciplus13_data_rate_t rate) if (lca->lca_ai_version != 3) return 0; - tvhinfo("en50221", "setting CI+ CAM data rate to %s Mbps", rate ? "96":"72"); + tvhinfo(LS_EN50221, "setting CI+ CAM data rate to %s Mbps", rate ? "96":"72"); return en50221_sl_send_data(lca->lca_sl, lca->lca_ai_session_number, data, sizeof(data)); } @@ -129,11 +129,11 @@ linuxdvb_ca_class_enabled_notify ( void *p, const char *lang ) if (lca->lca_enabled) { if (lca->lca_ca_fd < 0) { lca->lca_ca_fd = tvh_open(lca->lca_ca_path, O_RDWR | O_NONBLOCK, 0); - tvhtrace("linuxdvb", "opening ca%u %s (fd %d)", + tvhtrace(LS_LINUXDVB, "opening ca%u %s (fd %d)", lca->lca_number, lca->lca_ca_path, lca->lca_ca_fd); } } else { - tvhtrace("linuxdvb", "closing ca%u %s (fd %d)", + tvhtrace(LS_LINUXDVB, "closing ca%u %s (fd %d)", lca->lca_number, lca->lca_ca_path, lca->lca_ca_fd); if (lca->lca_en50221_thread_running) { @@ -285,9 +285,9 @@ en50221_app_unknown_message(void *arg, uint8_t slot_id, uint16_t session_num, uint32_t resource_id, uint8_t *data, uint32_t data_length) { - tvhtrace("en50221", "unknown message slot_id %u, session_num %u, resource_id %x", + tvhtrace(LS_EN50221, "unknown message slot_id %u, session_num %u, resource_id %x", slot_id, session_num, resource_id); - tvhlog_hexdump("en50221", data, data_length); + tvhlog_hexdump(LS_EN50221, data, data_length); return 0; } @@ -327,7 +327,7 @@ linuxdvb_ca_lookup_cb (void * arg, uint8_t slot_id, uint32_t requested_rid, *connected_rid = EN50221_APP_MMI_RESOURCEID; break; default: - tvhtrace("en50221", "lookup cb for unknown resource id %x on slot %u", + tvhtrace(LS_EN50221, "lookup cb for unknown resource id %x on slot %u", requested_rid, slot_id); *callback_out = (en50221_sl_resource_callback) en50221_app_unknown_message; *arg_out = lca; @@ -343,12 +343,12 @@ linuxdvb_ca_session_cb (void *arg, int reason, uint8_t slot_id, linuxdvb_ca_t * lca = arg; if (reason == S_SCALLBACK_REASON_CAMCONNECTING) { - tvhtrace("en50221", "0x%08x session %u connecting", rid, session_num); + tvhtrace(LS_EN50221, "0x%08x session %u connecting", rid, session_num); return 0; } if (reason == S_SCALLBACK_REASON_CAMCONNECTED) { - tvhtrace("en50221", "0x%08x session %u connected", rid, session_num); + tvhtrace(LS_EN50221, "0x%08x session %u connected", rid, session_num); switch(rid) { case EN50221_APP_RM_RESOURCEID: en50221_app_rm_enq(lca->lca_rm_resource, session_num); @@ -371,14 +371,14 @@ linuxdvb_ca_session_cb (void *arg, int reason, uint8_t slot_id, case EN50221_APP_DATETIME_RESOURCEID: break; default: - tvhtrace("en50221", "session %u with unknown rid 0x%08x is connected", + tvhtrace(LS_EN50221, "session %u with unknown rid 0x%08x is connected", session_num, rid); } return 0; } if (reason == S_SCALLBACK_REASON_CLOSE) { - tvhtrace("en50221", "0x%08x session %u close", rid, session_num); + tvhtrace(LS_EN50221, "0x%08x session %u close", rid, session_num); switch(rid) { case EN50221_APP_CA_RESOURCEID: dvbcam_unregister_cam(lca, 0); @@ -388,11 +388,11 @@ linuxdvb_ca_session_cb (void *arg, int reason, uint8_t slot_id, } if (reason == S_SCALLBACK_REASON_TC_CONNECT) { - tvhtrace("en50221", "0x%08x session %u tc connect", rid, session_num); + tvhtrace(LS_EN50221, "0x%08x session %u tc connect", rid, session_num); return 0; } - tvhtrace("en50221", "unhandled session callback - reason %d slot_id %u " + tvhtrace(LS_EN50221, "unhandled session callback - reason %d slot_id %u " "session_num %u resource_id %x", reason, slot_id, session_num, rid); return 0; } @@ -402,12 +402,12 @@ linuxdvb_ca_rm_enq_cb(void *arg, uint8_t slot_id, uint16_t session_num) { linuxdvb_ca_t * lca = arg; - tvhtrace("en50221", "rm enq callback received for slot %d", slot_id); + tvhtrace(LS_EN50221, "rm enq callback received for slot %d", slot_id); if (en50221_app_rm_reply(lca->lca_rm_resource, session_num, sizeof(resource_ids)/4, resource_ids)) { - tvherror("en50221", "failed to send rm reply to slot %u session %u", + tvherror(LS_EN50221, "failed to send rm reply to slot %u session %u", slot_id, session_num); } @@ -420,16 +420,16 @@ linuxdvb_ca_rm_reply_cb(void *arg, uint8_t slot_id, uint16_t session_num, { linuxdvb_ca_t * lca = arg; - tvhtrace("en50221", "rm reply cb received for slot %d, count %u", slot_id, + tvhtrace(LS_EN50221, "rm reply cb received for slot %d, count %u", slot_id, resource_id_count); uint32_t i; for(i=0; i< resource_id_count; i++) { - tvhtrace("en50221", "CAM provided resource id: %08x", _resource_ids[i]); + tvhtrace(LS_EN50221, "CAM provided resource id: %08x", _resource_ids[i]); } if (en50221_app_rm_changed(lca->lca_rm_resource, session_num)) { - tvherror("en50221", "failed to send RM reply on slot %u", slot_id); + tvherror(LS_EN50221, "failed to send RM reply on slot %u", slot_id); } return 0; @@ -440,10 +440,10 @@ linuxdvb_ca_rm_changed_cb(void *arg, uint8_t slot_id, uint16_t session_num) { linuxdvb_ca_t * lca = arg; - tvhtrace("en50221", "rm changed cb received for slot %d", slot_id); + tvhtrace(LS_EN50221, "rm changed cb received for slot %d", slot_id); if (en50221_app_rm_enq(lca->lca_rm_resource, session_num)) { - tvherror("en50221", "failed to send ENQ to slot %d", slot_id); + tvherror(LS_EN50221, "failed to send ENQ to slot %d", slot_id); } return 0; @@ -454,10 +454,10 @@ linuxdvb_ca_dt_enquiry_cb(void *arg, uint8_t slot_id, uint16_t session_num, uint8_t response_int) { linuxdvb_ca_t * lca = arg; - tvhtrace("en50221", "datetime enquiry cb received for slot %d", slot_id); + tvhtrace(LS_EN50221, "datetime enquiry cb received for slot %d", slot_id); if (en50221_app_datetime_send(lca->lca_dt_resource, session_num, time(NULL), -1)) { - tvherror("en50221", "Failed to send datetime to slot %d", slot_id); + tvherror(LS_EN50221, "Failed to send datetime to slot %d", slot_id); } return 0; @@ -471,11 +471,11 @@ linuxdvb_ca_ai_callback(void *arg, uint8_t slot_id, uint16_t session_num, { linuxdvb_ca_t * lca = arg; - tvhinfo("en50221", "CAM slot %u: Application type: %02x, manufacturer: %04x," + tvhinfo(LS_EN50221, "CAM slot %u: Application type: %02x, manufacturer: %04x," " Manufacturer code: %04x", slot_id, app_type, app_manufacturer, manufacturer_code); - tvhinfo("en50221", "CAM slot %u: Menu string: %.*s", slot_id, + tvhinfo(LS_EN50221, "CAM slot %u: Menu string: %.*s", slot_id, menu_string_len, menu_string); snprintf(lca->lca_cam_menu_string, sizeof(lca->lca_cam_menu_string), @@ -505,7 +505,7 @@ linuxdvb_ca_ca_info_callback(void *arg, uint8_t slot_id, uint16_t session_num, caid2name(ca_ids[i])); } - tvhinfo("en50221", "CAM slot %u supported CAIDs: %s", slot_id, buf); + tvhinfo(LS_EN50221, "CAM slot %u supported CAIDs: %s", slot_id, buf); return 0; } @@ -525,7 +525,7 @@ linuxdvb_ca_ca_pmt_reply_cb(void *arg, uint8_t slot_id, uint16_t session_num, default: str = "state unknown (unknown value received)"; } - tvhinfo("en50221", "CAM slot %u: descrambling %s", slot_id, str); + tvhinfo(LS_EN50221, "CAM slot %u: descrambling %s", slot_id, str); return 0; } @@ -534,7 +534,7 @@ static int linuxdvb_ca_mmi_close_cb(void *arg, uint8_t slot_id, uint16_t session_num, uint8_t cmd_id, uint8_t delay) { - tvhtrace("en50221", "mmi close cb received for slot %u session_num %u " + tvhtrace(LS_EN50221, "mmi close cb received for slot %u session_num %u " "cmd_id 0x%02x delay %u" , slot_id, session_num, cmd_id, delay); return 0; @@ -546,7 +546,7 @@ linuxdvb_ca_mmi_display_ctl_cb(void *arg, uint8_t slot_id, uint16_t session_num, { linuxdvb_ca_t * lca = arg; - tvhtrace("en50221", "mmi display ctl cb received for slot %u session_num %u " + tvhtrace(LS_EN50221, "mmi display ctl cb received for slot %u session_num %u " "cmd_id 0x%02x mmi_mode %u" , slot_id, session_num, cmd_id, mmi_mode); if (cmd_id == MMI_DISPLAY_CONTROL_CMD_ID_SET_MMI_MODE) { @@ -555,7 +555,7 @@ linuxdvb_ca_mmi_display_ctl_cb(void *arg, uint8_t slot_id, uint16_t session_num, d.u.mode_ack.mmi_mode = mmi_mode; if (en50221_app_mmi_display_reply(lca->lca_mmi_resource, session_num, MMI_DISPLAY_REPLY_ID_MMI_MODE_ACK, &d)) { - tvherror("en50221","Slot %u: Failed to send MMI mode ack reply", slot_id); + tvherror(LS_EN50221,"Slot %u: Failed to send MMI mode ack reply", slot_id); } } @@ -572,14 +572,14 @@ linuxdvb_ca_mmi_enq_cb(void *arg, uint8_t slot_id, uint16_t session_num, snprintf(buffer, sizeof(buffer), "%.*s", text_size, text); - tvhlog(LOG_NOTICE, "en50221", "MMI enquiry from CAM in slot %u: %s (%s%u digits)", - slot_id, buffer, blind_answ ? "blind " : "" , exp_answ_len); + tvhnotice(LS_EN50221, "MMI enquiry from CAM in slot %u: %s (%s%u digits)", + slot_id, buffer, blind_answ ? "blind " : "" , exp_answ_len); if (lca->lca_pin_reply && (strlen((char *) lca->lca_pin_str) == exp_answ_len) && strstr((char *) buffer, lca->lca_pin_match_str)) { - tvhtrace("en50221", "answering to PIN enquiry"); + tvhtrace(LS_EN50221, "answering to PIN enquiry"); en50221_app_mmi_answ(lca->lca_mmi_resource, session_num, MMI_ANSW_ID_ANSWER, (uint8_t *) lca->lca_pin_str, exp_answ_len); @@ -601,15 +601,15 @@ linuxdvb_ca_mmi_menu_cb(void *arg, uint8_t slot_id, uint16_t session_num, { linuxdvb_ca_t * lca = arg; - tvhlog(LOG_NOTICE, "en50221", "MMI menu from CAM in the slot %u:", slot_id); - tvhlog(LOG_NOTICE, "en50221", " title: %.*s", title->text_length, title->text); - tvhlog(LOG_NOTICE, "en50221", " subtitle: %.*s", sub_title->text_length, sub_title->text); + tvhnotice(LS_EN50221, "MMI menu from CAM in the slot %u:", slot_id); + tvhnotice(LS_EN50221, " title: %.*s", title->text_length, title->text); + tvhnotice(LS_EN50221, " subtitle: %.*s", sub_title->text_length, sub_title->text); uint32_t i; for(i=0; i< item_count; i++) { - tvhlog(LOG_NOTICE, "en50221", " item %i: %.*s", i+1, items[i].text_length, items[i].text); + tvhnotice(LS_EN50221, " item %i: %.*s", i+1, items[i].text_length, items[i].text); } - tvhlog(LOG_NOTICE, "en50221", " bottom: %.*s", bottom->text_length, bottom->text); + tvhnotice(LS_EN50221, " bottom: %.*s", bottom->text_length, bottom->text); /* cancel menu */ en50221_app_mmi_close(lca->lca_mmi_resource, session_num, @@ -627,15 +627,15 @@ linuxdvb_ca_app_mmi_list_cb(void *arg, uint8_t slot_id, uint16_t session_num, { linuxdvb_ca_t * lca = arg; - tvhlog(LOG_NOTICE, "en50221", "MMI list from CAM in the slot %u:", slot_id); - tvhlog(LOG_NOTICE, "en50221", " title: %.*s", title->text_length, title->text); - tvhlog(LOG_NOTICE, "en50221", " subtitle: %.*s", sub_title->text_length, sub_title->text); + tvhnotice(LS_EN50221, "MMI list from CAM in the slot %u:", slot_id); + tvhnotice(LS_EN50221, " title: %.*s", title->text_length, title->text); + tvhnotice(LS_EN50221, " subtitle: %.*s", sub_title->text_length, sub_title->text); uint32_t i; for(i=0; i< item_count; i++) { - tvhlog(LOG_NOTICE, "en50221", " item %i: %.*s", i+1, items[i].text_length, items[i].text); + tvhnotice(LS_EN50221, " item %i: %.*s", i+1, items[i].text_length, items[i].text); } - tvhlog(LOG_NOTICE, "en50221", " bottom: %.*s", bottom->text_length, bottom->text); + tvhnotice(LS_EN50221, " bottom: %.*s", bottom->text_length, bottom->text); /* cancel menu */ en50221_app_mmi_close(lca->lca_mmi_resource, session_num, @@ -651,19 +651,19 @@ linuxdvb_ca_en50221_thread ( void *aux ) lca->lca_tl = en50221_tl_create(5, 32); if (!lca->lca_tl) { - tvherror("en50221", "failed to create transport layer"); + tvherror(LS_EN50221, "failed to create transport layer"); return NULL; } slot_id = en50221_tl_register_slot(lca->lca_tl, lca->lca_ca_fd, 0, 1000, 100); if (slot_id < 0) { - tvherror("en50221", "slot registration failed"); + tvherror(LS_EN50221, "slot registration failed"); return NULL; } lca->lca_sl = en50221_sl_create(lca->lca_tl, 256); if (lca->lca_sl == NULL) { - tvherror("en50221", "failed to create session layer"); + tvherror(LS_EN50221, "failed to create session layer"); return NULL; } @@ -704,7 +704,7 @@ linuxdvb_ca_en50221_thread ( void *aux ) int error; if ((error = en50221_tl_poll(lca->lca_tl)) != 0) { if (error != lasterror) { - tvherror("en50221", "poll error on slot %d [error:%i]", + tvherror(LS_EN50221, "poll error on slot %d [error:%i]", en50221_tl_get_error_slot(lca->lca_tl), en50221_tl_get_error(lca->lca_tl)); } @@ -731,7 +731,7 @@ linuxdvb_ca_monitor ( void *aux ) if (lca->lca_ca_fd >= 0) { if ((ioctl(lca->lca_ca_fd, CA_GET_SLOT_INFO, &csi)) != 0) { - tvherror("linuxdvb", "failed to get CAM slot %u info [e=%s]", + tvherror(LS_LINUXDVB, "failed to get CAM slot %u info [e=%s]", csi.num, strerror(errno)); } if (csi.flags & CA_CI_MODULE_READY) @@ -744,8 +744,8 @@ linuxdvb_ca_monitor ( void *aux ) lca->lca_state_str = ca_slot_state2str(state); if (lca->lca_state != state) { - tvhlog(LOG_INFO, "linuxdvb", "CAM slot %u status changed to %s", - csi.num, lca->lca_state_str); + tvhnotice(LS_LINUXDVB, "CAM slot %u status changed to %s", + csi.num, lca->lca_state_str); idnode_notify_title_changed(&lca->lca_id, NULL); lca->lca_state = state; } @@ -828,17 +828,17 @@ linuxdvb_ca_process_capmt_queue ( void *aux ) return; if (!(section = section_codec(lcc->data, lcc->len))){ - tvherror("en50221", "failed to decode PMT section"); + tvherror(LS_EN50221, "failed to decode PMT section"); goto done; } if (!(result = section_ext_decode(section, 0))){ - tvherror("en50221", "failed to decode PMT ext_section"); + tvherror(LS_EN50221, "failed to decode PMT ext_section"); goto done; } if (!(pmt = mpeg_pmt_section_codec(result))){ - tvherror("en50221", "failed to decode PMT"); + tvherror(LS_EN50221, "failed to decode PMT"); goto done; } @@ -846,17 +846,17 @@ linuxdvb_ca_process_capmt_queue ( void *aux ) lcc->list_mgmt, lcc->cmd_id); if (size < 0) { - tvherror("en50221", "Failed to format CAPMT"); + tvherror(LS_EN50221, "Failed to format CAPMT"); } if (en50221_app_ca_pmt(lca->lca_ca_resource, lca->lca_ca_session_number, capmt, size)) { - tvherror("en50221", "Failed to send CAPMT"); + tvherror(LS_EN50221, "Failed to send CAPMT"); } - tvhtrace("en50221", "%s CAPMT sent (%s)", ca_pmt_cmd_id2str(lcc->cmd_id), + tvhtrace(LS_EN50221, "%s CAPMT sent (%s)", ca_pmt_cmd_id2str(lcc->cmd_id), ca_pmt_list_mgmt2str(lcc->list_mgmt)); - tvhlog_hexdump("en50221", capmt, size); + tvhlog_hexdump(LS_EN50221, capmt, size); done: i = (lcc->cmd_id == CA_PMT_CMD_ID_QUERY) ? @@ -901,7 +901,7 @@ linuxdvb_ca_enqueue_capmt(linuxdvb_ca_t *lca, uint8_t slot, const uint8_t *ptr, TAILQ_INSERT_TAIL(&lca->lca_capmt_queue, lcc, lcc_link); - tvhtrace("en50221", "%s CAPMT enqueued (%s)", ca_pmt_cmd_id2str(lcc->cmd_id), + tvhtrace(LS_EN50221, "%s CAPMT enqueued (%s)", ca_pmt_cmd_id2str(lcc->cmd_id), ca_pmt_list_mgmt2str(lcc->list_mgmt)); } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c index d3501a414..8f36c2cd2 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_en50494.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_en50494.c @@ -162,7 +162,7 @@ linuxdvb_en50494_freq0 /* transponder value - t */ *t = round((((freq / 1000) + 2 + le->le_frequency) / 4) - 350); if (*t > 1024) { - tvherror("en50494", "transponder value bigger then 1024"); + tvherror(LS_EN50494, "transponder value bigger then 1024"); return -1; } @@ -220,7 +220,7 @@ linuxdvb_en50494_tune */ if (pthread_mutex_trylock(&linuxdvb_en50494_lock) != 0) { if (pthread_mutex_lock(&linuxdvb_en50494_lock) != 0) { - tvherror("en50494","failed to lock for tuning"); + tvherror(LS_EN50494,"failed to lock for tuning"); return -1; } tvh_safe_usleep(20000); @@ -240,13 +240,13 @@ linuxdvb_en50494_tune /* use 18V */ ret = linuxdvb_diseqc_set_volt(lsp, 1); if (ret) { - tvherror("en50494", "error setting lnb voltage to 18V"); + tvherror(LS_EN50494, "error setting lnb voltage to 18V"); break; } tvh_safe_usleep(15000); /* standard: 4ms < x < 22ms */ /* send tune command (with/without pin) */ - tvhdebug("en50494", + tvhdebug(LS_EN50494, "lnb=%i id=%i freq=%i pin=%i v/h=%i l/u=%i f=%i, data=0x%02X%02X", le->le_position, le->le_id, le->le_frequency, le->le_pin, pol, band, freq, data1, data2); @@ -266,7 +266,7 @@ linuxdvb_en50494_tune data1, data2); } if (ret != 0) { - tvherror("en50494", "error send tune command"); + tvherror(LS_EN50494, "error send tune command"); break; } tvh_safe_usleep(50000); /* standard: 2ms < x < 60ms */ @@ -274,7 +274,7 @@ linuxdvb_en50494_tune /* return to 13V */ ret = linuxdvb_diseqc_set_volt(lsp, 0); if (ret) { - tvherror("en50494", "error setting lnb voltage back to 13V"); + tvherror(LS_EN50494, "error setting lnb voltage back to 13V"); break; } } @@ -292,7 +292,7 @@ void linuxdvb_en50494_init (void) { if (pthread_mutex_init(&linuxdvb_en50494_lock, NULL) != 0) { - tvherror("en50494", "failed to init lock mutex"); + tvherror(LS_EN50494, "failed to init lock mutex"); } } @@ -316,7 +316,7 @@ linuxdvb_en50494_create0 return NULL; if (port > 1) { - tvherror("en50494", "only 2 ports/positions are possible. given %i", port); + tvherror(LS_EN50494, "only 2 ports/positions are possible. given %i", port); port = 0; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c index ec5e8b18e..50cdc50c8 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_frontend.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_frontend.c @@ -426,7 +426,7 @@ linuxdvb_frontend_enabled_updated ( mpegts_input_t *mi ) /* Ensure disabled */ if (!mi->mi_enabled) { - tvhtrace("linuxdvb", "%s - disabling tuner", buf); + tvhtrace(LS_LINUXDVB, "%s - disabling tuner", buf); if (lfe->lfe_fe_fd > 0) { close(lfe->lfe_fe_fd); lfe->lfe_fe_fd = -1; @@ -438,7 +438,7 @@ linuxdvb_frontend_enabled_updated ( mpegts_input_t *mi ) /* Ensure FE opened (if not powersave) */ } else if (!lfe->lfe_powersave && lfe->lfe_fe_fd <= 0 && lfe->lfe_fe_path) { lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0); - tvhtrace("linuxdvb", "%s - opening FE %s (%d)", + tvhtrace(LS_LINUXDVB, "%s - opening FE %s (%d)", buf, lfe->lfe_fe_path, lfe->lfe_fe_fd); } } @@ -531,15 +531,15 @@ linuxdvb_frontend_stop_mux mi->mi_display_name(mi, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("linuxdvb", "%s - stopping %s", buf1, buf2); + tvhdebug(LS_LINUXDVB, "%s - stopping %s", buf1, buf2); /* Stop thread */ if (lfe->lfe_dvr_pipe.wr > 0) { tvh_write(lfe->lfe_dvr_pipe.wr, "", 1); - tvhtrace("linuxdvb", "%s - waiting for dvr thread", buf1); + tvhtrace(LS_LINUXDVB, "%s - waiting for dvr thread", buf1); pthread_join(lfe->lfe_dvr_thread, NULL); tvh_pipe_close(&lfe->lfe_dvr_pipe); - tvhdebug("linuxdvb", "%s - stopped dvr thread", buf1); + tvhdebug(LS_LINUXDVB, "%s - stopped dvr thread", buf1); } /* Not locked */ @@ -658,7 +658,7 @@ linuxdvb_frontend_network_list ( mpegts_input_t *mi ) { linuxdvb_frontend_t *lfe = (linuxdvb_frontend_t*)mi; - tvhtrace("linuxdvb", "%s: network list for %s", + tvhtrace(LS_LINUXDVB, "%s: network list for %s", mi->mi_name ?: "", dvb_type2str(lfe->lfe_type)); return dvb_network_list_by_fe_type(lfe->lfe_type); @@ -703,7 +703,7 @@ linuxdvb_frontend_monitor ( void *aux ) #endif lfe->mi_display_name((mpegts_input_t*)lfe, buf, sizeof(buf)); - tvhtrace("linuxdvb", "%s - checking FE status%s", buf, lfe->lfe_ready ? " (ready)" : ""); + tvhtrace(LS_LINUXDVB, "%s - checking FE status%s", buf, lfe->lfe_ready ? " (ready)" : ""); /* Disabled */ if (!lfe->mi_enabled && mmi) @@ -711,7 +711,7 @@ linuxdvb_frontend_monitor ( void *aux ) /* Close FE */ if (lfe->lfe_fe_fd > 0 && !lfe->lfe_refcount && lfe->lfe_powersave) { - tvhtrace("linuxdvb", "%s - closing frontend", buf); + tvhtrace(LS_LINUXDVB, "%s - closing frontend", buf); close(lfe->lfe_fe_fd); lfe->lfe_fe_fd = -1; if (lfe->lfe_satconf) @@ -721,7 +721,7 @@ linuxdvb_frontend_monitor ( void *aux ) /* Check accessibility */ if (lfe->lfe_fe_fd <= 0) { if (lfe->lfe_fe_path && access(lfe->lfe_fe_path, R_OK | W_OK)) { - tvherror("linuxdvb", "%s - device is not accessible", buf); + tvherror(LS_LINUXDVB, "%s - device is not accessible", buf); // TODO: disable device return; } @@ -735,7 +735,7 @@ linuxdvb_frontend_monitor ( void *aux ) /* Get current status */ if (ioctl(lfe->lfe_fe_fd, FE_READ_STATUS, &fe_status) == -1) { - tvhwarn("linuxdvb", "%s - FE_READ_STATUS error %s", buf, strerror(errno)); + tvhwarn(LS_LINUXDVB, "%s - FE_READ_STATUS error %s", buf, strerror(errno)); /* TODO: check error value */ return; @@ -750,7 +750,7 @@ linuxdvb_frontend_monitor ( void *aux ) /* Set default period */ if (fe_status != lfe->lfe_status) { - tvhdebug("linuxdvb", "%s - status %7s (%s%s%s%s%s%s)", buf, + tvhdebug(LS_LINUXDVB, "%s - status %7s (%s%s%s%s%s%s)", buf, signal2str(status), (fe_status & FE_HAS_SIGNAL) ? "SIGNAL" : "", (fe_status & FE_HAS_CARRIER) ? " | CARRIER" : "", @@ -759,7 +759,7 @@ linuxdvb_frontend_monitor ( void *aux ) (fe_status & FE_HAS_LOCK) ? " | LOCK" : "", (fe_status & FE_TIMEDOUT) ? "TIMEOUT" : ""); } else { - tvhtrace("linuxdvb", "%s - status %d (%04X)", buf, status, fe_status); + tvhtrace(LS_LINUXDVB, "%s - status %d (%04X)", buf, status, fe_status); } retune = NOSIGNAL(fe_status) && NOSIGNAL(lfe->lfe_status) && !NOSIGNAL(lfe->lfe_status2); lfe->lfe_status2 = lfe->lfe_status; @@ -769,7 +769,7 @@ linuxdvb_frontend_monitor ( void *aux ) if (retune || lfe->lfe_nodata) { lfe->lfe_nodata = 0; if (lfe->lfe_locked && lfe->lfe_freq > 0) { - tvhlog(LOG_WARNING, "linuxdvb", "%s - %s", buf, retune ? "retune" : "retune nodata"); + tvhwarn(LS_LINUXDVB, "%s - %s", buf, retune ? "retune" : "retune nodata"); linuxdvb_frontend_tune0(lfe, mmi, lfe->lfe_freq); mtimer_arm_rel(&lfe->lfe_monitor_timer, linuxdvb_frontend_monitor, lfe, ms2mono(50)); lfe->lfe_locked = 1; @@ -784,7 +784,7 @@ linuxdvb_frontend_monitor ( void *aux ) /* Locked */ if (status == SIGNAL_GOOD) { - tvhdebug("linuxdvb", "%s - locked", buf); + tvhdebug(LS_LINUXDVB, "%s - locked", buf); lfe->lfe_locked = 1; /* Start input */ @@ -863,8 +863,8 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 1); mmi->tii_stats.signal_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled signal scale: %d", - fe_properties[0].u.st.stat[0].scale); + tvhwarn(LS_LINUXDVB, "Unhandled signal scale: %d", + fe_properties[0].u.st.stat[0].scale); } } if(!gotprop && ioctl_check(lfe, 2)) { @@ -877,7 +877,7 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 2); mmi->tii_stats.signal_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide signal strength value."); + tvhwarn(LS_LINUXDVB, "Unable to provide signal strength value."); } } @@ -891,8 +891,8 @@ linuxdvb_frontend_monitor ( void *aux ) else { ioctl_bad(lfe, 3); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled ERROR_BIT_COUNT scale: %d", - fe_properties[1].u.st.stat[0].scale); + tvhwarn(LS_LINUXDVB, "Unhandled ERROR_BIT_COUNT scale: %d", + fe_properties[1].u.st.stat[0].scale); } } /* TOTAL_BIT_COUNT */ @@ -906,8 +906,8 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 4); mmi->tii_stats.ec_bit = 0; /* both values or none */ if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled TOTAL_BIT_COUNT scale: %d", - fe_properties[2].u.st.stat[0].scale); + tvhwarn(LS_LINUXDVB, "Unhandled TOTAL_BIT_COUNT scale: %d", + fe_properties[2].u.st.stat[0].scale); } } if(!gotprop && ioctl_check(lfe, 5)) { @@ -917,7 +917,7 @@ linuxdvb_frontend_monitor ( void *aux ) else { ioctl_bad(lfe, 5); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide BER value."); + tvhwarn(LS_LINUXDVB, "Unable to provide BER value."); } } @@ -938,8 +938,8 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 6); mmi->tii_stats.snr_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled SNR scale: %d", - fe_properties[3].u.st.stat[0].scale); + tvhwarn(LS_LINUXDVB, "Unhandled SNR scale: %d", + fe_properties[3].u.st.stat[0].scale); } } if(!gotprop && ioctl_check(lfe, 7)) { @@ -952,7 +952,7 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 7); mmi->tii_stats.snr_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide SNR value."); + tvhwarn(LS_LINUXDVB, "Unable to provide SNR value."); } } @@ -967,8 +967,8 @@ linuxdvb_frontend_monitor ( void *aux ) else { ioctl_bad(lfe, 8); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled ERROR_BLOCK_COUNT scale: %d", - fe_properties[4].u.st.stat[0].scale); + tvhwarn(LS_LINUXDVB, "Unhandled ERROR_BLOCK_COUNT scale: %d", + fe_properties[4].u.st.stat[0].scale); } } @@ -985,7 +985,7 @@ linuxdvb_frontend_monitor ( void *aux ) mmi->tii_stats.ec_block = 0; atomic_set(&mmi->tii_stats.unc, 0); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unhandled TOTAL_BLOCK_COUNT scale: %d", + tvhwarn(LS_LINUXDVB, "Unhandled TOTAL_BLOCK_COUNT scale: %d", fe_properties[5].u.st.stat[0].scale); } } @@ -998,7 +998,7 @@ linuxdvb_frontend_monitor ( void *aux ) else { ioctl_bad(lfe, 10); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide UNC value."); + tvhwarn(LS_LINUXDVB, "Unable to provide UNC value."); } } /* Older API */ @@ -1014,14 +1014,14 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 1); mmi->tii_stats.signal_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide signal strength value."); + tvhwarn(LS_LINUXDVB, "Unable to provide signal strength value."); } if (ioctl_check(lfe, 2) && !ioctl(lfe->lfe_fe_fd, FE_READ_BER, &u32)) mmi->tii_stats.ber = u32; else { ioctl_bad(lfe, 2); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide BER value."); + tvhwarn(LS_LINUXDVB, "Unable to provide BER value."); } if (ioctl_check(lfe, 3) && !ioctl(lfe->lfe_fe_fd, FE_READ_SNR, &u16)) { mmi->tii_stats.snr_scale = SIGNAL_STATUS_SCALE_RELATIVE; @@ -1031,14 +1031,14 @@ linuxdvb_frontend_monitor ( void *aux ) ioctl_bad(lfe, 3); mmi->tii_stats.snr_scale = SIGNAL_STATUS_SCALE_UNKNOWN; if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide SNR value."); + tvhwarn(LS_LINUXDVB, "Unable to provide SNR value."); } if (ioctl_check(lfe, 4) && !ioctl(lfe->lfe_fe_fd, FE_READ_UNCORRECTED_BLOCKS, &u32)) atomic_set(&mmi->tii_stats.unc, u32); else { ioctl_bad(lfe, 4); if (logit) - tvhlog(LOG_WARNING, "linuxdvb", "Unable to provide UNC value."); + tvhwarn(LS_LINUXDVB, "Unable to provide UNC value."); } } @@ -1081,7 +1081,7 @@ linuxdvb_frontend_open_pid0 for ( ; pids_size > 0 && pids->fd >= 0; pids_size--, pids++); if (pids_size == 0) { - tvherror("linuxdvb", "%s - maximum PID count reached, pid %d ignored", + tvherror(LS_LINUXDVB, "%s - maximum PID count reached, pid %d ignored", name, pid); return; } @@ -1089,13 +1089,13 @@ linuxdvb_frontend_open_pid0 /* Open DMX */ fd = tvh_open(lfe->lfe_dmx_path, O_RDWR, 0); if(fd == -1) { - tvherror("linuxdvb", "%s - failed to open dmx for pid %d [e=%s]", + tvherror(LS_LINUXDVB, "%s - failed to open dmx for pid %d [e=%s]", name, pid, strerror(errno)); return; } /* Install filter */ - tvhtrace("linuxdvb", "%s - open PID %04X (%d) fd %d", name, pid, pid, fd); + tvhtrace(LS_LINUXDVB, "%s - open PID %04X (%d) fd %d", name, pid, pid, fd); memset(&dmx_param, 0, sizeof(dmx_param)); dmx_param.pid = pid; dmx_param.input = DMX_IN_FRONTEND; @@ -1104,7 +1104,7 @@ linuxdvb_frontend_open_pid0 dmx_param.flags = DMX_IMMEDIATE_START; if(ioctl(fd, DMX_SET_PES_FILTER, &dmx_param)) { - tvherror("linuxdvb", "%s - failed to config dmx for pid %d [e=%s]", + tvherror(LS_LINUXDVB, "%s - failed to config dmx for pid %d [e=%s]", name, pid, strerror(errno)); close(fd); return; @@ -1124,7 +1124,7 @@ linuxdvb_frontend_close_pid0 pids_size--, pids++); if (pids_size == 0) return; - tvhtrace("linuxdvb", "%s - close PID %04X (%d) fd %d", name, pid, pid, pids->fd); + tvhtrace(LS_LINUXDVB, "%s - close PID %04X (%d) fd %d", name, pid, pid, pids->fd); close(pids->fd); pids->fd = -1; pids->pid = -1; @@ -1207,7 +1207,7 @@ linuxdvb_frontend_input_thread ( void *aux ) /* Open DVR */ dvr = tvh_open(lfe->lfe_dvr_path, O_RDONLY | O_NONBLOCK, 0); if (dvr < 0) { - tvherror("linuxdvb", "%s - failed to open %s", name, lfe->lfe_dvr_path); + tvherror(LS_LINUXDVB, "%s - failed to open %s", name, lfe->lfe_dvr_path); return NULL; } @@ -1231,7 +1231,7 @@ linuxdvb_frontend_input_thread ( void *aux ) nfds = tvhpoll_wait(efd, ev, 1, 150); if (nfds == 0) { /* timeout */ if (nodata == 0) { - tvhlog(LOG_WARNING, "linuxdvb", "%s - poll TIMEOUT", name); + tvhwarn(LS_LINUXDVB, "%s - poll TIMEOUT", name); nodata = 50; lfe->lfe_nodata = 1; } else { @@ -1258,11 +1258,11 @@ linuxdvb_frontend_input_thread ( void *aux ) if (ERRNO_AGAIN(errno)) continue; if (errno == EOVERFLOW) { - tvhlog(LOG_WARNING, "linuxdvb", "%s - read() EOVERFLOW", name); + tvhwarn(LS_LINUXDVB, "%s - read() EOVERFLOW", name); continue; } - tvhlog(LOG_ERR, "linuxdvb", "%s - read() error %d (%s)", - name, errno, strerror(errno)); + tvherror(LS_LINUXDVB, "%s - read() error %d (%s)", + name, errno, strerror(errno)); break; } @@ -1310,7 +1310,7 @@ linuxdvb2tvh ( const char *prefix, linuxdvb_tbl_t *tbl, int key, int defval ) return tbl->t; tbl++; } - tvhtrace("linuxdvb", "%s - linuxdvb2tvh failed %d", prefix, key); + tvhtrace(LS_LINUXDVB, "%s - linuxdvb2tvh failed %d", prefix, key); return defval; } #endif @@ -1323,7 +1323,7 @@ tvh2linuxdvb ( const char *prefix, linuxdvb_tbl_t *tbl, int key, int defval ) return tbl->l; tbl++; } - tvhtrace("linuxdvb", "%s - tvh2linuxdvb failed %d", prefix, key); + tvhtrace(LS_LINUXDVB, "%s - tvh2linuxdvb failed %d", prefix, key); return defval; } @@ -1380,11 +1380,11 @@ linuxdvb_frontend_clear /* Open FE */ lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1)); - tvhtrace("linuxdvb", "%s - frontend clear", buf1); + tvhtrace(LS_LINUXDVB, "%s - frontend clear", buf1); if (lfe->lfe_fe_fd <= 0) { lfe->lfe_fe_fd = tvh_open(lfe->lfe_fe_path, O_RDWR | O_NONBLOCK, 0); - tvhtrace("linuxdvb", "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd); + tvhtrace(LS_LINUXDVB, "%s - opening FE %s (%d)", buf1, lfe->lfe_fe_path, lfe->lfe_fe_fd); if (lfe->lfe_fe_fd <= 0) { return SM_CODE_TUNING_FAILED; } @@ -1402,7 +1402,7 @@ linuxdvb_frontend_clear .props = clear_p }; if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &clear_cmdseq)) != 0) { - tvherror("linuxdvb", "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno)); + tvherror(LS_LINUXDVB, "%s - DTV_CLEAR failed [e=%s]", buf1, strerror(errno)); return -1; } @@ -1418,7 +1418,7 @@ linuxdvb_frontend_clear delsys_p.cmd = DTV_DELIVERY_SYSTEM; delsys_p.u.data = TR(delsys, delsys_tbl, SYS_UNDEFINED); if ((ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &delsys_cmdseq)) != 0) { - tvherror("linuxdvb", "%s - DTV_DELIVERY_SYSTEM failed [e=%s]", buf1, strerror(errno)); + tvherror(LS_LINUXDVB, "%s - DTV_DELIVERY_SYSTEM failed [e=%s]", buf1, strerror(errno)); return -1; } } @@ -1573,7 +1573,7 @@ linuxdvb_frontend_tune0 if (tvhtrace_enabled()) { char buf2[256]; dvb_mux_conf_str(&lm->lm_tuning, buf2, sizeof(buf2)); - tvhtrace("linuxdvb", "tuner %s tunning to %s (freq %i)", buf1, buf2, freq); + tvhtrace(LS_LINUXDVB, "tuner %s tunning to %s (freq %i)", buf1, buf2, freq); } memset(&p, 0, sizeof(p)); p.frequency = dmc->dmc_fe_freq; @@ -1611,7 +1611,7 @@ linuxdvb_frontend_tune0 break; #endif default: - tvherror("linuxdvb", "%s - unknown FE type %d", buf1, dmc->dmc_fe_type); + tvherror(LS_LINUXDVB, "%s - unknown FE type %d", buf1, dmc->dmc_fe_type); return SM_CODE_TUNING_FAILED; } @@ -1619,7 +1619,7 @@ linuxdvb_frontend_tune0 p.frequency = lfe->lfe_freq = freq; if (dmc->dmc_fe_type != lfe->lfe_type) { - tvherror("linuxdvb", "%s - failed to tune [type does not match %i != %i]", buf1, dmc->dmc_fe_type, lfe->lfe_type); + tvherror(LS_LINUXDVB, "%s - failed to tune [type does not match %i != %i]", buf1, dmc->dmc_fe_type, lfe->lfe_type); return SM_CODE_TUNING_FAILED; } @@ -1758,7 +1758,7 @@ linuxdvb_frontend_tune0 if (tvhtrace_enabled()) { int i; for (i = 0; i < cmdseq.num; i++) - tvhtrace("linuxdvb", "S2CMD %02u => %u", cmds[i].cmd, cmds[i].u.data); + tvhtrace(LS_LINUXDVB, "S2CMD %02u => %u", cmds[i].cmd, cmds[i].u.data); } r = ioctl(lfe->lfe_fe_fd, FE_SET_PROPERTY, &cmdseq); @@ -1769,7 +1769,7 @@ linuxdvb_frontend_tune0 /* Failed */ if (r != 0) { - tvherror("linuxdvb", "%s - failed to tune [e=%s]", buf1, strerror(errno)); + tvherror(LS_LINUXDVB, "%s - failed to tune [e=%s]", buf1, strerror(errno)); if (errno == EINVAL) mmi->mmi_tune_failed = 1; return SM_CODE_TUNING_FAILED; @@ -1787,10 +1787,10 @@ linuxdvb_frontend_tune1 lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("linuxdvb", "%s - starting %s", buf1, buf2); + tvhdebug(LS_LINUXDVB, "%s - starting %s", buf1, buf2); /* Tune */ - tvhtrace("linuxdvb", "%s - tuning", buf1); + tvhtrace(LS_LINUXDVB, "%s - tuning", buf1); rep = lfe->lfe_tune_repeats > 0 ? lfe->lfe_tune_repeats : 0; for (i = 0; i <= rep; i++) { if (i > 0) @@ -1942,7 +1942,7 @@ linuxdvb_frontend_create else if (type == DVB_TYPE_DAB) idc = &linuxdvb_frontend_dab_class; else { - tvherror("linuxdvb", "unknown FE type %d", type); + tvherror(LS_LINUXDVB, "unknown FE type %d", type); return NULL; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c index df4f0b50b..84e22e502 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_rotor.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_rotor.c @@ -261,7 +261,7 @@ sat_angle( linuxdvb_rotor_t *lr, linuxdvb_satconf_ele_t *ls ) double azimuth, elevation; #ifndef ROTOR_TEST - tvhtrace("diseqc", "site: lat %.4f, lon %.4f, alt %.4f; sat lon %.4f", + tvhtrace(LS_DISEQC, "site: lat %.4f, lon %.4f, alt %.4f; sat lon %.4f", site_lat, site_lon, site_alt, sat_lon); #endif @@ -269,7 +269,7 @@ sat_angle( linuxdvb_rotor_t *lr, linuxdvb_satconf_ele_t *ls ) &azimuth, &elevation); #ifndef ROTOR_TEST - tvhtrace("diseqc", "rotor angle azimuth %.4f elevation %.4f", azimuth, elevation); + tvhtrace(LS_DISEQC, "rotor angle azimuth %.4f elevation %.4f", azimuth, elevation); #else gazimuth = azimuth; gelevation = elevation; @@ -366,7 +366,7 @@ linuxdvb_rotor_check_orbital_pos pos = -(pos); dir = 'W'; } - tvhdebug("diseqc", "rotor already positioned to %i.%i%c", + tvhdebug(LS_DISEQC, "rotor already positioned to %i.%i%c", pos / 10, pos % 10, dir); return 1; } @@ -381,13 +381,13 @@ linuxdvb_rotor_gotox_tune for (i = 0; i <= ls->lse_parent->ls_diseqc_repeats; i++) { if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6B, 1, (int)lr->lr_position)) { - tvherror("diseqc", "failed to set GOTOX pos %d", lr->lr_position); + tvherror(LS_DISEQC, "failed to set GOTOX pos %d", lr->lr_position); return -1; } tvh_safe_usleep(MINMAX(lr->lr_cmd_time, 10, 100) * 1000); } - tvhdebug("diseqc", "rotor GOTOX pos %d sent", lr->lr_position); + tvhdebug(LS_DISEQC, "rotor GOTOX pos %d sent", lr->lr_position); return linuxdvb_rotor_grace((linuxdvb_diseqc_t*)lr,lm); } @@ -410,14 +410,14 @@ linuxdvb_rotor_usals_tune } cmd |= (angle / 10) * 0x10 + xtable[angle % 10]; - tvhdebug("diseqc", "rotor USALS goto %0.1f%c (motor %0.1f %sclockwise)", + tvhdebug(LS_DISEQC, "rotor USALS goto %0.1f%c (motor %0.1f %sclockwise)", fabs(lr->lr_sat_lon), (lr->lr_sat_lon > 0.0) ? 'E' : 'W', ((double)angle / 10.0), (cmd & 0xF000) == 0xD000 ? "counter-" : ""); for (i = 0; i <= lsp->ls_diseqc_repeats; i++) { if (linuxdvb_diseqc_send(fd, 0xE0, 0x31, 0x6E, 2, (cmd >> 8) & 0xff, cmd & 0xff)) { - tvherror("diseqc", "failed to send USALS command"); + tvherror(LS_DISEQC, "failed to send USALS command"); return -1; } tvh_safe_usleep(MINMAX(lr->lr_cmd_time, 10, 100) * 1000); diff --git a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c index c32519b13..89df12fd8 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_satconf.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_satconf.c @@ -758,16 +758,16 @@ linuxdvb_satconf_start ( linuxdvb_satconf_t *ls, int delay, int vol ) return -1; if (ls->ls_last_tone_off != 1) { - tvhtrace("diseqc", "initial tone off"); + tvhtrace(LS_DISEQC, "initial tone off"); if (ioctl(linuxdvb_satconf_fe_fd(ls), FE_SET_TONE, SEC_TONE_OFF)) { - tvherror("diseqc", "failed to disable tone"); + tvherror(LS_DISEQC, "failed to disable tone"); return -1; } ls->ls_last_tone_off = 1; } /* the linuxdvb_diseqc_set_volt() fcn already sleeps for 15ms */ if (delay > 15) { - tvhtrace("diseqc", "initial sleep %dms", delay); + tvhtrace(LS_DISEQC, "initial sleep %dms", delay); tvh_safe_usleep((delay-15)*1000); } return 0; @@ -800,7 +800,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) band = lse->lse_lnb->lnb_band(lse->lse_lnb, lm) & 0x1; freq = lse->lse_lnb->lnb_freq(lse->lse_lnb, lm); } else { - tvherror("linuxdvb", "LNB is not defined!!!"); + tvherror(LS_LINUXDVB, "LNB is not defined!!!"); return -1; } if (!lse->lse_en50494) { @@ -834,7 +834,7 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) /* Pending */ if (r != 0) { - tvhtrace("diseqc", "waiting %d seconds to finish setup for %s", r, lds[i]->ld_type); + tvhtrace(LS_DISEQC, "waiting %d seconds to finish setup for %s", r, lds[i]->ld_type); mtimer_arm_rel(&ls->ls_diseqc_timer, linuxdvb_satconf_ele_tune_cb, lse, sec2mono(r)); ls->ls_diseqc_idx = i + 1; return 0; @@ -856,9 +856,9 @@ linuxdvb_satconf_ele_tune ( linuxdvb_satconf_ele_t *lse ) if (!lse->lse_en50494) { if (ls->ls_last_tone_off != band + 1) { ls->ls_last_tone_off = 0; - tvhtrace("diseqc", "set diseqc tone %s", band ? "on" : "off"); + tvhtrace(LS_DISEQC, "set diseqc tone %s", band ? "on" : "off"); if (ioctl(lfe->lfe_fe_fd, FE_SET_TONE, band ? SEC_TONE_ON : SEC_TONE_OFF)) { - tvherror("diseqc", "failed to set diseqc tone (e=%s)", strerror(errno)); + tvherror(LS_DISEQC, "failed to set diseqc tone (e=%s)", strerror(errno)); return -1; } ls->ls_last_tone_off = band + 1; @@ -900,7 +900,7 @@ linuxdvb_satconf_lnb_freq if (lse->lse_en50494) { f = lse->lse_en50494->ld_freq(lse->lse_en50494, lm, f); if (f < 0) { - tvherror("en50494", "invalid tuning freq"); + tvherror(LS_EN50494, "invalid tuning freq"); return -1; } } @@ -985,20 +985,20 @@ linuxdvb_satconf_match_mux char buf1[256], buf2[256]; dvb_mux_conf_str(&lm1->lm_tuning, buf1, sizeof(buf1)); dvb_mux_conf_str(&lm2->lm_tuning, buf2, sizeof(buf2)); - tvhtrace("diseqc", "match mux 1 - %s", buf1); - tvhtrace("diseqc", "match mux 2 - %s", buf2); + tvhtrace(LS_DISEQC, "match mux 1 - %s", buf1); + tvhtrace(LS_DISEQC, "match mux 2 - %s", buf2); #endif if (lse1 != lse2) { - tvhtrace("diseqc", "match position failed"); + tvhtrace(LS_DISEQC, "match position failed"); return 0; } if (!lse1->lse_lnb->lnb_match(lse1->lse_lnb, lm1, lm2)) { - tvhtrace("diseqc", "match LNB failed"); + tvhtrace(LS_DISEQC, "match LNB failed"); return 0; } if (lse1->lse_en50494 && !lse1->lse_en50494->ld_match(lse1->lse_en50494, lm1, lm2)) { - tvhtrace("diseqc", "match en50494 failed"); + tvhtrace(LS_DISEQC, "match en50494 failed"); return 0; } return 1; @@ -1562,12 +1562,12 @@ linuxdvb_diseqc_send va_end(ap); if (tr) - tvhtrace("diseqc", "sending diseqc (len %d) %02X %02X %02X %s", + tvhtrace(LS_DISEQC, "sending diseqc (len %d) %02X %02X %02X %s", len + 3, framing, addr, cmd, buf); /* Send */ if (ioctl(fd, FE_DISEQC_SEND_MASTER_CMD, &message)) { - tvherror("diseqc", "failed to send diseqc cmd (e=%s)", strerror(errno)); + tvherror(LS_DISEQC, "failed to send diseqc cmd (e=%s)", strerror(errno)); return -1; } return 0; @@ -1580,10 +1580,10 @@ linuxdvb_diseqc_set_volt ( linuxdvb_satconf_t *ls, int vol ) if (vol >= 0 && ls->ls_last_vol == vol + 1) return 0; /* Set voltage */ - tvhtrace("diseqc", "set voltage %dV", vol ? (vol < 0 ? 0 : 18) : 13); + tvhtrace(LS_DISEQC, "set voltage %dV", vol ? (vol < 0 ? 0 : 18) : 13); if (ioctl(linuxdvb_satconf_fe_fd(ls), FE_SET_VOLTAGE, vol ? (vol < 0 ? SEC_VOLTAGE_OFF : SEC_VOLTAGE_18) : SEC_VOLTAGE_13)) { - tvherror("diseqc", "failed to set voltage (e=%s)", strerror(errno)); + tvherror(LS_DISEQC, "failed to set voltage (e=%s)", strerror(errno)); ls->ls_last_vol = 0; return -1; } diff --git a/src/input/mpegts/linuxdvb/linuxdvb_switch.c b/src/input/mpegts/linuxdvb/linuxdvb_switch.c index abc9254ff..3043d69f3 100644 --- a/src/input/mpegts/linuxdvb/linuxdvb_switch.c +++ b/src/input/mpegts/linuxdvb/linuxdvb_switch.c @@ -239,10 +239,10 @@ linuxdvb_switch_tune return -1; lsp->ls_last_toneburst = 0; - tvhtrace("diseqc", "toneburst %s", ls->ls_toneburst ? "B" : "A"); + tvhtrace(LS_DISEQC, "toneburst %s", ls->ls_toneburst ? "B" : "A"); if (ioctl(fd, FE_DISEQC_SEND_BURST, ls->ls_toneburst ? SEC_MINI_B : SEC_MINI_A)) { - tvherror("diseqc", "failed to set toneburst (e=%s)", strerror(errno)); + tvherror(LS_DISEQC, "failed to set toneburst (e=%s)", strerror(errno)); return -1; } lsp->ls_last_toneburst = ls->ls_toneburst + 1; diff --git a/src/input/mpegts/mpegts_input.c b/src/input/mpegts/mpegts_input.c index 854b200a1..910044b37 100644 --- a/src/input/mpegts/mpegts_input.c +++ b/src/input/mpegts/mpegts_input.c @@ -509,13 +509,13 @@ mpegts_input_open_pid if (mps2 == NULL) { LIST_INSERT_HEAD(&mm->mm_all_subs, mps, mps_svcraw_link); mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhdebug("mpegts", "%s - open PID %s subscription [%04x/%p]", + tvhdebug(LS_MPEGTS, "%s - open PID %s subscription [%04x/%p]", buf, (type & MPS_TABLES) ? "tables" : "fullmux", type, owner); mm->mm_update_pids_flag = 1; } else { if (!reopen) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvherror("mpegts", + tvherror(LS_MPEGTS, "%s - open PID %04x (%d) failed, dupe sub (owner %p)", buf, mp->mp_pid, mp->mp_pid, owner); } @@ -529,13 +529,13 @@ mpegts_input_open_pid if (type & MPS_SERVICE) LIST_INSERT_HEAD(&mp->mp_svc_subs, mps, mps_svcraw_link); mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhdebug("mpegts", "%s - open PID %04X (%d) [%d/%p]", + tvhdebug(LS_MPEGTS, "%s - open PID %04X (%d) [%d/%p]", buf, mp->mp_pid, mp->mp_pid, type, owner); mm->mm_update_pids_flag = 1; } else { if (!reopen) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvherror("mpegts", "%s - open PID %04x (%d) failed, dupe sub (owner %p)", + tvherror(LS_MPEGTS, "%s - open PID %04x (%d) failed, dupe sub (owner %p)", buf, mp->mp_pid, mp->mp_pid, owner); } free(mps); @@ -562,7 +562,7 @@ mpegts_input_close_pid LIST_FOREACH(mps, &mm->mm_all_subs, mps_svcraw_link) if (mps->mps_owner == owner) break; if (mps == NULL) return -1; - tvhdebug("mpegts", "%s - close PID %s subscription [%04x/%p]", + tvhdebug(LS_MPEGTS, "%s - close PID %s subscription [%04x/%p]", buf, pid == MPEGTS_TABLES_PID ? "tables" : "fullmux", type, owner); if (pid == MPEGTS_FULLMUX_PID) @@ -585,7 +585,7 @@ mpegts_input_close_pid } if (mps) { mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhdebug("mpegts", "%s - close PID %04X (%d) [%d/%p]", + tvhdebug(LS_MPEGTS, "%s - close PID %04X (%d) [%d/%p]", buf, mp->mp_pid, mp->mp_pid, type, owner); if (type & MPS_RAW) LIST_REMOVE(mps, mps_raw_link); @@ -662,7 +662,7 @@ mpegts_input_cat_pass_callback if (len >= 4 && dlen >= 4 && mm->mm_active) { caid = ( ptr[0] << 8) | ptr[1]; pid = ((ptr[2] & 0x1f) << 8) | ptr[3]; - tvhdebug("cat", " pass: caid %04X (%d) pid %04X (%d)", + tvhdebug(LS_TBL_BASE, "cat: pass: caid %04X (%d) pid %04X (%d)", (uint16_t)caid, (uint16_t)caid, pid, pid); pthread_mutex_lock(&s->s_stream_mutex); es = NULL; @@ -750,13 +750,13 @@ mpegts_input_open_service if(s->s_type == STYPE_STD) { s->s_pmt_mon = mpegts_table_add(mm, DVB_PMT_BASE, DVB_PMT_MASK, - dvb_pmt_callback, s, "pmt", + dvb_pmt_callback, s, "pmt", LS_TBL_BASE, MT_CRC, s->s_pmt_pid, MPS_WEIGHT_PMT); if (s->s_scrambled_pass && (flags & SUBSCRIPTION_EMM) != 0) { s->s_cat_mon = mpegts_table_add(mm, DVB_CAT_BASE, DVB_CAT_MASK, mpegts_input_cat_pass_callback, s, "cat", - MT_QUICKREQ | MT_CRC, DVB_CAT_PID, + LS_TBL_BASE, MT_QUICKREQ | MT_CRC, DVB_CAT_PID, MPS_WEIGHT_CAT); } } @@ -906,7 +906,7 @@ mpegts_input_stopped_mux mtimer_disarm(&mi->mi_status_timer); mi->mi_display_name(mi, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - flush subscribers", buf); + tvhtrace(LS_MPEGTS, "%s - flush subscribers", buf); for (s = LIST_FIRST(&mm->mm_transports); s; s = s_next) { s_next = LIST_NEXT(s, s_active_link); service_remove_subscriber(s, NULL, SM_CODE_SUBSCRIPTION_OVERRIDDEN); @@ -1132,7 +1132,7 @@ retry: tvh_cond_signal(&mi->mi_input_cond, 0); } else { if (tvhlog_limit(&mi->mi_input_queue_loglimit, 10)) - tvhwarn("mpegts", "too much queued input data (over 50MB), discarding new"); + tvhwarn(LS_MPEGTS, "too much queued input data (over 50MB), discarding new"); free(mp); } } else { @@ -1174,7 +1174,7 @@ mpegts_input_table_dispatch } pthread_mutex_unlock(&mm->mm_tables_lock); if (i != c) { - tvherror("psi", "tables count inconsistency (num %d, list %d)", i, c); + tvherror(LS_TBL, "tables count inconsistency (num %d, list %d)", i, c); assert(0); } @@ -1336,7 +1336,7 @@ mpegts_input_process tsb2 < tsb2_end; tsb2 += 188) { cc = tsb2[3] & 0x0f; if (cc2 != 0xff && cc2 != cc) { - tvhtrace("mpegts", "%s: pid %04X cc err %2d != %2d", muxname, pid, cc, cc2); + tvhtrace(LS_MPEGTS, "%s: pid %04X cc err %2d != %2d", muxname, pid, cc, cc2); atomic_add(&mmi->tii_stats.cc, 1); } cc2 = (cc + 1) & 0xF; @@ -1384,7 +1384,7 @@ mpegts_input_process if (type & MPS_TABLE) { if (mi->mi_table_queue_size >= 2*1024*1024) { if (tvhlog_limit(&mi->mi_input_queue_loglimit, 10)) - tvhwarn("mpegts", "too much queued table input data (over 2MB), discarding new"); + tvhwarn(LS_MPEGTS, "too much queued table input data (over 2MB), discarding new"); } else { mpegts_table_feed_t *mtf = malloc(sizeof(mpegts_table_feed_t)+llen); mtf->mtf_len = llen; @@ -1483,7 +1483,7 @@ mpegts_input_thread ( void * p ) /* Wait for a packet */ if (!(mp = TAILQ_FIRST(&mi->mi_input_queue))) { if (bytes) { - tvhtrace("mpegts", "input %s got %zu bytes", buf, bytes); + tvhtrace(LS_MPEGTS, "input %s got %zu bytes", buf, bytes); bytes = 0; } tvh_cond_wait(&mi->mi_input_cond, &mi->mi_input_lock); @@ -1528,7 +1528,7 @@ mpegts_input_thread ( void * p ) pthread_mutex_lock(&mi->mi_input_lock); } - tvhtrace("mpegts", "input %s got %zu bytes (finish)", buf, bytes); + tvhtrace(LS_MPEGTS, "input %s got %zu bytes (finish)", buf, bytes); /* Flush */ while ((mp = TAILQ_FIRST(&mi->mi_input_queue))) { @@ -1816,7 +1816,7 @@ mpegts_input_create0 { if (idnode_insert(&mi->ti_id, uuid, class, 0)) { if (uuid) - tvherror("mpegts", "invalid input uuid '%s'", uuid); + tvherror(LS_MPEGTS, "invalid input uuid '%s'", uuid); free(mi); return NULL; } diff --git a/src/input/mpegts/mpegts_mux.c b/src/input/mpegts/mpegts_mux.c index b155c77e9..e593fde3b 100644 --- a/src/input/mpegts/mpegts_mux.c +++ b/src/input/mpegts/mpegts_mux.c @@ -140,7 +140,7 @@ mpegts_mux_subscribe_keep s = mi->mi_linked; mi->mi_linked = NULL; - tvhtrace("mpegts", "subscribe keep for '%s' (%p)", mi->mi_name, mm); + tvhtrace(LS_MPEGTS, "subscribe keep for '%s' (%p)", mi->mi_name, mm); r = mpegts_mux_subscribe(mm, mi, "keep", SUBSCRIPTION_PRIO_KEEP, SUBSCRIPTION_ONESHOT | SUBSCRIPTION_MINIMAL); mi->mi_linked = s; @@ -159,7 +159,7 @@ mpegts_mux_subscribe_linked const char *serr = "All"; int r = 0; - tvhtrace("mpegts", "subscribe linked"); + tvhtrace(LS_MPEGTS, "subscribe linked"); if (!mpegts_mux_keep_exists(mi) && (r = mpegts_mux_subscribe_keep(mm, mi))) { serr = "active1"; @@ -201,7 +201,7 @@ mpegts_mux_subscribe_linked fatal: mi ->mi_display_name(mi, buf1, sizeof(buf1)); mi2->mi_display_name(mi2, buf2, sizeof(buf2)); - tvherror("mpegts", "%s - %s - linked input cannot be started (%s: %i)", buf1, buf2, serr, r); + tvherror(LS_MPEGTS, "%s - %s - linked input cannot be started (%s: %i)", buf1, buf2, serr, r); } void @@ -211,7 +211,7 @@ mpegts_mux_unsubscribe_linked th_subscription_t *ths, *ths_next; if (mi) { - tvhtrace("mpegts", "unsubscribing linked"); + tvhtrace(LS_MPEGTS, "unsubscribing linked"); for (ths = LIST_FIRST(&subscriptions); ths; ths = ths_next) { ths_next = LIST_NEXT(ths, ths_global_link); @@ -237,7 +237,7 @@ mpegts_mux_instance_start /* Already active */ if (mm->mm_active) { *mmiptr = mm->mm_active; - tvhdebug("mpegts", "%s - already active", buf); + tvhdebug(LS_MPEGTS, "%s - already active", buf); mpegts_mux_scan_active(mm, buf, (*mmiptr)->mmi_input); return 0; } @@ -250,7 +250,7 @@ mpegts_mux_instance_start /* Start */ mi->mi_display_name(mi, buf2, sizeof(buf2)); - tvhinfo("mpegts", "%s - tuning on %s", buf, buf2); + tvhinfo(LS_MPEGTS, "%s - tuning on %s", buf, buf2); if (mi->mi_linked) mpegts_mux_unsubscribe_linked(mi, t); @@ -261,7 +261,7 @@ mpegts_mux_instance_start if (r) return r; /* Start */ - tvhdebug("mpegts", "%s - started", buf); + tvhdebug(LS_MPEGTS, "%s - started", buf); mi->mi_started_mux(mi, mmi); /* Event handler */ @@ -738,7 +738,7 @@ mpegts_mux_delete ( mpegts_mux_t *mm, int delconf ) idnode_save_check(&mm->mm_id, delconf); mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhinfo("mpegts", "%s (%p) - deleting", buf, mm); + tvhinfo(LS_MPEGTS, "%s (%p) - deleting", buf, mm); /* Stop */ mm->mm_stop(mm, 1, SM_CODE_ABORTED); @@ -784,7 +784,7 @@ mpegts_mux_has_subscribers ( mpegts_mux_t *mm, const char *name ) mpegts_mux_instance_t *mmi = mm->mm_active; if (mmi) { if (mmi->mmi_input->mi_has_subscription(mmi->mmi_input, mm)) { - tvhtrace("mpegts", "%s - keeping mux", name); + tvhtrace(LS_MPEGTS, "%s - keeping mux", name); return 1; } } @@ -808,7 +808,7 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force, int reason ) /* Stop possible recursion */ if (!mmi) return; - tvhdebug("mpegts", "%s - stopping mux%s", buf, force ? " (forced)" : ""); + tvhdebug(LS_MPEGTS, "%s - stopping mux%s", buf, force ? " (forced)" : ""); mi = mmi->mmi_input; assert(mi); @@ -825,7 +825,7 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force, int reason ) mi2->mi_linked = s; } else { if (!force) { - tvhtrace("mpegts", "%s - keeping subscribed (linked tuner active)", buf); + tvhtrace(LS_MPEGTS, "%s - keeping subscribed (linked tuner active)", buf); return; } } @@ -842,10 +842,10 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force, int reason ) assert(mm->mm_active == NULL); /* Flush all tables */ - tvhtrace("mpegts", "%s - flush tables", buf); + tvhtrace(LS_MPEGTS, "%s - flush tables", buf); mpegts_table_flush_all(mm); - tvhtrace("mpegts", "%s - mi=%p", buf, (void *)mi); + tvhtrace(LS_MPEGTS, "%s - mi=%p", buf, (void *)mi); /* Flush table data queue */ mpegts_input_flush_mux(mi, mm); @@ -858,7 +858,7 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force, int reason ) if (mp->mp_pid == MPEGTS_FULLMUX_PID || mp->mp_pid == MPEGTS_TABLES_PID) { while ((mps = LIST_FIRST(&mm->mm_all_subs))) { - tvhdebug("mpegts", "%s - close PID %s subscription [%d/%p]", + tvhdebug(LS_MPEGTS, "%s - close PID %s subscription [%d/%p]", buf, mp->mp_pid == MPEGTS_TABLES_PID ? "tables" : "fullmux", mps->mps_type, mps->mps_owner); LIST_REMOVE(mps, mps_svcraw_link); @@ -866,7 +866,7 @@ mpegts_mux_stop ( mpegts_mux_t *mm, int force, int reason ) } } else { while ((mps = RB_FIRST(&mp->mp_subs))) { - tvhdebug("mpegts", "%s - close PID %04X (%d) [%d/%p]", buf, + tvhdebug(LS_MPEGTS, "%s - close PID %04X (%d) [%d/%p]", buf, mp->mp_pid, mp->mp_pid, mps->mps_type, mps->mps_owner); RB_REMOVE(&mp->mp_subs, mps, mps_link); if (mps->mps_type & (MPS_SERVICE|MPS_ALL)) @@ -1044,7 +1044,7 @@ mpegts_mux_scan_service_check ( mpegts_mux_t *mm ) snext = LIST_NEXT(s, s_dvb_mux_link); if (s->s_enabled && s->s_auto != SERVICE_AUTO_OFF && s->s_dvb_check_seen + 24 * 3600 < last_seen) { - tvhinfo("mpegts", "disabling service %s [sid %04X/%d] (missing in PAT/SDT)", + tvhinfo(LS_MPEGTS, "disabling service %s [sid %04X/%d] (missing in PAT/SDT)", s->s_nicename ?: "", s->s_dvb_service_id, s->s_dvb_service_id); service_set_enabled((service_t *)s, 0, SERVICE_AUTO_PAT_MISSING); } @@ -1073,7 +1073,7 @@ mpegts_mux_scan_done ( mpegts_mux_t *mm, const char *buf, int res ) total++; incomplete++; } - tvhdebug("mpegts", "%s - %04X (%d) %s %s", buf, mt->mt_pid, mt->mt_pid, mt->mt_name, s); + tvhdebug(LS_MPEGTS, "%s - %04X (%d) %s %s", buf, mt->mt_pid, mt->mt_pid, mt->mt_name, s); } } pthread_mutex_unlock(&mm->mm_tables_lock); @@ -1085,18 +1085,18 @@ mpegts_mux_scan_done ( mpegts_mux_t *mm, const char *buf, int res ) if (res < 0) { /* is threshold 3 missing tables enough? */ if (incomplete > 0 && total > incomplete && incomplete <= 3) { - tvhinfo("mpegts", "%s - scan complete (partial - %d/%d tables)", buf, total, incomplete); + tvhinfo(LS_MPEGTS, "%s - scan complete (partial - %d/%d tables)", buf, total, incomplete); mpegts_network_scan_mux_partial(mm); } else { - tvhwarn("mpegts", "%s - scan timed out (%d/%d tables)", buf, total, incomplete); + tvhwarn(LS_MPEGTS, "%s - scan timed out (%d/%d tables)", buf, total, incomplete); mpegts_network_scan_mux_fail(mm); } } else if (res) { - tvhinfo("mpegts", "%s scan complete", buf); + tvhinfo(LS_MPEGTS, "%s scan complete", buf); mpegts_network_scan_mux_done(mm); mpegts_mux_scan_service_check(mm); } else { - tvhinfo("mpegts", "%s - scan no data, failed", buf); + tvhinfo(LS_MPEGTS, "%s - scan no data, failed", buf); mpegts_network_scan_mux_fail(mm); } } @@ -1146,7 +1146,7 @@ again: /* Pending tables (another 20s or 30s - bit arbitrary) */ } else if (q) { - tvhtrace("mpegts", "%s - scan needs more time", buf); + tvhtrace(LS_MPEGTS, "%s - scan needs more time", buf); mtimer_arm_rel(&mm->mm_scan_timeout, mpegts_mux_scan_timeout, mm, sec2mono(w ? 30 : 20)); return; @@ -1169,7 +1169,7 @@ mpegts_mux_create0 if (idnode_insert(&mm->mm_id, uuid, class, 0)) { if (uuid) - tvherror("mpegts", "invalid mux uuid '%s'", uuid); + tvherror(LS_MPEGTS, "invalid mux uuid '%s'", uuid); free(mm); return NULL; } @@ -1230,7 +1230,7 @@ mpegts_mux_create0 SUBSCRIPTION_IDLESCAN, 10); mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - created", buf); + tvhtrace(LS_MPEGTS, "%s - created", buf); return mm; } @@ -1273,7 +1273,7 @@ mpegts_mux_set_onid ( mpegts_mux_t *mm, uint16_t onid ) if (tvhtrace_enabled()) { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - set onid %04X (%d)", buf, onid, onid); + tvhtrace(LS_MPEGTS, "%s - set onid %04X (%d)", buf, onid, onid); } idnode_changed(&mm->mm_id); return 1; @@ -1290,7 +1290,7 @@ mpegts_mux_set_tsid ( mpegts_mux_t *mm, uint16_t tsid, int force ) if (tvhtrace_enabled()) { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - set tsid %04X (%d)", buf, tsid, tsid); + tvhtrace(LS_MPEGTS, "%s - set tsid %04X (%d)", buf, tsid, tsid); } idnode_changed(&mm->mm_id); return 1; @@ -1305,7 +1305,7 @@ mpegts_mux_set_crid_authority ( mpegts_mux_t *mm, const char *defauth ) if (tvhtrace_enabled()) { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - set crid authority %s", buf, defauth); + tvhtrace(LS_MPEGTS, "%s - set crid authority %s", buf, defauth); } idnode_changed(&mm->mm_id); return 1; @@ -1348,7 +1348,7 @@ mpegts_mux_remove_subscriber if (tvhtrace_enabled()) { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhtrace("mpegts", "%s - remove subscriber (reason %i)", buf, reason); + tvhtrace(LS_MPEGTS, "%s - remove subscriber (reason %i)", buf, reason); } mm->mm_stop(mm, 0, reason); } diff --git a/src/input/mpegts/mpegts_mux_dvb.c b/src/input/mpegts/mpegts_mux_dvb.c index 9c452a855..203a53af0 100644 --- a/src/input/mpegts/mpegts_mux_dvb.c +++ b/src/input/mpegts/mpegts_mux_dvb.c @@ -1013,7 +1013,7 @@ dvb_mux_create0 idc = &dvb_mux_dab_class; delsys = DVB_SYS_DAB; } else { - tvherror("dvb", "unknown FE type %d", ln->ln_type); + tvherror(LS_DVB, "unknown FE type %d", ln->ln_type); return NULL; } diff --git a/src/input/mpegts/mpegts_mux_sched.c b/src/input/mpegts/mpegts_mux_sched.c index 3f65e5459..83e594e55 100644 --- a/src/input/mpegts/mpegts_mux_sched.c +++ b/src/input/mpegts/mpegts_mux_sched.c @@ -113,7 +113,7 @@ mpegts_mux_sched_class_cron_set ( void *p, const void *v ) mms->mms_cronstr = strdup(str); return 1; } else { - tvhwarn("muxsched", "invalid cronjob spec (%s)", str); + tvhwarn(LS_MUXSCHED, "invalid cronjob spec (%s)", str); } } return 0; @@ -211,7 +211,7 @@ mpegts_mux_sched_timer ( void *p ) /* Find mux */ if (!(mm = mpegts_mux_find(mms->mms_mux))) { - tvhdebug("muxsched", "mux has been removed, delete sched entry"); + tvhdebug(LS_MUXSCHED, "mux has been removed, delete sched entry"); mpegts_mux_sched_delete(mms, 1); return; } @@ -257,7 +257,7 @@ mpegts_mux_sched_timer ( void *p ) /* Find next */ if (cron_next(&mms->mms_cronjob, now, &nxt)) { - tvherror("muxsched", "failed to find next event"); + tvherror(LS_MUXSCHED, "failed to find next event"); return; } @@ -276,7 +276,7 @@ mpegts_mux_sched_create ( const char *uuid, htsmsg_t *conf ) mpegts_mux_sched_t *mms; if (!(mms = calloc(1, sizeof(mpegts_mux_sched_t)))) { - tvherror("muxsched", "calloc() failed"); + tvherror(LS_MUXSCHED, "calloc() failed"); assert(0); return NULL; } @@ -284,7 +284,7 @@ mpegts_mux_sched_create ( const char *uuid, htsmsg_t *conf ) /* Insert node */ if (idnode_insert(&mms->mms_id, uuid, &mpegts_mux_sched_class, 0)) { if (uuid) - tvherror("muxsched", "invalid uuid '%s'", uuid); + tvherror(LS_MUXSCHED, "invalid uuid '%s'", uuid); free(mms); return NULL; } diff --git a/src/input/mpegts/mpegts_network.c b/src/input/mpegts/mpegts_network.c index 0e8373f5c..92198db3f 100644 --- a/src/input/mpegts/mpegts_network.c +++ b/src/input/mpegts/mpegts_network.c @@ -415,7 +415,7 @@ mpegts_network_create0 /* Setup idnode */ if (idnode_insert(&mn->mn_id, uuid, idc, 0)) { if (uuid) - tvherror("mpegts", "invalid network uuid '%s'", uuid); + tvherror(LS_MPEGTS, "invalid network uuid '%s'", uuid); free(mn); return NULL; } @@ -449,7 +449,7 @@ mpegts_network_create0 /* Name */ if (netname) mn->mn_network_name = strdup(netname); mn->mn_display_name(mn, buf, sizeof(buf)); - tvhtrace("mpegts", "created network %s", buf); + tvhtrace(LS_MPEGTS, "created network %s", buf); return mn; } @@ -475,7 +475,7 @@ mpegts_network_set_nid return 0; mn->mn_nid = nid; mn->mn_display_name(mn, buf, sizeof(buf)); - tvhdebug("mpegts", "%s - set nid %04X (%d)", buf, nid, nid); + tvhdebug(LS_MPEGTS, "%s - set nid %04X (%d)", buf, nid, nid); return 1; } @@ -489,7 +489,7 @@ mpegts_network_set_network_name if (name && name[0] && strcmp(name, mn->mn_network_name ?: "")) { tvh_str_update(&mn->mn_network_name, name); mn->mn_display_name(mn, buf, sizeof(buf)); - tvhdebug("mpegts", "%s - set name %s", buf, name); + tvhdebug(LS_MPEGTS, "%s - set name %s", buf, name); save = 1; } } diff --git a/src/input/mpegts/mpegts_network_dvb.c b/src/input/mpegts/mpegts_network_dvb.c index d15c3aa72..b8239ed66 100644 --- a/src/input/mpegts/mpegts_network_dvb.c +++ b/src/input/mpegts/mpegts_network_dvb.c @@ -88,15 +88,15 @@ dvb_network_scanfile_set ( dvb_network_t *ln, const char *id ) if (tvhtrace_enabled()) { char buf[128]; dvb_mux_conf_str(dmc, buf, sizeof(buf)); - tvhtrace("scanfile", "mux %p %s added to network %s", mm, buf, ln->mn_network_name); + tvhtrace(LS_SCANFILE, "mux %p %s added to network %s", mm, buf, ln->mn_network_name); } } else { if (tvhtrace_enabled()) { char buf[128]; dvb_mux_conf_str(dmc, buf, sizeof(buf)); - tvhtrace("scanfile", "mux %p skipped %s in network %s", mm, buf, ln->mn_network_name); + tvhtrace(LS_SCANFILE, "mux %p skipped %s in network %s", mm, buf, ln->mn_network_name); dvb_mux_conf_str(&((dvb_mux_t *)mm)->lm_tuning, buf, sizeof(buf)); - tvhtrace("scanfile", "mux %p exists %s in network %s", mm, buf, ln->mn_network_name); + tvhtrace(LS_SCANFILE, "mux %p exists %s in network %s", mm, buf, ln->mn_network_name); } } } @@ -682,7 +682,7 @@ dvb_network_create_mux if (tvhtrace_enabled()) { char buf[128]; dvb_mux_conf_str(&((dvb_mux_t *)mm)->lm_tuning, buf, sizeof(buf)); - tvhtrace("mpegts", "mux %p %s onid %i tsid %i added to network %s (autodiscovery)", + tvhtrace(LS_MPEGTS, "mux %p %s onid %i tsid %i added to network %s (autodiscovery)", mm, buf, onid, tsid, mm->mm_network->mn_network_name); } } @@ -698,21 +698,21 @@ dvb_network_create_mux #define COMPARE(x, cbit) ({ \ int xr = dmc->x != lm->lm_tuning.x; \ if (xr) { \ - tvhtrace("mpegts", "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ + tvhtrace(LS_MPEGTS, "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ " (%li)", (long)dmc->x, (long)tuning_new.x); \ tuning_new.x = dmc->x; \ } xr ? cbit : 0; }) #define COMPAREN(x, cbit) ({ \ int xr = dmc->x != 0 && dmc->x != 1 && dmc->x != tuning_new.x; \ if (xr) { \ - tvhtrace("mpegts", "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ + tvhtrace(LS_MPEGTS, "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ " (%li)", (long)dmc->x, (long)tuning_new.x); \ tuning_new.x = dmc->x; \ } xr ? cbit : 0; }) #define COMPAREN0(x, cbit) ({ \ int xr = dmc->x != 1 && dmc->x != tuning_new.x; \ if (xr) { \ - tvhtrace("mpegts", "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ + tvhtrace(LS_MPEGTS, "create mux dmc->" #x " (%li) != lm->lm_tuning." #x \ " (%li)", (long)dmc->x, (long)tuning_new.x); \ tuning_new.x = dmc->x; \ } xr ? cbit : 0; }) @@ -769,11 +769,11 @@ dvb_network_create_mux char muxname[128]; mpegts_mux_nice_name((mpegts_mux_t *)mm, muxname, sizeof(muxname)); dvb_mux_conf_str(&tuning_old, buf, sizeof(buf)); - tvhlog(change ? LOG_WARNING : LOG_NOTICE, "mpegts", + tvhlog(change ? LOG_WARNING : LOG_NOTICE, LS_MPEGTS, "mux %s%s %s (%08x)", muxname, change ? " changed from" : " old params", buf, save); dvb_mux_conf_str(&tuning_new, buf, sizeof(buf)); - tvhlog(change ? LOG_WARNING : LOG_NOTICE, "mpegts", + tvhlog(change ? LOG_WARNING : LOG_NOTICE, LS_MPEGTS, "mux %s%s %s (%08x)", muxname, change ? " changed to " : " new params", buf, save); if (!change) save = 0; @@ -1020,7 +1020,7 @@ int dvb_network_get_orbital_pos(mpegts_network_t *mn) return INT_MAX; if (tvhtrace_enabled()) { if (!idnode_is_instance(&mn->mn_id, &dvb_network_dvbs_class)) { - tvhinfo("mpegts", "wrong dvb_network_get_orbital_pos() call"); + tvhinfo(LS_MPEGTS, "wrong dvb_network_get_orbital_pos() call"); return INT_MAX; } } diff --git a/src/input/mpegts/mpegts_network_scan.c b/src/input/mpegts/mpegts_network_scan.c index 870515b9a..45f8ef21b 100644 --- a/src/input/mpegts/mpegts_network_scan.c +++ b/src/input/mpegts/mpegts_network_scan.c @@ -206,7 +206,7 @@ mpegts_network_scan_queue_del ( mpegts_mux_t *mm ) } mpegts_mux_nice_name(mm, buf, sizeof(buf)); mn->mn_display_name(mn, buf2, sizeof(buf2)); - tvhdebug("mpegts", "%s - removing mux %s from scan queue", buf2, buf); + tvhdebug(LS_MPEGTS, "%s - removing mux %s from scan queue", buf2, buf); mm->mm_scan_state = MM_SCAN_STATE_IDLE; mm->mm_scan_weight = 0; mtimer_disarm(&mm->mm_scan_timeout); @@ -244,7 +244,7 @@ mpegts_network_scan_queue_add mpegts_mux_nice_name(mm, buf, sizeof(buf)); mn->mn_display_name(mn, buf2, sizeof(buf2)); - tvhdebug("mpegts", "%s - adding mux %s to scan queue weight %d flags %04X", + tvhdebug(LS_MPEGTS, "%s - adding mux %s to scan queue weight %d flags %04X", buf2, buf, weight, flags); /* Add new entry */ @@ -373,11 +373,11 @@ tsid_lookup: { char buf[256]; mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhinfo("mpegts", "fastscan mux found '%s', set scan state 'PENDING'", buf); + tvhinfo(LS_MPEGTS, "fastscan mux found '%s', set scan state 'PENDING'", buf); mpegts_mux_scan_state_set(mm, MM_SCAN_STATE_PEND); return; } - tvhinfo("mpegts", "fastscan mux not found, position:%i, frequency:%i, polarisation:%c", satpos, freq, pol[0]); + tvhinfo(LS_MPEGTS, "fastscan mux not found, position:%i, frequency:%i, polarisation:%c", satpos, freq, pol[0]); // fastscan mux not found, try to add it automatically LIST_FOREACH(mn, &mpegts_network_all, mn_global_link) @@ -405,7 +405,7 @@ tsid_lookup: char buf[256]; idnode_changed(&mm->mm_id); mn->mn_display_name(mn, buf, sizeof(buf)); - tvhinfo("mpegts", "fastscan mux add to network '%s'", buf); + tvhinfo(LS_MPEGTS, "fastscan mux add to network '%s'", buf); } free(mux); } diff --git a/src/input/mpegts/mpegts_service.c b/src/input/mpegts/mpegts_service.c index cc9ec324c..d03198e52 100644 --- a/src/input/mpegts/mpegts_service.c +++ b/src/input/mpegts/mpegts_service.c @@ -788,7 +788,7 @@ mpegts_service_create0 pthread_mutex_unlock(&s->s_stream_mutex); mpegts_mux_nice_name(mm, buf, sizeof(buf)); - tvhlog(LOG_DEBUG, "mpegts", "%s - add service %04X %s", buf, s->s_dvb_service_id, s->s_dvb_svcname); + tvhdebug(LS_MPEGTS, "%s - add service %04X %s", buf, s->s_dvb_service_id, s->s_dvb_svcname); /* Notification */ idnode_notify_changed(&mm->mm_id); @@ -1059,7 +1059,7 @@ mpegts_service_create_raw ( mpegts_mux_t *mm ) s->s_nicename = strdup(buf); pthread_mutex_unlock(&s->s_stream_mutex); - tvhlog(LOG_DEBUG, "mpegts", "%s - add raw service", buf); + tvhdebug(LS_MPEGTS, "%s - add raw service", buf); return s; } diff --git a/src/input/mpegts/mpegts_table.c b/src/input/mpegts/mpegts_table.c index f40f82665..6db50e695 100644 --- a/src/input/mpegts/mpegts_table.c +++ b/src/input/mpegts/mpegts_table.c @@ -39,7 +39,7 @@ mpegts_table_consistency_check ( mpegts_mux_t *mm ) c++; if (i != c) { - tvherror("mpegts", "table: mux %p count inconsistency (num %d, list %d)", mm, i, c); + tvherror(LS_MPEGTS, "table: mux %p count inconsistency (num %d, list %d)", mm, i, c); abort(); } } @@ -116,7 +116,7 @@ void mpegts_table_release_ ( mpegts_table_t *mt ) { dvb_table_release((mpegts_psi_table_t *)mt); - tvhtrace("mpegts", "table: mux %p free %s %02X/%02X (%d) pid %04X (%d)", + tvhtrace(LS_MPEGTS, "table: mux %p free %s %02X/%02X (%d) pid %04X (%d)", mt->mt_mux, mt->mt_name, mt->mt_table, mt->mt_mask, mt->mt_table, mt->mt_pid, mt->mt_pid); if (mt->mt_bat) @@ -138,7 +138,7 @@ mpegts_table_destroy_ ( mpegts_table_t *mt ) lock_assert(&mm->mm_tables_lock); - tvhtrace("mpegts", "table: mux %p destroy %s %02X/%02X (%d) pid %04X (%d)", + tvhtrace(LS_MPEGTS, "table: mux %p destroy %s %02X/%02X (%d) pid %04X (%d)", mm, mt->mt_name, mt->mt_table, mt->mt_mask, mt->mt_table, mt->mt_pid, mt->mt_pid); mpegts_table_consistency_check(mm); @@ -180,7 +180,7 @@ mpegts_table_t * mpegts_table_add ( mpegts_mux_t *mm, int tableid, int mask, mpegts_table_callback_t callback, void *opaque, - const char *name, int flags, int pid, int weight ) + const char *name, int subsys, int flags, int pid, int weight ) { mpegts_table_t *mt; int subscribe = 1; @@ -216,13 +216,14 @@ mpegts_table_add pthread_mutex_unlock(&mm->mm_tables_lock); return mt; } - tvhtrace("mpegts", "table: mux %p add %s %02X/%02X (%d) pid %04X (%d)", + tvhtrace(LS_MPEGTS, "table: mux %p add %s %02X/%02X (%d) pid %04X (%d)", mm, name, tableid, mask, tableid, pid, pid); /* Create */ mt = calloc(1, sizeof(mpegts_table_t)); mt->mt_arefcount = 1; mt->mt_name = strdup(name); + mt->mt_subsys = subsys; mt->mt_callback = callback; mt->mt_opaque = opaque; mt->mt_pid = pid; diff --git a/src/input/mpegts/satip/satip.c b/src/input/mpegts/satip/satip.c index f7cb1da17..6f4492317 100644 --- a/src/input/mpegts/satip/satip.c +++ b/src/input/mpegts/satip/satip.c @@ -77,7 +77,7 @@ satip_device_block( const char *addr, int block ) TAILQ_FOREACH(lfe, &sd->sd_frontends, sf_link) mpegts_input_stop_all((mpegts_input_t *)lfe); } - tvhinfo("satip", "address %s is %s", addr, + tvhinfo(LS_SATIP, "address %s is %s", addr, block < 0 ? "stopped" : (block > 0 ? "allowed" : "disabled")); } } @@ -531,8 +531,8 @@ satip_device_hack( satip_device_t *sd ) sd->sd_fullmux_ok = 0; sd->sd_pids_max = 32; sd->sd_pids_deladd = 0; - tvhwarn("satip", "Detected old Inverto firmware V1.13.0.105 and less"); - tvhwarn("satip", "Upgrade to V1.16.0.120 - http://http://www.inverto.tv/support/ - IDL400s"); + tvhwarn(LS_SATIP, "Detected old Inverto firmware V1.13.0.105 and less"); + tvhwarn(LS_SATIP, "Upgrade to V1.16.0.120 - http://http://www.inverto.tv/support/ - IDL400s"); } else #endif if (strstr(sd->sd_info.location, ":8888/octonet.xml")) { @@ -668,11 +668,11 @@ satip_device_create( satip_device_info_t *info ) m = atoi(argv[i] + 6); } if (type == DVB_TYPE_NONE) { - tvhlog(LOG_ERR, "satip", "%s: bad tuner type [%s]", - satip_device_nicename(sd, buf2, sizeof(buf2)), argv[i]); + tvherror(LS_SATIP, "%s: bad tuner type [%s]", + satip_device_nicename(sd, buf2, sizeof(buf2)), argv[i]); } else if (m < 0 || m > 32) { - tvhlog(LOG_ERR, "satip", "%s: bad tuner count [%s]", - satip_device_nicename(sd, buf2, sizeof(buf2)), argv[i]); + tvherror(LS_SATIP, "%s: bad tuner count [%s]", + satip_device_nicename(sd, buf2, sizeof(buf2)), argv[i]); } else { sd->sd_nosave = 1; for (j = 0; j < m; j++) @@ -865,13 +865,13 @@ satip_discovery_http_closed(http_client_t *hc, int errn) } if (errn != 0 || s == NULL || hc->hc_code != 200 || hc->hc_data_size == 0 || hc->hc_data == NULL) { - tvhlog(LOG_ERR, "satip", "Cannot get %s: %s", d->location, strerror(errn)); + tvherror(LS_SATIP, "Cannot get %s: %s", d->location, strerror(errn)); return; } if (tvhtrace_enabled()) { - tvhtrace("satip", "received XML description from %s", hc->hc_host); - tvhlog_hexdump("satip", hc->hc_data, hc->hc_data_size); + tvhtrace(LS_SATIP, "received XML description from %s", hc->hc_host); + tvhlog_hexdump(LS_SATIP, hc->hc_data, hc->hc_data_size); } if (d->myaddr == NULL || d->myaddr[0] == '\0') { @@ -895,7 +895,7 @@ satip_discovery_http_closed(http_client_t *hc, int errn) xml = htsmsg_xml_deserialize(hc->hc_data, errbuf, sizeof(errbuf)); hc->hc_data = NULL; if (!xml) { - tvhlog(LOG_ERR, "satip_discovery_desc", "htsmsg_xml_deserialize error %s", errbuf); + tvherror(LS_SATIP, "satip_discovery_desc htsmsg_xml_deserialize error %s", errbuf); goto finish; } if ((tags = htsmsg_get_map(xml, "tags")) == NULL) diff --git a/src/input/mpegts/satip/satip_frontend.c b/src/input/mpegts/satip/satip_frontend.c index 7bcb76cd0..17070f113 100644 --- a/src/input/mpegts/satip/satip_frontend.c +++ b/src/input/mpegts/satip/satip_frontend.c @@ -558,7 +558,7 @@ satip_frontend_stop_mux mi->mi_display_name(mi, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("satip", "%s - stopping %s", buf1, buf2); + tvhdebug(LS_SATIP, "%s - stopping %s", buf1, buf2); mtimer_disarm(&lfe->sf_monitor_timer); @@ -616,7 +616,7 @@ satip_frontend_start_mux lfe->mi_display_name((mpegts_input_t*)lfe, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("satip", "%s - starting %s", buf1, buf2); + tvhdebug(LS_SATIP, "%s - starting %s", buf1, buf2); if (!lfe->sf_device->sd_no_univ_lnb && (lm->lm_tuning.dmc_fe_delsys == DVB_SYS_DVBS || @@ -624,7 +624,7 @@ satip_frontend_start_mux /* Note: assume universal LNB */ if (lm->lm_tuning.dmc_fe_freq < 10700000 || lm->lm_tuning.dmc_fe_freq > 12750000) { - tvhwarn("satip", "DVB-S/S2 frequency %d out of range universal LNB", lm->lm_tuning.dmc_fe_freq); + tvhwarn(LS_SATIP, "DVB-S/S2 frequency %d out of range universal LNB", lm->lm_tuning.dmc_fe_freq); return SM_CODE_TUNING_FAILED; } } @@ -803,7 +803,7 @@ satip_frontend_decode_rtcp( satip_frontend_t *lfe, const char *name, if (sl > 0 && l - 16 >= sl) { rtcp[sl + 16] = '\0'; s = (char *)rtcp + 16; - tvhtrace("satip", "Status string: '%s'", s); + tvhtrace(LS_SATIP, "Status string: '%s'", s); status = SIGNAL_NONE; if (strncmp(s, "ver=0.9;tuner=", 14) == 0 || strncmp(s, "ver=1.2;tuner=", 14) == 0) { @@ -985,7 +985,7 @@ all: } if (r < 0) - tvherror("satip", "%s - failed to modify pids: %s", name, strerror(-r)); + tvherror(LS_SATIP, "%s - failed to modify pids: %s", name, strerror(-r)); return r; skip: @@ -1124,7 +1124,7 @@ satip_frontend_extra_shutdown snprintf(b, sizeof(b), "/stream=%li", stream_id); r = rtsp_teardown(rtsp, b, NULL); if (r < 0) { - tvhtrace("satip", "bad shutdown for session %s stream id %li", session, stream_id); + tvhtrace(LS_SATIP, "bad shutdown for session %s stream id %li", session, stream_id); } else { while (1) { r = http_client_run(rtsp); @@ -1144,7 +1144,7 @@ satip_frontend_extra_shutdown } http_client_close(rtsp); - tvhlog(LOG_INFO, "satip", "extra shutdown done for session %s", session); + tvhinfo(LS_SATIP, "extra shutdown done for session %s", session); done: tvhpoll_destroy(efd); @@ -1163,10 +1163,10 @@ satip_frontend_shutdown goto wake; snprintf(b, sizeof(b), "/stream=%li", rtsp->hc_rtsp_stream_id); - tvhtrace("satip", "%s - shutdown for %s/%s", name, b, rtsp->hc_rtsp_session ?: ""); + tvhtrace(LS_SATIP, "%s - shutdown for %s/%s", name, b, rtsp->hc_rtsp_session ?: ""); r = rtsp_teardown(rtsp, (char *)b, NULL); if (r < 0) { - tvhtrace("satip", "%s - bad teardown", b); + tvhtrace(LS_SATIP, "%s - bad teardown", b); } else { while (1) { r = http_client_run(rtsp); @@ -1275,7 +1275,7 @@ satip_frontend_rtp_data_received( http_client_t *hc, void *buf, size_t len ) lfe->sf_seq = nseq; else if (((lfe->sf_seq + 1) & 0xffff) != nseq) { unc = ((c - pos) / 188) * (uint32_t)((uint16_t)nseq-(uint16_t)(lfe->sf_seq+1)); - tvhtrace("satip", "TCP/RTP discontinuity (%i != %i)", lfe->sf_seq + 1, nseq); + tvhtrace(LS_SATIP, "TCP/RTP discontinuity (%i != %i)", lfe->sf_seq + 1, nseq); } lfe->sf_seq = nseq; @@ -1418,11 +1418,11 @@ new_tune: c = read(lfe->sf_dvr_pipe.rd, b, 1); if (c == 1) { if (b[0] == 'e') { - tvhtrace("satip", "%s - input thread received shutdown", buf); + tvhtrace(LS_SATIP, "%s - input thread received shutdown", buf); exit_flag = 1; goto done; } else if (b[0] == 's') { - tvhtrace("satip", "%s - start", buf); + tvhtrace(LS_SATIP, "%s - start", buf); start = 1; } } @@ -1473,7 +1473,7 @@ new_tune: if ((rtsp_flags & SATIP_SETUP_TCP) == 0) { if (udp_bind_double(&rtp, &rtcp, - "satip", "rtp", "rtcp", + LS_SATIP, "rtp", "rtcp", satip_frontend_bindaddr(lfe), lfe->sf_udp_rtp_port, NULL, SATIP_BUF_SIZE, 16384, 4*1024, 4*1024) < 0) { satip_frontend_tuning_error(lfe, tr); @@ -1482,7 +1482,7 @@ new_tune: rtp_port = ntohs(IP_PORT(rtp->ip)); - tvhtrace("satip", "%s - local RTP port %i RTCP port %i", + tvhtrace(LS_SATIP, "%s - local RTP port %i RTCP port %i", lfe->mi_name, ntohs(IP_PORT(rtp->ip)), ntohs(IP_PORT(rtcp->ip))); @@ -1527,7 +1527,7 @@ new_tune: r = (uint64_t)i - u64_2; if (tc) - tvhtrace("satip", "%s - last tune diff = %llu (delay = %d)", + tvhtrace(LS_SATIP, "%s - last tune diff = %llu (delay = %d)", buf, (unsigned long long)u64_2, r); tc = 1; @@ -1546,7 +1546,7 @@ new_tune: changing = 1; continue; } else if (b[0] == 'e') { - tvhtrace("satip", "%s - input thread received shutdown", buf); + tvhtrace(LS_SATIP, "%s - input thread received shutdown", buf); exit_flag = 1; goto done; } else if (b[0] == 's') { @@ -1556,7 +1556,7 @@ new_tune: continue; } } - tvhtrace("satip", "%s - input thread received mux close", buf); + tvhtrace(LS_SATIP, "%s - input thread received mux close", buf); goto done; } @@ -1633,9 +1633,9 @@ new_tune: pthread_mutex_unlock(&lfe->sf_dvr_lock); if (r < 0) { if (r != -12345678) - tvherror("satip", "%s - failed to tune (%i)", buf, r); + tvherror(LS_SATIP, "%s - failed to tune (%i)", buf, r); else - tvhtrace("satip", "%s - mux changed in the middle", buf); + tvhtrace(LS_SATIP, "%s - mux changed in the middle", buf); satip_frontend_tuning_error(lfe, tr); goto done; } @@ -1664,7 +1664,7 @@ new_tune: changing = 1; continue; } else if (b[0] == 'e') { - tvhtrace("satip", "%s - input thread received shutdown", buf); + tvhtrace(LS_SATIP, "%s - input thread received shutdown", buf); exit_flag = 1; running = 0; continue; } else if (b[0] == 's') { @@ -1674,7 +1674,7 @@ new_tune: continue; } } - tvhtrace("satip", "%s - input thread received mux close", buf); + tvhtrace(LS_SATIP, "%s - input thread received mux close", buf); running = 0; continue; } @@ -1693,7 +1693,7 @@ new_tune: r = http_client_run(rtsp); if (r < 0) { if (rtsp->hc_code == 404 && session[0]) { - tvhlog(LOG_WARNING, "satip", "%s - RTSP 404 ERROR (retrying)", buf); + tvhwarn(LS_SATIP, "%s - RTSP 404 ERROR (retrying)", buf); satip_frontend_extra_shutdown(lfe, session, stream_id); session[0] = '\0'; start = 1; @@ -1701,8 +1701,8 @@ new_tune: rtsp = NULL; break; } - tvhlog(LOG_ERR, "satip", "%s - RTSP error %d (%s) [%i-%i]", - buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); + tvherror(LS_SATIP, "%s - RTSP error %d (%s) [%i-%i]", + buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); satip_frontend_tuning_error(lfe, tr); fatal = 1; } else if (r == HTTP_CON_DONE) { @@ -1715,8 +1715,8 @@ new_tune: if (!running) break; if (r < 0) { - tvhlog(LOG_ERR, "satip", "%s - RTSP OPTIONS error %d (%s) [%i-%i]", - buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); + tvherror(LS_SATIP, "%s - RTSP OPTIONS error %d (%s) [%i-%i]", + buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); satip_frontend_tuning_error(lfe, tr); fatal = 1; } @@ -1730,15 +1730,15 @@ new_tune: rtsp->hc_rtcp_port != rtp_port + 1)) || ((rtsp_flags & SATIP_SETUP_TCP) != 0 && (rtsp->hc_rtp_tcp < 0 || rtsp->hc_rtcp_tcp < 0))) { - tvhlog(LOG_ERR, "satip", "%s - RTSP SETUP error %d (%s) [%i-%i]", - buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); + tvherror(LS_SATIP, "%s - RTSP SETUP error %d (%s) [%i-%i]", + buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); satip_frontend_tuning_error(lfe, tr); fatal = 1; } else { strncpy((char *)session, rtsp->hc_rtsp_session ?: "", sizeof(session)); session[sizeof(session)-1] = '\0'; stream_id = rtsp->hc_rtsp_stream_id; - tvhdebug("satip", "%s #%i - new session %s stream id %li", + tvhdebug(LS_SATIP, "%s #%i - new session %s stream id %li", rtsp->hc_host, lfe->sf_number, rtsp->hc_rtsp_session, rtsp->hc_rtsp_stream_id); if (lfe->sf_play2) { @@ -1753,7 +1753,7 @@ new_tune: } pthread_mutex_unlock(&lfe->sf_dvr_lock); if (r < 0) { - tvherror("satip", "%s - failed to tune2 (%i)", buf, r); + tvherror(LS_SATIP, "%s - failed to tune2 (%i)", buf, r); satip_frontend_tuning_error(lfe, tr); fatal = 1; } @@ -1781,8 +1781,8 @@ new_tune: /* fall thru */ default: if (rtsp->hc_code >= 400) { - tvhlog(LOG_ERR, "satip", "%s - RTSP cmd error %d (%s) [%i-%i]", - buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); + tvherror(LS_SATIP, "%s - RTSP cmd error %d (%s) [%i-%i]", + buf, r, strerror(-r), rtsp->hc_cmd, rtsp->hc_code); satip_frontend_tuning_error(lfe, tr); fatal = 1; } @@ -1822,11 +1822,11 @@ new_tune: if (ERRNO_AGAIN(errno)) continue; if (errno == EOVERFLOW) { - tvhlog(LOG_WARNING, "satip", "%s - recvmsg() EOVERFLOW", buf); + tvhwarn(LS_SATIP, "%s - recvmsg() EOVERFLOW", buf); continue; } - tvhlog(LOG_ERR, "satip", "%s - multirecv error %d (%s)", - buf, errno, strerror(errno)); + tvherror(LS_SATIP, "%s - multirecv error %d (%s)", + buf, errno, strerror(errno)); break; } @@ -1856,7 +1856,7 @@ new_tune: seq = nseq; else if (((seq + 1) & 0xffff) != nseq) { unc += ((c - pos) / 188) * (uint32_t)((uint16_t)nseq-(uint16_t)(seq+1)); - tvhtrace("satip", "RTP discontinuity (%i != %i)", seq + 1, nseq); + tvhtrace(LS_SATIP, "RTP discontinuity (%i != %i)", seq + 1, nseq); } seq = nseq; /* Process */ @@ -2076,7 +2076,7 @@ satip_frontend_create else if (type == DVB_TYPE_ATSC_C) idc = &satip_frontend_atsc_c_class; else { - tvherror("satip", "unknown FE type %d", type); + tvherror(LS_SATIP, "unknown FE type %d", type); return NULL; } @@ -2203,10 +2203,10 @@ satip_frontend_delete ( satip_frontend_t *lfe ) /* Stop thread */ if (lfe->sf_dvr_pipe.wr > 0) { tvh_write(lfe->sf_dvr_pipe.wr, "e", 1); - tvhtrace("satip", "%s - waiting for control thread", buf1); + tvhtrace(LS_SATIP, "%s - waiting for control thread", buf1); pthread_join(lfe->sf_dvr_thread, NULL); tvh_pipe_close(&lfe->sf_dvr_pipe); - tvhdebug("satip", "%s - stopped control thread", buf1); + tvhdebug(LS_SATIP, "%s - stopped control thread", buf1); } /* Stop timer */ diff --git a/src/input/mpegts/satip/satip_rtsp.c b/src/input/mpegts/satip/satip_rtsp.c index 83bfe73b4..febc0e8a8 100644 --- a/src/input/mpegts/satip/satip_rtsp.c +++ b/src/input/mpegts/satip/satip_rtsp.c @@ -45,7 +45,7 @@ satip_rtsp_setup_find(const char *prefix, tvh2satip_t *tbl, return tbl->s; tbl++; } - tvhtrace("satip", "%s - cannot translate %d", prefix, src); + tvhtrace(LS_SATIP, "%s - cannot translate %d", prefix, src); return defval; } @@ -233,7 +233,7 @@ satip_rtsp_setup( http_client_t *hc, int src, int fe, strcat(buf, ",21"); } else if (flags & SATIP_SETUP_PIDS21) strcat(buf, "&pids=21"); - tvhtrace("satip", "setup params - %s", buf); + tvhtrace(LS_SATIP, "setup params - %s", buf); if (hc->hc_rtsp_stream_id >= 0) snprintf(stream = _stream, sizeof(_stream), "/stream=%li", hc->hc_rtsp_stream_id); diff --git a/src/input/mpegts/satip/satip_satconf.c b/src/input/mpegts/satip/satip_satconf.c index 32164629b..016d6cbf1 100644 --- a/src/input/mpegts/satip/satip_satconf.c +++ b/src/input/mpegts/satip/satip_satconf.c @@ -214,8 +214,8 @@ satip_satconf_sanity_check( satip_frontend_t *lfe ) TAILQ_FOREACH(sfc, &lfe->sf_satconf, sfc_link) { if (sfc->sfc_network_limit) { if (lfe->sf_master) { - tvherror("satip", "%s: unable to combine master/slave with network limiter, " - "disabling master", lfe->mi_name); + tvherror(LS_SATIP, "%s: unable to combine master/slave with network limiter, " + "disabling master", lfe->mi_name); lfe->sf_master = 0; } } diff --git a/src/input/mpegts/scanfile.c b/src/input/mpegts/scanfile.c index 998d9d604..83ec8856e 100644 --- a/src/input/mpegts/scanfile.c +++ b/src/input/mpegts/scanfile.c @@ -305,7 +305,7 @@ scanfile_region_create } if (!reg) { - tvhtrace("scanfile", "%s region %s created", type, id); + tvhtrace(LS_SCANFILE, "%s region %s created", type, id); reg = calloc(1, sizeof(scanfile_region_t)); reg->sfr_id = strdup(id); reg->sfr_name = strdup(desc); @@ -400,7 +400,7 @@ scanfile_load_one break; } - tvhtrace("scanfile", "[%s] %s", line, r ? "FAIL" : "OK"); + tvhtrace(LS_SCANFILE, "[%s] %s", line, r ? "FAIL" : "OK"); if (r) { free(mux); } else { @@ -434,11 +434,11 @@ str_trim(char *s) } #define mux_fail0(r, text) do { \ - tvhtrace("scanfile", text); \ + tvhtrace(LS_SCANFILE, text); \ ((r) = -1); \ } while (0) #define mux_fail(r, text, val) do { \ - tvhtrace("scanfile", text, val); \ + tvhtrace(LS_SCANFILE, text, val); \ ((r) = -1); \ } while (0) #define mux_ok(r) ((r) = ((r) > 0) ? 0 : (r)) @@ -687,7 +687,7 @@ scanfile_load_dvbv5 free(mux); } else { dvb_mux_conf_str(mux, buf, sizeof(buf)); - tvhtrace("scanfile", "mux %s", buf); + tvhtrace(LS_SCANFILE, "mux %s", buf); if (*net == NULL) if (scanfile_create_network(net, type, name, mux->dmc_fe_delsys)) return -1; @@ -709,7 +709,7 @@ scanfile_load_file char *str, buf[256]; int load = 0; - tvhtrace("scanfile", "load file %s", name); + tvhtrace(LS_SCANFILE, "load file %s", name); if (scanfile_total_load > SCANFILE_LIMIT) return; fp = fb_open2(dir, name, 1, 0); @@ -764,7 +764,7 @@ scanfile_load_dir char p[256]; fb_dir *dir; fb_dirent *de; - tvhtrace("scanfile", "load dir %s", path); + tvhtrace(LS_SCANFILE, "load dir %s", path); if (lvl >= 3) return; if (!(dir = fb_opendir(path))) return; @@ -799,7 +799,7 @@ scanfile_stats(const char *what, scanfile_region_list_t *list) networks++; } if (regions) { - tvhinfo("scanfile", "%s - loaded %i regions with %i networks", what, regions, networks); + tvhinfo(LS_SCANFILE, "%s - loaded %i regions with %i networks", what, regions, networks); return 1; } return 0; @@ -867,10 +867,10 @@ scanfile_init ( const char *muxconf_path, int lock ) r += scanfile_stats(buf, &scanfile_regions_load[i]); } if (!r) { - tvhwarn("scanfile", "no predefined muxes found, check path '%s%s'", + tvhwarn(LS_SCANFILE, "no predefined muxes found, check path '%s%s'", path[0] == '/' ? path : TVHEADEND_DATADIR "/", path[0] == '/' ? "" : path); - tvhwarn("scanfile", "expected tree structure - http://git.linuxtv.org/cgit.cgi/dtv-scan-tables.git/tree/"); + tvhwarn(LS_SCANFILE, "expected tree structure - http://git.linuxtv.org/cgit.cgi/dtv-scan-tables.git/tree/"); for (i = 0; i < REGIONS; i++) scanfile_done_region(&scanfile_regions_load[i]); free(scanfile_regions_load); diff --git a/src/input/mpegts/tsdemux.c b/src/input/mpegts/tsdemux.c index f2d50bef2..81ab9c986 100644 --- a/src/input/mpegts/tsdemux.c +++ b/src/input/mpegts/tsdemux.c @@ -75,7 +75,7 @@ ts_recv_packet0 /* Let the hardware to stabilize and don't flood the log */ if (t->s_start_time + sec2mono(1) < mclk() && tvhlog_limit(&st->es_cc_log, 10)) - tvhwarn("TS", "%s Continuity counter error (total %zi)", + tvhwarn(LS_TS, "%s Continuity counter error (total %zi)", service_component_nicename(st), st->es_cc_log.count); if (!error) errors++; @@ -143,7 +143,7 @@ ts_recv_skipped0 /* Let the hardware to stabilize and don't flood the log */ if (t->s_start_time + sec2mono(1) < mclk() && tvhlog_limit(&st->es_cc_log, 10)) - tvhwarn("TS", "%s Continuity counter error (total %zi)", + tvhwarn(LS_TS, "%s Continuity counter error (total %zi)", service_component_nicename(st), st->es_cc_log.count); } st->es_cc = (cc + 1) & 0xf; @@ -202,7 +202,7 @@ ts_recv_packet1 if(error) { /* Transport Error Indicator */ if (tvhlog_limit(&t->s_tei_log, 10)) - tvhwarn("TS", "%s Transport error indicator (total %zi)", + tvhwarn(LS_TS, "%s Transport error indicator (total %zi)", service_nicename((service_t*)t), t->s_tei_log.count); } diff --git a/src/input/mpegts/tsfile/tsfile.c b/src/input/mpegts/tsfile/tsfile.c index d5e7a90c9..4262a03db 100644 --- a/src/input/mpegts/tsfile/tsfile.c +++ b/src/input/mpegts/tsfile/tsfile.c @@ -138,7 +138,7 @@ void tsfile_add_file ( const char *path ) uuid = tmp; } - tvhtrace("tsfile", "add file %s (uuid:%s)", path, uuid); + tvhtrace(LS_TSFILE, "add file %s (uuid:%s)", path, uuid); /* Create logical instance */ mm = tsfile_mux_create(uuid, tsfile_network); diff --git a/src/input/mpegts/tsfile/tsfile_input.c b/src/input/mpegts/tsfile/tsfile_input.c index 34a0078ba..edb95d90f 100644 --- a/src/input/mpegts/tsfile/tsfile_input.c +++ b/src/input/mpegts/tsfile/tsfile_input.c @@ -58,10 +58,10 @@ tsfile_input_thread ( void *aux ) tmi = (tsfile_mux_instance_t*)mmi; fd = tvh_open(tmi->mmi_tsfile_path, O_RDONLY | O_NONBLOCK, 0); if (fd == -1) - tvhlog(LOG_ERR, "tsfile", "open(%s) failed %d (%s)", - tmi->mmi_tsfile_path, errno, strerror(errno)); + tvherror(LS_TSFILE, "open(%s) failed %d (%s)", + tmi->mmi_tsfile_path, errno, strerror(errno)); else - tvhtrace("tsfile", "adapter %d opened %s", mi->mi_instance, tmi->mmi_tsfile_path); + tvhtrace(LS_TSFILE, "adapter %d opened %s", mi->mi_instance, tmi->mmi_tsfile_path); } pthread_mutex_unlock(&global_lock); if (fd == -1) return NULL; @@ -78,15 +78,15 @@ tsfile_input_thread ( void *aux ) /* Get file length */ if (fstat(fd, &st)) { - tvhlog(LOG_ERR, "tsfile", "stat() failed %d (%s)", - errno, strerror(errno)); + tvherror(LS_TSFILE, "stat() failed %d (%s)", + errno, strerror(errno)); goto exit; } /* Check for extra (incomplete) packet at end */ rem = st.st_size % 188; len = 0; - tvhtrace("tsfile", "adapter %d file size %jd rem %zu", + tvhtrace(LS_TSFILE, "adapter %d file size %jd rem %zu", mi->mi_instance, (intmax_t)st.st_size, rem); pcr_last_mono = getfastmonoclock(); @@ -114,8 +114,8 @@ tsfile_input_thread ( void *aux ) if (c < 0) { if (ERRNO_AGAIN(errno)) continue; - tvhlog(LOG_ERR, "tsfile", "read() error %d (%s)", - errno, strerror(errno)); + tvherror(LS_TSFILE, "read() error %d (%s)", + errno, strerror(errno)); break; } len += c; @@ -124,7 +124,7 @@ tsfile_input_thread ( void *aux ) if (len >= st.st_size) { len = 0; c -= rem; - tvhtrace("tsfile", "adapter %d reached eof, resetting", mi->mi_instance); + tvhtrace(LS_TSFILE, "adapter %d reached eof, resetting", mi->mi_instance); lseek(fd, 0, SEEK_SET); pcr_last = PTS_UNSET; } @@ -177,12 +177,12 @@ tsfile_input_stop_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *mmi ) /* Stop thread */ if (ti->ti_thread_pipe.rd != -1) { - tvhtrace("tsfile", "adapter %d stopping thread", mi->mi_instance); + tvhtrace(LS_TSFILE, "adapter %d stopping thread", mi->mi_instance); err = tvh_write(ti->ti_thread_pipe.wr, "", 1); assert(err != -1); pthread_join(ti->ti_thread_id, NULL); tvh_pipe_close(&ti->ti_thread_pipe); - tvhtrace("tsfile", "adapter %d stopped thread", mi->mi_instance); + tvhtrace(LS_TSFILE, "adapter %d stopped thread", mi->mi_instance); } mmi->mmi_mux->mm_active = NULL; @@ -196,11 +196,11 @@ tsfile_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *t, int weigh mpegts_mux_t *mm = t->mmi_mux; tsfile_mux_instance_t *mmi = (tsfile_mux_instance_t*)t; tsfile_input_t *ti = (tsfile_input_t*)mi; - tvhtrace("tsfile", "adapter %d starting mmi %p", mi->mi_instance, mmi); + tvhtrace(LS_TSFILE, "adapter %d starting mmi %p", mi->mi_instance, mmi); /* Already tuned */ if (mmi->mmi_mux->mm_active == t) { - tvhtrace("tsfile", "mmi %p is already active", mmi); + tvhtrace(LS_TSFILE, "mmi %p is already active", mmi); return 0; } assert(mmi->mmi_mux->mm_active == NULL); @@ -208,8 +208,8 @@ tsfile_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *t, int weigh /* Check file is accessible */ if (lstat(mmi->mmi_tsfile_path, &st)) { - tvhlog(LOG_ERR, "tsfile", "mmi %p could not stat '%s' (%i)", - mmi, mmi->mmi_tsfile_path, errno); + tvherror(LS_TSFILE, "mmi %p could not stat '%s' (%i)", + mmi, mmi->mmi_tsfile_path, errno); mmi->mmi_tune_failed = 1; return SM_CODE_TUNING_FAILED; } @@ -218,10 +218,10 @@ tsfile_input_start_mux ( mpegts_input_t *mi, mpegts_mux_instance_t *t, int weigh if (ti->ti_thread_pipe.rd == -1) { if (tvh_pipe(O_NONBLOCK, &ti->ti_thread_pipe)) { mmi->mmi_tune_failed = 1; - tvhlog(LOG_ERR, "tsfile", "failed to create thread pipe"); + tvherror(LS_TSFILE, "failed to create thread pipe"); return SM_CODE_TUNING_FAILED; } - tvhtrace("tsfile", "adapter %d starting thread", mi->mi_instance); + tvhtrace(LS_TSFILE, "adapter %d starting thread", mi->mi_instance); tvhthread_create(&ti->ti_thread_id, NULL, tsfile_input_thread, mi, "tsfile"); } diff --git a/src/input/mpegts/tsfile/tsfile_mux.c b/src/input/mpegts/tsfile/tsfile_mux.c index bc6cd724f..4cfb40816 100644 --- a/src/input/mpegts/tsfile/tsfile_mux.c +++ b/src/input/mpegts/tsfile/tsfile_mux.c @@ -42,7 +42,7 @@ tsfile_mux_instance_create mmi->mmi_tsfile_path = strdup(path); mmi->mmi_tsfile_pcr_pid = MPEGTS_PID_NONE; mmi->tii_delete = tsfile_mux_instance_delete; - tvhtrace("tsfile", "mmi created %p path %s", mmi, mmi->mmi_tsfile_path); + tvhtrace(LS_TSFILE, "mmi created %p path %s", mmi, mmi->mmi_tsfile_path); return mmi; } @@ -59,7 +59,7 @@ tsfile_mux_create ( const char *uuid, mpegts_network_t *mn ) = mpegts_mux_create1(uuid, mn, MPEGTS_ONID_NONE, MPEGTS_TSID_NONE, NULL); mm->mm_config_save = iptv_mux_config_save; mm->mm_epg = MM_EPG_DISABLE; - tvhtrace("tsfile", "mm created %p", mm); + tvhtrace(LS_TSFILE, "mm created %p", mm); return mm; } diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun.c index 690bded99..8ff296be4 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun.c @@ -112,7 +112,7 @@ tvhdhomerun_device_class_override_set( void *obj, const void * p ) if ( hd->hd_override_type != NULL && strcmp(hd->hd_override_type,s) != 0 ) { free(hd->hd_override_type); hd->hd_override_type = strdup(p); - tvhlog(LOG_INFO, "tvhdhomerun", "Setting override_type : %s", hd->hd_override_type); + tvhinfo(LS_TVHDHOMERUN, "Setting override_type : %s", hd->hd_override_type); return 1; } } @@ -304,7 +304,7 @@ static void tvhdhomerun_device_create(struct hdhomerun_discover_device_t *dInfo) } hd->hd_override_type = strdup(dvb_type2str(type)); - tvhlog(LOG_INFO, "tvheadend","Using Network type : %s", hd->hd_override_type); + tvhinfo(LS_TVHDHOMERUN, "Using Network type : %s", hd->hd_override_type); /* some sane defaults */ hd->hd_fullmux_ok = 1; @@ -337,9 +337,9 @@ static void tvhdhomerun_device_create(struct hdhomerun_discover_device_t *dInfo) for (j = 0; j < dInfo->tuner_count; ++j) { if (tvhdhomerun_frontend_create(hd, dInfo, feconf, type, j)) { - tvhlog(LOG_INFO, "tvhdhomerun", "Created frontend %08X tuner %d", dInfo->device_id, j); + tvhinfo(LS_TVHDHOMERUN, "Created frontend %08X tuner %d", dInfo->device_id, j); } else { - tvhlog(LOG_ERR, "tvhdhomerun", "Unable to create frontend-device. ( %08x-%d )", dInfo->device_id,j); + tvherror(LS_TVHDHOMERUN, "Unable to create frontend-device. ( %08x-%d )", dInfo->device_id,j); } } @@ -374,8 +374,8 @@ tvhdhomerun_device_discovery_thread( void *aux ) tvhdhomerun_device_t *existing = tvhdhomerun_device_find(cDev->device_id); if ( tvheadend_is_running() ) { if ( !existing ) { - tvhlog(LOG_INFO, "tvhdhomerun","Found HDHomerun device %08x with %d tuners", - cDev->device_id, cDev->tuner_count); + tvhinfo(LS_TVHDHOMERUN,"Found HDHomerun device %08x with %d tuners", + cDev->device_id, cDev->tuner_count); tvhdhomerun_device_create(cDev); } else if ( ((struct sockaddr_in *)&existing->hd_info.ip_address)->sin_addr.s_addr != htonl(cDev->ip_addr) ) { @@ -392,7 +392,7 @@ tvhdhomerun_device_discovery_thread( void *aux ) tcp_get_str_from_ip((struct sockaddr *)&detected_dev_addr, detected_ip, sizeof(detected_ip)); - tvhlog(LOG_INFO, "tvhdhomerun","HDHomerun device %08x switched IPs from %s to %s, updating", + tvhinfo(LS_TVHDHOMERUN,"HDHomerun device %08x switched IPs from %s to %s, updating", cDev->device_id, existing_ip, detected_ip); tvhdhomerun_device_destroy(existing); tvhdhomerun_device_create(cDev); @@ -477,7 +477,7 @@ tvhdhomerun_device_destroy( tvhdhomerun_device_t *hd ) idnode_save_check(&hd->th_id, 0); - tvhlog(LOG_INFO, "tvhdhomerun", "Releasing locks for devices"); + tvhinfo(LS_TVHDHOMERUN, "Releasing locks for devices"); while ((lfe = TAILQ_FIRST(&hd->hd_frontends)) != NULL) { tvhdhomerun_frontend_delete(lfe); } diff --git a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c index c6ad64c86..71d6c934b 100644 --- a/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c +++ b/src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c @@ -67,7 +67,7 @@ tvhdhomerun_frontend_input_thread ( void *aux ) tvhpoll_event_t ev[2]; tvhpoll_t *efd; - tvhdebug("tvhdhomerun", "starting input thread"); + tvhdebug(LS_TVHDHOMERUN, "starting input thread"); /* Get MMI */ pthread_mutex_lock(&hfe->hf_input_thread_mutex); @@ -77,7 +77,7 @@ tvhdhomerun_frontend_input_thread ( void *aux ) pthread_mutex_unlock(&hfe->hf_input_thread_mutex); if (mmi == NULL) return NULL; - tvhdebug("tvhdhomerun", "opening client socket"); + tvhdebug(LS_TVHDHOMERUN, "opening client socket"); /* One would like to use libhdhomerun for the streaming details, * but that library uses threads on its own and the socket is put @@ -93,32 +93,32 @@ tvhdhomerun_frontend_input_thread ( void *aux ) /* first setup a local socket for the device to stream to */ sockfd = tvh_socket(AF_INET, SOCK_DGRAM, 0); if(sockfd == -1) { - tvherror("tvhdhomerun", "failed to open socket (%d)", errno); + tvherror(LS_TVHDHOMERUN, "failed to open socket (%d)", errno); return NULL; } if(fcntl(sockfd, F_SETFL, O_NONBLOCK) != 0) { close(sockfd); - tvherror("tvhdhomerun", "failed to set socket nonblocking (%d)", errno); + tvherror(LS_TVHDHOMERUN, "failed to set socket nonblocking (%d)", errno); return NULL; } /* enable broadcast */ if(setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, (char *) &sock_opt, sizeof(sock_opt)) < 0) { close(sockfd); - tvhlog(LOG_ERR, "tvhdhomerun", "failed to enable broadcast on socket (%d)", errno); + tvherror(LS_TVHDHOMERUN, "failed to enable broadcast on socket (%d)", errno); return NULL; } if(setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, (char *) &sock_opt, sizeof(sock_opt)) < 0) { close(sockfd); - tvhlog(LOG_ERR, "tvhdhomerun", "failed to set address reuse on socket (%d)", errno); + tvherror(LS_TVHDHOMERUN, "failed to set address reuse on socket (%d)", errno); return NULL; } /* important: we need large rx buffers to accomodate the large amount of traffic */ if(setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF, (char *) &rx_size, sizeof(rx_size)) < 0) { - tvhlog(LOG_WARNING, "tvhdhomerun", "failed set socket rx buffer size, expect CC errors (%d)", errno); + tvhwarn(LS_TVHDHOMERUN, "failed set socket rx buffer size, expect CC errors (%d)", errno); } memset(&sock_addr, 0, sizeof(sock_addr)); @@ -126,14 +126,14 @@ tvhdhomerun_frontend_input_thread ( void *aux ) sock_addr.sin_addr.s_addr = htonl(INADDR_ANY); sock_addr.sin_port = 0; if(bind(sockfd, (struct sockaddr *) &sock_addr, sizeof(sock_addr)) != 0) { - tvhlog(LOG_ERR, "tvhdhomerun", "failed bind socket: %d", errno); + tvherror(LS_TVHDHOMERUN, "failed bind socket: %d", errno); close(sockfd); return NULL; } memset(&sock_addr, 0, sizeof(sock_addr)); if(getsockname(sockfd, (struct sockaddr *) &sock_addr, &sockaddr_len) != 0) { - tvhlog(LOG_ERR, "tvhdhomerun", "failed to getsockname: %d", errno); + tvherror(LS_TVHDHOMERUN, "failed to getsockname: %d", errno); close(sockfd); return NULL; } @@ -149,12 +149,12 @@ tvhdhomerun_frontend_input_thread ( void *aux ) (unsigned int)(local_ip >> 8) & 0xFF, (unsigned int)(local_ip >> 0) & 0xFF, ntohs(sock_addr.sin_port)); - tvhdebug("tvhdhomerun", "setting target to: %s", target); + tvhdebug(LS_TVHDHOMERUN, "setting target to: %s", target); pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); r = hdhomerun_device_set_tuner_target(hfe->hf_hdhomerun_tuner, target); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(r < 1) { - tvhlog(LOG_ERR, "tvhdhomerun", "failed to set target: %d", r); + tvherror(LS_TVHDHOMERUN, "failed to set target: %d", r); return NULL; } @@ -168,7 +168,7 @@ tvhdhomerun_frontend_input_thread ( void *aux ) r = tvhpoll_add(efd, ev, 2); if(r < 0) - tvhlog(LOG_ERR, "tvhdhomerun", "failed to setup poll"); + tvherror(LS_TVHDHOMERUN, "failed to setup poll"); sbuf_init_fixed(&sb, (20000000 / 8)); @@ -185,23 +185,23 @@ tvhdhomerun_frontend_input_thread ( void *aux ) if(ERRNO_AGAIN(errno)) continue; if(errno == EOVERFLOW) { - tvhlog(LOG_WARNING, "tvhdhomerun", "%s - read() EOVERFLOW", buf); + tvhwarn(LS_TVHDHOMERUN, "%s - read() EOVERFLOW", buf); continue; } - tvhlog(LOG_ERR, "tvhdhomerun", "%s - read() error %d (%s)", - buf, errno, strerror(errno)); + tvherror(LS_TVHDHOMERUN, "%s - read() error %d (%s)", + buf, errno, strerror(errno)); break; } //if(r != (7*188)) //continue; /* dude; this is not a valid packet */ - //tvhdebug("tvhdhomerun", "got r=%d (thats %d)", r, (r == 7*188)); + //tvhdebug(LS_TVHDHOMERUN, "got r=%d (thats %d)", r, (r == 7*188)); mpegts_input_recv_packets((mpegts_input_t*) hfe, mmi, &sb, 0, NULL); } - tvhdebug("tvhdhomerun", "setting target to none"); + tvhdebug(LS_TVHDHOMERUN, "setting target to none"); pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); hdhomerun_device_set_tuner_target(hfe->hf_hdhomerun_tuner, "none"); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); @@ -238,7 +238,7 @@ tvhdhomerun_frontend_monitor_cb( void *aux ) res = hdhomerun_device_get_tuner_status(hfe->hf_hdhomerun_tuner, &tuner_status_str, &tuner_status); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(res < 1) - tvhwarn("tvhdhomerun", "tuner_status (%d)", res); + tvhwarn(LS_TVHDHOMERUN, "tuner_status (%d)", res); if(tuner_status.signal_present) hfe->hf_status = SIGNAL_GOOD; @@ -251,7 +251,7 @@ tvhdhomerun_frontend_monitor_cb( void *aux ) /* wait for a signal_present */ if(!hfe->hf_locked) { if(tuner_status.signal_present) { - tvhdebug("tvhdhomerun", "locked"); + tvhdebug(LS_TVHDHOMERUN, "locked"); hfe->hf_locked = 1; /* start input thread */ @@ -310,12 +310,12 @@ static void tvhdhomerun_device_open_pid(tvhdhomerun_frontend_t *hfe, int pid) { /* a full mux subscription should specificly set the filter */ if (pid == MPEGTS_FULLMUX_PID) { - tvhdebug("tvhdhomerun", "setting PID filter full mux"); + tvhdebug(LS_TVHDHOMERUN, "setting PID filter full mux"); pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); res = hdhomerun_device_set_tuner_filter(hfe->hf_hdhomerun_tuner, "0x0000-0x1FFF"); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(res < 1) - tvhlog(LOG_ERR, "tvhdhomerun", "failed to set_tuner_filter to 0x0000 - 0x1FFF"); + tvherror(LS_TVHDHOMERUN, "failed to set_tuner_filter to 0x0000 - 0x1FFF"); return; } @@ -324,15 +324,15 @@ static void tvhdhomerun_device_open_pid(tvhdhomerun_frontend_t *hfe, int pid) { res = hdhomerun_device_get_tuner_filter(hfe->hf_hdhomerun_tuner, &pfilter); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(res < 1) { - tvhlog(LOG_ERR, "tvhdhomerun", "failed to get_tuner_filter: %d", res); + tvherror(LS_TVHDHOMERUN, "failed to get_tuner_filter: %d", res); return; } - tvhdebug("tvhdhomerun", "current pfilter: %s", pfilter); + tvhdebug(LS_TVHDHOMERUN, "current pfilter: %s", pfilter); /* make sure the pid maps to a max of 0x1FFF, API will reject the call otherwise */ if(pid > 0x1FFF) { - tvhlog(LOG_ERR, "tvhdhomerun", "pid %d is too large, masking to API maximum of 0x1FFF", pid); + tvherror(LS_TVHDHOMERUN, "pid %d is too large, masking to API maximum of 0x1FFF", pid); pid = (pid & 0x1FFF); } @@ -342,15 +342,15 @@ static void tvhdhomerun_device_open_pid(tvhdhomerun_frontend_t *hfe, int pid) { if(strncmp(pfilter, buf, strlen(buf)) != 0) { memset(buf, 0x00, sizeof(buf)); snprintf(buf, sizeof(buf), "%s 0x%04x", pfilter, pid); - tvhdebug("tvhdhomerun", "setting pfilter to: %s", buf); + tvhdebug(LS_TVHDHOMERUN, "setting pfilter to: %s", buf); pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); res = hdhomerun_device_set_tuner_filter(hfe->hf_hdhomerun_tuner, buf); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(res < 1) - tvhlog(LOG_ERR, "tvhdhomerun", "failed to set_tuner_filter: %d", res); + tvherror(LS_TVHDHOMERUN, "failed to set_tuner_filter: %d", res); } else { - //tvhdebug("tvhdhomerun", "pid 0x%x already present in pfilter", pid); + //tvhdebug(LS_TVHDHOMERUN, "pid 0x%x already present in pfilter", pid); return; } } @@ -418,19 +418,19 @@ static int tvhdhomerun_frontend_tune(tvhdhomerun_frontend_t *hfe, mpegts_mux_ins break; } - tvhlog(LOG_INFO, "tvhdhomerun", "tuning to %s", channel_buf); + tvhinfo(LS_TVHDHOMERUN, "tuning to %s", channel_buf); pthread_mutex_lock(&hfe->hf_hdhomerun_device_mutex); res = hdhomerun_device_tuner_lockkey_request(hfe->hf_hdhomerun_tuner, &perror); if(res < 1) { pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); - tvhlog(LOG_ERR, "tvhdhomerun", "failed to acquire lockkey: %s", perror); + tvherror(LS_TVHDHOMERUN, "failed to acquire lockkey: %s", perror); return SM_CODE_TUNING_FAILED; } res = hdhomerun_device_set_tuner_channel(hfe->hf_hdhomerun_tuner, channel_buf); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(res < 1) { - tvhlog(LOG_ERR, "tvhdhomerun", "failed to tune to %s", channel_buf); + tvherror(LS_TVHDHOMERUN, "failed to tune to %s", channel_buf); return SM_CODE_TUNING_FAILED; } @@ -453,7 +453,7 @@ tvhdhomerun_frontend_start_mux mi->mi_display_name(mi, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("tvhdhomerun", "%s - starting %s", buf1, buf2); + tvhdebug(LS_TVHDHOMERUN, "%s - starting %s", buf1, buf2); /* tune to the right mux */ res = tvhdhomerun_frontend_tune(hfe, mmi); @@ -463,7 +463,7 @@ tvhdhomerun_frontend_start_mux r = hdhomerun_device_set_tuner_filter(hfe->hf_hdhomerun_tuner, "0x0000"); pthread_mutex_unlock(&hfe->hf_hdhomerun_device_mutex); if(r < 1) - tvhlog(LOG_ERR, "tvhdhomerun", "failed to reset pfilter: %d", r); + tvherror(LS_TVHDHOMERUN, "failed to reset pfilter: %d", r); return res; } @@ -477,15 +477,15 @@ tvhdhomerun_frontend_stop_mux mi->mi_display_name(mi, buf1, sizeof(buf1)); mpegts_mux_nice_name(mmi->mmi_mux, buf2, sizeof(buf2)); - tvhdebug("tvhdhomerun", "%s - stopping %s", buf1, buf2); + tvhdebug(LS_TVHDHOMERUN, "%s - stopping %s", buf1, buf2); /* join input thread */ if(hfe->hf_input_thread_pipe.wr > 0) { tvh_write(hfe->hf_input_thread_pipe.wr, "", 1); // wake input thread - tvhtrace("tvhdhomerun", "%s - waiting for input thread", buf1); + tvhtrace(LS_TVHDHOMERUN, "%s - waiting for input thread", buf1); pthread_join(hfe->hf_input_thread, NULL); tvh_pipe_close(&hfe->hf_input_thread_pipe); - tvhtrace("tvhdhomerun", "%s - input thread stopped", buf1); + tvhtrace(LS_TVHDHOMERUN, "%s - input thread stopped", buf1); } hdhomerun_device_tuner_lockkey_release(hfe->hf_hdhomerun_tuner); @@ -505,7 +505,7 @@ static void tvhdhomerun_frontend_update_pids( mpegts_input_t *mi, mpegts_mux_t * mpegts_pid_sub_t *mps; int i; - //tvhdebug("tvhdhomerun", "Update pids\n"); + //tvhdebug(LS_TVHDHOMERUN, "Update pids\n"); mpegts_pid_init(&pids); RB_FOREACH(mp, &mm->mm_pids, mp_link) { @@ -705,7 +705,7 @@ tvhdhomerun_frontend_create(tvhdhomerun_device_t *hd, struct hdhomerun_discover_ else if (type == DVB_TYPE_ATSC_C) idc = &tvhdhomerun_frontend_atsc_c_class; else { - tvherror("stvhdhomerun", "unknown FE type %d", type); + tvherror(LS_TVHDHOMERUN, "unknown FE type %d", type); return NULL; } diff --git a/src/libav.c b/src/libav.c index 077cae361..c7651a75e 100644 --- a/src/libav.c +++ b/src/libav.c @@ -51,7 +51,7 @@ libav_log_callback(void *ptr, int level, const char *fmt, va_list vl) if(!strlen(l)) break; - tvhlog(level, "libav", "%s", l); + tvhlog(level, LS_LIBAV, "%s", l); if(!nl) break; @@ -124,7 +124,7 @@ streaming_component_type2codec_id(streaming_component_type_t type) streaming_component_type_t codec_id2streaming_component_type(enum AVCodecID id) { - streaming_component_type_t type = AV_CODEC_ID_NONE; + streaming_component_type_t type = SCT_NONE; switch(id) { case AV_CODEC_ID_H264: diff --git a/src/lock.c b/src/lock.c index 3a352b927..608e02d84 100644 --- a/src/lock.c +++ b/src/lock.c @@ -114,7 +114,7 @@ int file_lock(const char *lfile, int timeout) err = state_lock_(lfile, 1, timeout, -1); if (err < 0) - tvherror("lock", "file %s lock error: %s", lfile, strerror(-err)); + tvherror(LS_LOCK, "file %s lock error: %s", lfile, strerror(-err)); return err; } @@ -124,6 +124,6 @@ int file_unlock(const char *lfile, int _fd) err = state_lock_(lfile, 0, 10, _fd); if (err < 0) - tvherror("lock", "file %s unlock error: %s", lfile, strerror(-err)); + tvherror(LS_LOCK, "file %s unlock error: %s", lfile, strerror(-err)); return err; } diff --git a/src/main.c b/src/main.c index 13ee44a6f..261d3034c 100644 --- a/src/main.c +++ b/src/main.c @@ -202,7 +202,7 @@ handle_sigill(int x) /* Note that on some platforms, the SSL library tries */ /* to determine the CPU capabilities with possible */ /* unknown instructions */ - tvhwarn("CPU", "Illegal instruction handler (might be OK)"); + tvhwarn(LS_CPU, "Illegal instruction handler (might be OK)"); signal(SIGILL, handle_sigill); } @@ -620,7 +620,7 @@ mtimer_thread(void *aux) #if ENABLE_GTIMER_CHECK mtm = getmonoclock() - mtm; if (mtm > 10000) - tvhtrace("mtimer", "%s:%s duration %"PRId64"us", id, fcn, mtm); + tvhtrace(LS_MTIMER, "%s:%s duration %"PRId64"us", id, fcn, mtm); #endif } @@ -664,9 +664,9 @@ mainloop(void) // the top of the list with a 0 offset we could loop indefinitely #if 0 - tvhdebug("gtimer", "now %"PRItime_t, ts.tv_sec); + tvhdebug(LS_GTIMER, "now %"PRItime_t, ts.tv_sec); LIST_FOREACH(gti, >imers, gti_link) - tvhdebug("gtimer", " gti %p expire %"PRItimet, gti, gti->gti_expire.tv_sec); + tvhdebug(LS_GTIMER, " gti %p expire %"PRItimet, gti, gti->gti_expire.tv_sec); #endif while((gti = LIST_FIRST(>imers)) != NULL) { @@ -691,7 +691,7 @@ mainloop(void) #if ENABLE_GTIMER_CHECK mtm = getmonoclock() - mtm; if (mtm > 10000) - tvhtrace("gtimer", "%s:%s duration %"PRId64"us", id, fcn, mtm); + tvhtrace(LS_GTIMER, "%s:%s duration %"PRId64"us", id, fcn, mtm); #endif } @@ -1014,7 +1014,7 @@ main(int argc, char **argv) tvhlog_init(log_level, log_options, opt_logpath); tvhlog_set_debug(log_debug); tvhlog_set_trace(log_trace); - tvhinfo("main", "Log started"); + tvhinfo(LS_MAIN, "Log started"); signal(SIGPIPE, handle_sigpipe); // will be redundant later signal(SIGILL, handle_sigill); // see handler.. @@ -1042,7 +1042,7 @@ main(int argc, char **argv) for (i = 0; i < gnum; i++) snprintf(buf + strlen(buf), sizeof(buf) - 1 - strlen(buf), ",%d", glist[i]); - tvhlog(LOG_ALERT, "START", + tvhlog(LOG_ALERT, LS_START, "setgroups(%s) failed, do you have permission?", buf+1); return 1; } @@ -1067,12 +1067,12 @@ main(int argc, char **argv) pidfile = tvh_fopen(opt_pidpath, "w+"); if (gid != -1 && (getgid() != gid) && setgid(gid)) { - tvhlog(LOG_ALERT, "START", + tvhlog(LOG_ALERT, LS_START, "setgid(%d) failed, do you have permission?", gid); return 1; } if (uid != -1 && (getuid() != uid) && setuid(uid)) { - tvhlog(LOG_ALERT, "START", + tvhlog(LOG_ALERT, LS_START, "setuid(%d) failed, do you have permission?", uid); return 1; } @@ -1091,10 +1091,10 @@ main(int argc, char **argv) if (opt_dump) { #ifdef PLATFORM_LINUX if (chdir("/tmp")) - tvhwarn("START", "failed to change cwd to /tmp"); + tvhwarn(LS_START, "failed to change cwd to /tmp"); prctl(PR_SET_DUMPABLE, 1); #else - tvhwarn("START", "Coredumps not implemented on your platform"); + tvhwarn(LS_START, "Coredumps not implemented on your platform"); #endif } @@ -1249,7 +1249,7 @@ main(int argc, char **argv) pthread_sigmask(SIG_UNBLOCK, &set, NULL); - tvhlog(LOG_NOTICE, "START", "HTS Tvheadend version %s started, " + tvhlog(LOG_NOTICE, LS_START, "HTS Tvheadend version %s started, " "running as PID:%d UID:%d GID:%d, CWD:%s CNF:%s", tvheadend_version, getpid(), getuid(), getgid(), getcwd(buf, sizeof(buf)), @@ -1266,73 +1266,73 @@ main(int argc, char **argv) pthread_join(mtimer_tid, NULL); #if ENABLE_DBUS_1 - tvhftrace("main", dbus_server_done); + tvhftrace(LS_MAIN, dbus_server_done); #endif #if ENABLE_UPNP - tvhftrace("main", upnp_server_done); + tvhftrace(LS_MAIN, upnp_server_done); #endif - tvhftrace("main", satip_server_done); - tvhftrace("main", htsp_done); - tvhftrace("main", http_server_done); - tvhftrace("main", webui_done); - tvhftrace("main", fsmonitor_done); - tvhftrace("main", http_client_done); - tvhftrace("main", tcp_server_done); + tvhftrace(LS_MAIN, satip_server_done); + tvhftrace(LS_MAIN, htsp_done); + tvhftrace(LS_MAIN, http_server_done); + tvhftrace(LS_MAIN, webui_done); + tvhftrace(LS_MAIN, fsmonitor_done); + tvhftrace(LS_MAIN, http_client_done); + tvhftrace(LS_MAIN, tcp_server_done); // Note: the locking is obviously a bit redundant, but without // we need to disable the gtimer_arm call in epg_save() pthread_mutex_lock(&global_lock); - tvhftrace("main", epg_save); + tvhftrace(LS_MAIN, epg_save); #if ENABLE_TIMESHIFT - tvhftrace("main", timeshift_term); + tvhftrace(LS_MAIN, timeshift_term); #endif pthread_mutex_unlock(&global_lock); - tvhftrace("main", epggrab_done); + tvhftrace(LS_MAIN, epggrab_done); #if ENABLE_MPEGTS - tvhftrace("main", mpegts_done); + tvhftrace(LS_MAIN, mpegts_done); #endif - tvhftrace("main", descrambler_done); - tvhftrace("main", service_mapper_done); - tvhftrace("main", service_done); - tvhftrace("main", channel_done); - tvhftrace("main", bouquet_done); - tvhftrace("main", dvr_done); - tvhftrace("main", subscription_done); - tvhftrace("main", access_done); - tvhftrace("main", epg_done); - tvhftrace("main", avahi_done); - tvhftrace("main", bonjour_done); - tvhftrace("main", imagecache_done); - tvhftrace("main", lang_code_done); - tvhftrace("main", api_done); - - tvhtrace("main", "tasklet enter"); + tvhftrace(LS_MAIN, descrambler_done); + tvhftrace(LS_MAIN, service_mapper_done); + tvhftrace(LS_MAIN, service_done); + tvhftrace(LS_MAIN, channel_done); + tvhftrace(LS_MAIN, bouquet_done); + tvhftrace(LS_MAIN, dvr_done); + tvhftrace(LS_MAIN, subscription_done); + tvhftrace(LS_MAIN, access_done); + tvhftrace(LS_MAIN, epg_done); + tvhftrace(LS_MAIN, avahi_done); + tvhftrace(LS_MAIN, bonjour_done); + tvhftrace(LS_MAIN, imagecache_done); + tvhftrace(LS_MAIN, lang_code_done); + tvhftrace(LS_MAIN, api_done); + + tvhtrace(LS_MAIN, "tasklet enter"); tvh_cond_signal(&tasklet_cond, 0); pthread_join(tasklet_tid, NULL); - tvhtrace("main", "tasklet thread end"); + tvhtrace(LS_MAIN, "tasklet thread end"); tasklet_flush(); - tvhtrace("main", "tasklet leave"); - tvhtrace("main", "mtimer tick thread join enter"); + tvhtrace(LS_MAIN, "tasklet leave"); + tvhtrace(LS_MAIN, "mtimer tick thread join enter"); pthread_join(mtimer_tick_tid, NULL); - tvhtrace("main", "mtimer tick thread join leave"); - - tvhftrace("main", dvb_done); - tvhftrace("main", lang_str_done); - tvhftrace("main", esfilter_done); - tvhftrace("main", profile_done); - tvhftrace("main", intlconv_done); - tvhftrace("main", urlparse_done); - tvhftrace("main", idnode_done); - tvhftrace("main", notify_done); - tvhftrace("main", spawn_done); - - tvhlog(LOG_NOTICE, "STOP", "Exiting HTS Tvheadend"); + tvhtrace(LS_MAIN, "mtimer tick thread join leave"); + + tvhftrace(LS_MAIN, dvb_done); + tvhftrace(LS_MAIN, lang_str_done); + tvhftrace(LS_MAIN, esfilter_done); + tvhftrace(LS_MAIN, profile_done); + tvhftrace(LS_MAIN, intlconv_done); + tvhftrace(LS_MAIN, urlparse_done); + tvhftrace(LS_MAIN, idnode_done); + tvhftrace(LS_MAIN, notify_done); + tvhftrace(LS_MAIN, spawn_done); + + tvhlog(LOG_NOTICE, LS_STOP, "Exiting HTS Tvheadend"); tvhlog_end(); - tvhftrace("main", config_done); - tvhftrace("main", hts_settings_done); + tvhftrace(LS_MAIN, config_done); + tvhftrace(LS_MAIN, hts_settings_done); if(opt_fork) unlink(opt_pidpath); @@ -1423,5 +1423,5 @@ htsmsg_t *tvheadend_capabilities_list(int check) */ void time_t_out_of_range_notify(int64_t val) { - tvherror("main", "time value out of range (%"PRId64") of time_t", val); + tvherror(LS_MAIN, "time value out of range (%"PRId64") of time_t", val); } diff --git a/src/muxer.c b/src/muxer.c index af8240509..c6bb6ef2e 100644 --- a/src/muxer.c +++ b/src/muxer.c @@ -261,8 +261,8 @@ muxer_create(const muxer_config_t *m_cfg) #endif if(!m) { - tvhlog(LOG_ERR, "mux", "Can't find a muxer that supports '%s' container", - muxer_container_type2txt(m_cfg->m_type)); + tvherror(LS_MUXER, "Can't find a muxer that supports '%s' container", + muxer_container_type2txt(m_cfg->m_type)); return NULL; } diff --git a/src/muxer/muxer_libav.c b/src/muxer/muxer_libav.c index 83f0c3066..3219fddad 100644 --- a/src/muxer/muxer_libav.c +++ b/src/muxer/muxer_libav.c @@ -316,16 +316,16 @@ lav_muxer_init(muxer_t* m, struct streaming_start *ss, const char *name) continue; if(!lav_muxer_support_stream(lm->m_config.m_type, ssc->ssc_type)) { - tvhlog(LOG_WARNING, "libav", "%s is not supported in %s", - streaming_component_type2txt(ssc->ssc_type), - muxer_container_type2txt(lm->m_config.m_type)); + tvhwarn(LS_LIBAV, "%s is not supported in %s", + streaming_component_type2txt(ssc->ssc_type), + muxer_container_type2txt(lm->m_config.m_type)); ssc->ssc_muxer_disabled = 1; continue; } if(lav_muxer_add_stream(lm, ssc)) { - tvhlog(LOG_ERR, "libav", "Failed to add %s stream", - streaming_component_type2txt(ssc->ssc_type)); + tvherror(LS_LIBAV, "Failed to add %s stream", + streaming_component_type2txt(ssc->ssc_type)); ssc->ssc_muxer_disabled = 1; continue; } @@ -337,12 +337,12 @@ lav_muxer_init(muxer_t* m, struct streaming_start *ss, const char *name) } if(!lm->lm_oc->nb_streams) { - tvhlog(LOG_ERR, "libav", "No supported streams available"); + tvherror(LS_LIBAV, "No supported streams available"); lm->m_errors++; return -1; } else if(avformat_write_header(lm->lm_oc, &opts) < 0) { - tvhlog(LOG_ERR, "libav", "Failed to write %s header", - muxer_container_type2txt(lm->m_config.m_type)); + tvherror(LS_LIBAV, "Failed to write %s header", + muxer_container_type2txt(lm->m_config.m_type)); lm->m_errors++; return -1; } @@ -404,15 +404,15 @@ lav_muxer_open_file(muxer_t *m, const char *filename) if((r = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) { av_strerror(r, buf, sizeof(buf)); - tvhlog(LOG_ERR, "libav", "%s: Could not open -- %s", filename, buf); + tvherror(LS_LIBAV, "%s: Could not open -- %s", filename, buf); lm->m_errors++; return -1; } /* bypass umask settings */ if (chmod(filename, lm->m_config.m_file_permissions)) - tvhlog(LOG_ERR, "libav", "%s: Unable to change permissions -- %s", - filename, strerror(errno)); + tvherror(LS_LIBAV, "%s: Unable to change permissions -- %s", + filename, strerror(errno)); return 0; } @@ -439,13 +439,13 @@ lav_muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data) oc = lm->lm_oc; if(!oc->nb_streams) { - tvhlog(LOG_ERR, "libav", "No streams to mux"); + tvherror(LS_LIBAV, "No streams to mux"); rc = -1; goto ret; } if(!lm->lm_init) { - tvhlog(LOG_ERR, "libav", "Muxer not initialized correctly"); + tvherror(LS_LIBAV, "Muxer not initialized correctly"); rc = -1; goto ret; } @@ -475,7 +475,7 @@ lav_muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data) pktbuf_ptr(pkt->pkt_payload), pktbuf_len(pkt->pkt_payload), pkt->pkt_frametype < PKT_P_FRAME) < 0) { - tvhlog(LOG_WARNING, "libav", "Failed to filter bitstream"); + tvhwarn(LS_LIBAV, "Failed to filter bitstream"); if (packet.data != pktbuf_ptr(pkt->pkt_payload)) av_free(packet.data); break; @@ -507,7 +507,7 @@ lav_muxer_write_pkt(muxer_t *m, streaming_message_type_t smt, void *data) packet.flags |= AV_PKT_FLAG_KEY; if((rc = av_interleaved_write_frame(oc, &packet))) - tvhlog(LOG_WARNING, "libav", "Failed to write frame"); + tvhwarn(LS_LIBAV, "Failed to write frame"); if(tofree && tofree != pktbuf_ptr(pkt->pkt_payload)) av_free(tofree); @@ -553,8 +553,8 @@ lav_muxer_close(muxer_t *m) lav_muxer_t *lm = (lav_muxer_t*)m; if(lm->lm_init && av_write_trailer(lm->lm_oc) < 0) { - tvhlog(LOG_WARNING, "libav", "Failed to write %s trailer", - muxer_container_type2txt(lm->m_config.m_type)); + tvhwarn(LS_LIBAV, "Failed to write %s trailer", + muxer_container_type2txt(lm->m_config.m_type)); lm->m_errors++; ret = -1; } @@ -628,7 +628,7 @@ lav_muxer_create(const muxer_config_t *m_cfg) fmt = av_guess_format(mux_name, NULL, NULL); if(!fmt) { - tvhlog(LOG_ERR, "libav", "Can't find the '%s' muxer", mux_name); + tvherror(LS_LIBAV, "Can't find the '%s' muxer", mux_name); return NULL; } diff --git a/src/muxer/muxer_mkv.c b/src/muxer/muxer_mkv.c index c38e9e431..b44e1430d 100644 --- a/src/muxer/muxer_mkv.c +++ b/src/muxer/muxer_mkv.c @@ -255,7 +255,7 @@ mk_build_tracks(mk_muxer_t *mk, streaming_start_t *ss) tr->nextpts = PTS_UNSET; if (mk->webm && ssc->ssc_type != SCT_VP8 && ssc->ssc_type != SCT_VORBIS) - tvhwarn("mkv", "WEBM format supports only VP8+VORBIS streams (detected %s)", + tvhwarn(LS_MKV, "WEBM format supports only VP8+VORBIS streams (detected %s)", streaming_component_type2txt(ssc->ssc_type)); switch(ssc->ssc_type) { @@ -499,8 +499,7 @@ static void mk_write_queue(mk_muxer_t *mk, htsbuf_queue_t *q) { if(!mk->error && mk_write_to_fd(mk, q) && !MC_IS_EOS_ERROR(mk->error)) - tvhlog(LOG_ERR, "mkv", "%s: Write failed -- %s", mk->filename, - strerror(errno)); + tvherror(LS_MKV, "%s: Write failed -- %s", mk->filename, strerror(errno)); htsbuf_queue_flush(q); } @@ -1181,8 +1180,8 @@ mk_mux_close(mk_muxer_t *mk) mk_write_master(mk, 0x1549a966, mk_build_segment_info(mk)); else { mk->error = errno; - tvhlog(LOG_ERR, "mkv", "%s: Unable to write duration, seek failed -- %s", - mk->filename, strerror(errno)); + tvherror(LS_MKV, "%s: Unable to write duration, seek failed -- %s", + mk->filename, strerror(errno)); } // Rewrite segment header to update total size @@ -1190,14 +1189,14 @@ mk_mux_close(mk_muxer_t *mk) mk_write_segment_header(mk, totsize - mk->segment_header_pos - 12); } else { mk->error = errno; - tvhlog(LOG_ERR, "mkv", "%s: Unable to write total size, seek failed -- %s", - mk->filename, strerror(errno)); + tvherror(LS_MKV, "%s: Unable to write total size, seek failed -- %s", + mk->filename, strerror(errno)); } if(close(mk->fd)) { mk->error = errno; - tvhlog(LOG_ERR, "mkv", "%s: Unable to close the file descriptor, close failed -- %s", - mk->filename, strerror(errno)); + tvherror(LS_MKV, "%s: Unable to close the file descriptor, close failed -- %s", + mk->filename, strerror(errno)); } } @@ -1334,23 +1333,23 @@ mkv_muxer_open_file(muxer_t *m, const char *filename) mk_muxer_t *mk = (mk_muxer_t*)m; int fd, permissions = mk->m_config.m_file_permissions; - tvhtrace("mkv", "Creating file \"%s\" with file permissions \"%o\"", + tvhtrace(LS_MKV, "Creating file \"%s\" with file permissions \"%o\"", filename, permissions); fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, permissions); if(fd < 0) { mk->error = errno; - tvhlog(LOG_ERR, "mkv", "%s: Unable to create file, open failed -- %s", - mk->filename, strerror(errno)); + tvherror(LS_MKV, "%s: Unable to create file, open failed -- %s", + mk->filename, strerror(errno)); mk->m_errors++; return -1; } /* bypass umask settings */ if (fchmod(fd, permissions)) - tvhlog(LOG_ERR, "mkv", "%s: Unable to change permissions -- %s", - filename, strerror(errno)); + tvherror(LS_MKV, "%s: Unable to change permissions -- %s", + filename, strerror(errno)); mk->filename = strdup(filename); mk->fd = fd; diff --git a/src/muxer/muxer_pass.c b/src/muxer/muxer_pass.c index c569bd81e..d4a228e6f 100644 --- a/src/muxer/muxer_pass.c +++ b/src/muxer/muxer_pass.c @@ -142,7 +142,7 @@ pass_muxer_pmt_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) return; if (sizeof(out) < ol + l + 5 + 4 /* crc */) { - tvherror("pass", "PMT entry too long (%i)", l); + tvherror(LS_PASS, "PMT entry too long (%i)", l); return; } @@ -201,7 +201,7 @@ pass_muxer_sdt_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) continue; } if (sizeof(out) < ol + l + 5 + 4 /* crc */) { - tvherror("pass", "SDT entry too long (%i)", l); + tvherror(LS_PASS, "SDT entry too long (%i)", l); return; } memcpy(out + ol, buf, l + 5); @@ -315,11 +315,11 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) if (!SCT_ISVIDEO(ssc->ssc_type) && !SCT_ISAUDIO(ssc->ssc_type)) continue; if (ssc->ssc_pid == DVB_SDT_PID && pm->pm_rewrite_sdt) { - tvhwarn("pass", "SDT PID shared with A/V, rewrite disabled"); + tvhwarn(LS_PASS, "SDT PID shared with A/V, rewrite disabled"); pm->pm_rewrite_sdt = 0; } if (ssc->ssc_pid == DVB_EIT_PID && pm->pm_rewrite_eit) { - tvhwarn("pass", "EIT PID shared with A/V, rewrite disabled"); + tvhwarn(LS_PASS, "EIT PID shared with A/V, rewrite disabled"); pm->pm_rewrite_eit = 0; } } @@ -332,7 +332,7 @@ pass_muxer_reconfigure(muxer_t* m, const struct streaming_start *ss) pm->pm_ss = streaming_start_copy(ss); dvb_table_parse_done(&pm->pm_pmt); - dvb_table_parse_init(&pm->pm_pmt, "pass-pmt", pm->pm_pmt_pid, pm); + dvb_table_parse_init(&pm->pm_pmt, "pass-pmt", LS_TBL_PASS, pm->pm_pmt_pid, pm); } return 0; @@ -375,22 +375,22 @@ pass_muxer_open_file(muxer_t *m, const char *filename) int fd; pass_muxer_t *pm = (pass_muxer_t*)m; - tvhtrace("pass", "Creating file \"%s\" with file permissions \"%o\"", filename, pm->m_config.m_file_permissions); + tvhtrace(LS_PASS, "Creating file \"%s\" with file permissions \"%o\"", filename, pm->m_config.m_file_permissions); fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, pm->m_config.m_file_permissions); if(fd < 0) { pm->pm_error = errno; - tvhlog(LOG_ERR, "pass", "%s: Unable to create file, open failed -- %s", - filename, strerror(errno)); + tvherror(LS_PASS, "%s: Unable to create file, open failed -- %s", + filename, strerror(errno)); pm->m_errors++; return -1; } /* bypass umask settings */ if (fchmod(fd, pm->m_config.m_file_permissions)) - tvhlog(LOG_ERR, "pass", "%s: Unable to change permissions -- %s", - filename, strerror(errno)); + tvherror(LS_PASS, "%s: Unable to change permissions -- %s", + filename, strerror(errno)); pm->pm_off = 0; pm->pm_seekable = 1; @@ -413,8 +413,8 @@ pass_muxer_write(muxer_t *m, const void *data, size_t size) } else if(tvh_write(pm->pm_fd, data, size)) { pm->pm_error = errno; if (!MC_IS_EOS_ERROR(errno)) - tvhlog(LOG_ERR, "pass", "%s: Write failed -- %s", pm->pm_filename, - strerror(errno)); + tvherror(LS_PASS, "%s: Write failed -- %s", pm->pm_filename, + strerror(errno)); else /* this is an end-of-streaming notification */ m->m_eos = 1; @@ -543,8 +543,8 @@ pass_muxer_close(muxer_t *m) if(pm->pm_seekable && close(pm->pm_fd)) { pm->pm_error = errno; - tvhlog(LOG_ERR, "pass", "%s: Unable to close file, close failed -- %s", - pm->pm_filename, strerror(errno)); + tvherror(LS_PASS, "%s: Unable to close file, close failed -- %s", + pm->pm_filename, strerror(errno)); pm->m_errors++; return -1; } @@ -599,10 +599,10 @@ pass_muxer_create(const muxer_config_t *m_cfg) pm->m_destroy = pass_muxer_destroy; pm->pm_fd = -1; - dvb_table_parse_init(&pm->pm_pat, "pass-pat", DVB_PAT_PID, pm); - dvb_table_parse_init(&pm->pm_pmt, "pass-pmt", 100, pm); - dvb_table_parse_init(&pm->pm_sdt, "pass-sdt", DVB_SDT_PID, pm); - dvb_table_parse_init(&pm->pm_eit, "pass-eit", DVB_EIT_PID, pm); + dvb_table_parse_init(&pm->pm_pat, "pass-pat", LS_TBL_PASS, DVB_PAT_PID, pm); + dvb_table_parse_init(&pm->pm_pmt, "pass-pmt", LS_TBL_PASS, 100, pm); + dvb_table_parse_init(&pm->pm_sdt, "pass-sdt", LS_TBL_PASS, DVB_SDT_PID, pm); + dvb_table_parse_init(&pm->pm_eit, "pass-eit", LS_TBL_PASS, DVB_EIT_PID, pm); return (muxer_t *)pm; } diff --git a/src/packet.c b/src/packet.c index 84bd89486..18e4b7048 100644 --- a/src/packet.c +++ b/src/packet.c @@ -147,7 +147,7 @@ pkt_ref_inc_poly(th_pkt_t *pkt, int n) * */ void -pkt_trace_(const char *file, int line, const char *subsys, th_pkt_t *pkt, +pkt_trace_(const char *file, int line, int subsys, th_pkt_t *pkt, int index, streaming_component_type_t type, const char *fmt, ...) { char buf[512], _dts[22], _pts[22], _type[2]; diff --git a/src/packet.h b/src/packet.h index 77f0bce8b..88339e6f3 100644 --- a/src/packet.h +++ b/src/packet.h @@ -120,7 +120,7 @@ th_pkt_t *pkt_copy_nodata(th_pkt_t *pkt); th_pktref_t *pktref_create(th_pkt_t *pkt); void pkt_trace_ - (const char *file, int line, const char *subsys, th_pkt_t *pkt, + (const char *file, int line, int subsys, th_pkt_t *pkt, int index, streaming_component_type_t type, const char *fmt, ...); #define pkt_trace(subsys, pkt, index, type, fmt, ...) \ diff --git a/src/parsers/parser_h264.c b/src/parsers/parser_h264.c index a51da34f4..05fc6ae8e 100644 --- a/src/parsers/parser_h264.c +++ b/src/parsers/parser_h264.c @@ -428,7 +428,7 @@ h264_decode_slice_header(elementary_stream_t *st, bitstream_t *bs, int *pkttype, if (sps->time_scale) d = 180000 * (uint64_t)sps->units_in_tick / (uint64_t)sps->time_scale; if (d == 0 && st->es_frame_duration < 2 && p->start + sec2mono(4) < mclk()) { - tvhwarn("parser", "H264 stream has not timing information, using 30fps"); + tvhwarn(LS_PARSER, "H264 stream has not timing information, using 30fps"); d = 3000; /* 90000/30 = 3000 : 30fps */ } diff --git a/src/parsers/parser_hevc.c b/src/parsers/parser_hevc.c index cc212b0ec..cb713be41 100644 --- a/src/parsers/parser_hevc.c +++ b/src/parsers/parser_hevc.c @@ -885,49 +885,49 @@ static int hvcc_write(sbuf_t *pb, HEVCDecoderConfigurationRecord *hvcc) hvcc->avgFrameRate = 0; hvcc->constantFrameRate = 0; - tvhtrace("hevc", "configurationVersion: %"PRIu8, + tvhtrace(LS_HEVC, "configurationVersion: %"PRIu8, hvcc->configurationVersion); - tvhtrace("hevc", "general_profile_space: %"PRIu8, + tvhtrace(LS_HEVC, "general_profile_space: %"PRIu8, hvcc->general_profile_space); - tvhtrace("hevc", "general_tier_flag: %"PRIu8, + tvhtrace(LS_HEVC, "general_tier_flag: %"PRIu8, hvcc->general_tier_flag); - tvhtrace("hevc", "general_profile_idc: %"PRIu8, + tvhtrace(LS_HEVC, "general_profile_idc: %"PRIu8, hvcc->general_profile_idc); - tvhtrace("hevc", "general_profile_compatibility_flags: 0x%08"PRIx32, + tvhtrace(LS_HEVC, "general_profile_compatibility_flags: 0x%08"PRIx32, hvcc->general_profile_compatibility_flags); - tvhtrace("hevc", "general_constraint_indicator_flags: 0x%012"PRIx64, + tvhtrace(LS_HEVC, "general_constraint_indicator_flags: 0x%012"PRIx64, hvcc->general_constraint_indicator_flags); - tvhtrace("hevc", "general_level_idc: %"PRIu8, + tvhtrace(LS_HEVC, "general_level_idc: %"PRIu8, hvcc->general_level_idc); - tvhtrace("hevc", "min_spatial_segmentation_idc: %"PRIu16, + tvhtrace(LS_HEVC, "min_spatial_segmentation_idc: %"PRIu16, hvcc->min_spatial_segmentation_idc); - tvhtrace("hevc", "parallelismType: %"PRIu8, + tvhtrace(LS_HEVC, "parallelismType: %"PRIu8, hvcc->parallelismType); - tvhtrace("hevc", "chromaFormat: %"PRIu8, + tvhtrace(LS_HEVC, "chromaFormat: %"PRIu8, hvcc->chromaFormat); - tvhtrace("hevc", "bitDepthLumaMinus8: %"PRIu8, + tvhtrace(LS_HEVC, "bitDepthLumaMinus8: %"PRIu8, hvcc->bitDepthLumaMinus8); - tvhtrace("hevc", "bitDepthChromaMinus8: %"PRIu8, + tvhtrace(LS_HEVC, "bitDepthChromaMinus8: %"PRIu8, hvcc->bitDepthChromaMinus8); - tvhtrace("hevc", "avgFrameRate: %"PRIu16, + tvhtrace(LS_HEVC, "avgFrameRate: %"PRIu16, hvcc->avgFrameRate); - tvhtrace("hevc", "constantFrameRate: %"PRIu8, + tvhtrace(LS_HEVC, "constantFrameRate: %"PRIu8, hvcc->constantFrameRate); - tvhtrace("hevc", "numTemporalLayers: %"PRIu8, + tvhtrace(LS_HEVC, "numTemporalLayers: %"PRIu8, hvcc->numTemporalLayers); - tvhtrace("hevc", "temporalIdNested: %"PRIu8, + tvhtrace(LS_HEVC, "temporalIdNested: %"PRIu8, hvcc->temporalIdNested); - tvhtrace("hevc", "lengthSizeMinusOne: %"PRIu8, + tvhtrace(LS_HEVC, "lengthSizeMinusOne: %"PRIu8, hvcc->lengthSizeMinusOne); - tvhtrace("hevc", "numOfArrays: %"PRIu8, + tvhtrace(LS_HEVC, "numOfArrays: %"PRIu8, hvcc->numOfArrays); for (i = 0; i < hvcc->numOfArrays; i++) { - tvhtrace("hevc", "NAL_unit_type[%"PRIu8"]: %"PRIu8, + tvhtrace(LS_HEVC, "NAL_unit_type[%"PRIu8"]: %"PRIu8, i, hvcc->array[i].NAL_unit_type); - tvhtrace("hevc", "numNalus[%"PRIu8"]: %"PRIu16, + tvhtrace(LS_HEVC, "numNalus[%"PRIu8"]: %"PRIu16, i, hvcc->array[i].numNalus); for (j = 0; j < hvcc->array[i].numNalus; j++) - tvhtrace("hevc", + tvhtrace(LS_HEVC, "nalUnitLength[%"PRIu8"][%"PRIu16"]: %"PRIu16, i, j, hvcc->array[i].nalUnitLength[j]); } diff --git a/src/parsers/parsers.c b/src/parsers/parsers.c index 6151641bc..f73bd3e22 100644 --- a/src/parsers/parsers.c +++ b/src/parsers/parsers.c @@ -338,7 +338,7 @@ parse_aac(service_t *t, elementary_stream_t *st, const uint8_t *data, /* Wrong bytestream */ } else { - tvhtrace("parser", "AAC skip byte %02x", d[0]); + tvhtrace(LS_PARSER, "AAC skip byte %02x", d[0]); p++; } } @@ -366,7 +366,7 @@ parse_pes(service_t *t, elementary_stream_t *st, const uint8_t *data, int len, st->es_parser_state = 1; if (data[0] != 0 && data[1] != 0 && data[2] != 1) if (tvhlog_limit(&st->es_pes_log, 10)) - tvhwarn("TS", "%s: Invalid start code %02x:%02x:%02x", + tvhwarn(LS_TS, "%s: Invalid start code %02x:%02x:%02x", service_component_nicename(st), data[0], data[1], data[2]); st->es_incomplete = 0; @@ -977,7 +977,7 @@ parse_pes_header(service_t *t, elementary_stream_t *st, st->es_curdts = PTS_UNSET; st->es_curpts = PTS_UNSET; if (tvhlog_limit(&st->es_pes_log, 10)) - tvhwarn("TS", "%s Corrupted PES header (errors %zi)", + tvhwarn(LS_TS, "%s Corrupted PES header (errors %zi)", service_component_nicename(st), st->es_pes_log.count); return -1; } @@ -1822,7 +1822,7 @@ parser_deliver(service_t *t, elementary_stream_t *st, th_pkt_t *pkt) pkt->pkt_pts < t->s_current_pts - 180000)) t->s_current_pts = pkt->pkt_pts; - pkt_trace("parser", pkt, st->es_index, st->es_type, "deliver"); + pkt_trace(LS_PARSER, pkt, st->es_index, st->es_type, "deliver"); pkt->pkt_aspect_num = st->es_aspect_num; pkt->pkt_aspect_den = st->es_aspect_den; @@ -1877,7 +1877,7 @@ parser_backlog(service_t *t, elementary_stream_t *st, th_pkt_t *pkt) int64_t pts = pkt->pkt_pts; pkt->pkt_dts = pts_no_backlog(dts); pkt->pkt_pts = pts_no_backlog(pts); - pkt_trace("parser", pkt, st->es_index, st->es_type, "backlog"); + pkt_trace(LS_PARSER, pkt, st->es_index, st->es_type, "backlog"); pkt->pkt_dts = dts; pkt->pkt_pts = pts; } @@ -1895,7 +1895,7 @@ parser_do_backlog(service_t *t, elementary_stream_t *st, th_pkt_t *pkt, *npkt; size_t metalen; - tvhtrace("parser", + tvhtrace(LS_PARSER, "pkt bcklog %2d %-12s - backlog flush start - (meta %ld)", st->es_index, streaming_component_type2txt(st->es_type), @@ -1966,7 +1966,7 @@ parser_do_backlog(service_t *t, elementary_stream_t *st, sm->sm_data = NULL; streaming_msg_free(sm); } - tvhtrace("parser", + tvhtrace(LS_PARSER, "pkt bcklog %2d %-12s - backlog flush end -", st->es_index, streaming_component_type2txt(st->es_type)); diff --git a/src/plumbing/globalheaders.c b/src/plumbing/globalheaders.c index 13b023259..0a6e14d1e 100644 --- a/src/plumbing/globalheaders.c +++ b/src/plumbing/globalheaders.c @@ -237,7 +237,7 @@ headers_complete(globalheaders_t *gh) */ if(threshold || (qd[i] <= 0 && qd_max > (MAX_SCAN_TIME * 90) / 2)) { ssc->ssc_disabled = 1; - tvhdebug("parser", "gh disable stream %d %s%s%s (PID %i) threshold %d qd %"PRId64" qd_max %"PRId64, + tvhdebug(LS_TSFIX, "gh disable stream %d %s%s%s (PID %i) threshold %d qd %"PRId64" qd_max %"PRId64, ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), ssc->ssc_lang[0] ? " " : "", ssc->ssc_lang, ssc->ssc_pid, threshold, qd[i], qd_max); @@ -252,7 +252,7 @@ headers_complete(globalheaders_t *gh) if (tvhtrace_enabled()) { for(i = 0; i < ss->ss_num_components; i++) { ssc = &ss->ss_components[i]; - tvhtrace("parser", "stream %d %s%s%s (PID %i) complete time %"PRId64"%s", + tvhtrace(LS_TSFIX, "stream %d %s%s%s (PID %i) complete time %"PRId64"%s", ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), ssc->ssc_lang[0] ? " " : "", ssc->ssc_lang, ssc->ssc_pid, gh_queue_delay(gh, ssc->ssc_index), @@ -290,7 +290,7 @@ gh_hold(globalheaders_t *gh, streaming_message_t *sm) ssc = streaming_start_component_find_by_index(gh->gh_ss, pkt->pkt_componentindex); if (ssc == NULL) { - tvherror("globalheaders", "Unable to find component %d", pkt->pkt_componentindex); + tvherror(LS_GLOBALHEADERS, "Unable to find component %d", pkt->pkt_componentindex); streaming_msg_free(sm); return; } diff --git a/src/plumbing/transcoding.c b/src/plumbing/transcoding.c index bbab774be..dda30d8af 100644 --- a/src/plumbing/transcoding.c +++ b/src/plumbing/transcoding.c @@ -182,7 +182,7 @@ transcode_opt_set_int(transcoder_t *t, transcoder_stream_t *ts, { int opt_error; if ((opt_error = av_opt_set_int(ctx, opt, val, 0)) != 0) { - tvherror("transcode", "%04X: Could not set option %s (error '%s')", + tvherror(LS_TRANSCODE, "%04X: Could not set option %s (error '%s')", shortid(t), opt, get_error_text(opt_error)); if (abort) transcoder_stream_invalidate(ts); @@ -336,19 +336,19 @@ transcoder_get_decoder(transcoder_t *t, streaming_component_type_t ty) codec_id = streaming_component_type2codec_id(ty); if (codec_id == AV_CODEC_ID_NONE) { - tvherror("transcode", "%04X: Unsupported input codec %s", + tvherror(LS_TRANSCODE, "%04X: Unsupported input codec %s", shortid(t), streaming_component_type2txt(ty)); return NULL; } codec = avcodec_find_decoder(codec_id); if (!codec) { - tvherror("transcode", "%04X: Unable to find %s decoder", + tvherror(LS_TRANSCODE, "%04X: Unable to find %s decoder", shortid(t), streaming_component_type2txt(ty)); return NULL; } - tvhtrace("transcode", "%04X: Using decoder %s", shortid(t), codec->name); + tvhtrace(LS_TRANSCODE, "%04X: Using decoder %s", shortid(t), codec->name); return codec; } @@ -364,11 +364,11 @@ transcoder_get_encoder(transcoder_t *t, const char *codec_name) codec = avcodec_find_encoder_by_name(codec_name); if (!codec) { - tvherror("transcode", "%04X: Unable to find %s encoder", + tvherror(LS_TRANSCODE, "%04X: Unable to find %s encoder", shortid(t), codec_name); return NULL; } - tvhtrace("transcode", "%04X: Using encoder %s", shortid(t), codec->name); + tvhtrace(LS_TRANSCODE, "%04X: Using encoder %s", shortid(t), codec->name); return codec; } @@ -382,7 +382,7 @@ transcoder_stream_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt { streaming_message_t *sm; - tvhtrace("transcode", "%04X: deliver copy (pts = %" PRIu64 ")", + tvhtrace(LS_TRANSCODE, "%04X: deliver copy (pts = %" PRIu64 ")", shortid(t), pkt->pkt_pts); sm = streaming_msg_create_pkt(pkt); streaming_target_deliver2(ts->ts_target, sm); @@ -414,7 +414,7 @@ transcoder_stream_subtitle(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *p if (!avcodec_is_open(ictx)) { if (avcodec_open2(ictx, icodec, NULL) < 0) { - tvherror("transcode", "%04X: Unable to open %s decoder", + tvherror(LS_TRANSCODE, "%04X: Unable to open %s decoder", shortid(t), icodec->name); transcoder_stream_invalidate(ts); return; @@ -433,7 +433,7 @@ transcoder_stream_subtitle(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *p length = avcodec_decode_subtitle2(ictx, &sub, &got_subtitle, &packet); if (length <= 0) { if (length == AVERROR_INVALIDDATA) goto cleanup; - tvherror("transcode", "%04X: Unable to decode subtitle (%d, %s)", + tvherror(LS_TRANSCODE, "%04X: Unable to decode subtitle (%d, %s)", shortid(t), length, get_error_text(length)); goto cleanup; } @@ -507,13 +507,13 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) memcpy(ictx->extradata, pktbuf_ptr(ts->ts_input_gh), pktbuf_len(ts->ts_input_gh)); } else { - tvherror("transcode", "%04X: missing meta data for %s", + tvherror(LS_TRANSCODE, "%04X: missing meta data for %s", shortid(t), icodec->id == AV_CODEC_ID_AAC ? "AAC" : "VORBIS"); } } if (avcodec_open2(ictx, icodec, NULL) < 0) { - tvherror("transcode", "%04X: Unable to open %s decoder", + tvherror(LS_TRANSCODE, "%04X: Unable to open %s decoder", shortid(t), icodec->name); transcoder_stream_invalidate(ts); goto cleanup; @@ -523,7 +523,7 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) } if (pkt->pkt_pts > as->aud_dec_pts) { - tvhwarn("transcode", "%04X: Detected framedrop in audio", shortid(t)); + tvhwarn(LS_TRANSCODE, "%04X: Detected framedrop in audio", shortid(t)); as->aud_enc_pts += (pkt->pkt_pts - as->aud_dec_pts); as->aud_dec_pts += (pkt->pkt_pts - as->aud_dec_pts); } @@ -537,24 +537,24 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) length = avcodec_decode_audio4(ictx, frame, &got_frame, &packet); av_free_packet(&packet); - tvhtrace("transcode", "%04X: audio decode: consumed=%d size=%zu, got=%d, pts=%" PRIi64, + tvhtrace(LS_TRANSCODE, "%04X: audio decode: consumed=%d size=%zu, got=%d, pts=%" PRIi64, shortid(t), length, pktbuf_len(pkt->pkt_payload), got_frame, pkt->pkt_pts); if (length < 0) { if (length == AVERROR_INVALIDDATA) goto cleanup; - tvherror("transcode", "%04X: Unable to decode audio (%d, %s)", + tvherror(LS_TRANSCODE, "%04X: Unable to decode audio (%d, %s)", shortid(t), length, get_error_text(length)); transcoder_stream_invalidate(ts); goto cleanup; } if (!got_frame) { - tvhtrace("transcode", "%04X: Did not have a full frame in the packet", shortid(t)); + tvhtrace(LS_TRANSCODE, "%04X: Did not have a full frame in the packet", shortid(t)); goto cleanup; } if (length != pktbuf_len(pkt->pkt_payload)) - tvhwarn("transcode", + tvhwarn(LS_TRANSCODE, "%04X: undecoded data (in=%zu, consumed=%d)", shortid(t), pktbuf_len(pkt->pkt_payload), length); @@ -569,30 +569,30 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) octx->flags |= CODEC_FLAG_GLOBAL_HEADER; if (!octx->sample_rate) { - tvherror("transcode", "%04X: audio encoder has no suitable sample rate!", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: audio encoder has no suitable sample rate!", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } else { - tvhdebug("transcode", "%04X: using audio sample rate %d", + tvhdebug(LS_TRANSCODE, "%04X: using audio sample rate %d", shortid(t), octx->sample_rate); } if (octx->sample_fmt == AV_SAMPLE_FMT_NONE) { - tvherror("transcode", "%04X: audio encoder has no suitable sample format!", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: audio encoder has no suitable sample format!", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } else { - tvhdebug("transcode", "%04X: using audio sample format %s", + tvhdebug(LS_TRANSCODE, "%04X: using audio sample format %s", shortid(t), av_get_sample_fmt_name(octx->sample_fmt)); } if (!octx->channel_layout) { - tvherror("transcode", "%04X: audio encoder has no suitable channel layout!", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: audio encoder has no suitable channel layout!", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } else { av_get_channel_layout_string(layout_buf, sizeof (layout_buf), octx->channels, octx->channel_layout); - tvhdebug("transcode", "%04X: using audio channel layout %s", + tvhdebug(LS_TRANSCODE, "%04X: using audio channel layout %s", shortid(t), layout_buf); } @@ -636,7 +636,7 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) } if (avcodec_open2(octx, ocodec, NULL) < 0) { - tvherror("transcode", "%04X: Unable to open %s encoder", + tvherror(LS_TRANSCODE, "%04X: Unable to open %s encoder", shortid(t), ocodec->name); transcoder_stream_invalidate(ts); goto cleanup; @@ -644,7 +644,7 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) as->fifo = av_audio_fifo_alloc(octx->sample_fmt, octx->channels, 1); if (!as->fifo) { - tvherror("transcode", "%04X: Could not allocate fifo", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not allocate fifo", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -660,14 +660,14 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) if (as->last_sample_rate != ictx->sample_rate || as->last_sample_fmt != ictx->sample_fmt || as->last_channel_layout != ictx->channel_layout) { - tvhdebug("transcode", "%04X: audio input format changed", shortid(t)); + tvhdebug(LS_TRANSCODE, "%04X: audio input format changed", shortid(t)); as->last_sample_rate = ictx->sample_rate; as->last_sample_fmt = ictx->sample_fmt; as->last_channel_layout = ictx->channel_layout; if (as->resample_context) { - tvhdebug("transcode", "%04X: stopping audio resampling", shortid(t)); + tvhdebug(LS_TRANSCODE, "%04X: stopping audio resampling", shortid(t)); avresample_free(&as->resample_context); as->resample_context = NULL; as->resample_is_open = 0; @@ -681,21 +681,21 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) if (as->resample) { if (!as->resample_context) { if (!(as->resample_context = avresample_alloc_context())) { - tvherror("transcode", "%04X: Could not allocate resample context", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not allocate resample context", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } // resample audio - tvhdebug("transcode", "%04X: starting audio resampling", shortid(t)); + tvhdebug(LS_TRANSCODE, "%04X: starting audio resampling", shortid(t)); av_get_channel_layout_string(layout_buf, sizeof (layout_buf), ictx->channels, ictx->channel_layout); - tvhdebug("transcode", "%04X: IN : channel_layout=%s, rate=%d, fmt=%s, bitrate=%"PRId64, + tvhdebug(LS_TRANSCODE, "%04X: IN : channel_layout=%s, rate=%d, fmt=%s, bitrate=%"PRId64, shortid(t), layout_buf, ictx->sample_rate, av_get_sample_fmt_name(ictx->sample_fmt), (int64_t)ictx->bit_rate); av_get_channel_layout_string(layout_buf, sizeof (layout_buf), octx->channels, octx->channel_layout); - tvhdebug("transcode", "%04X: OUT: channel_layout=%s, rate=%d, fmt=%s, bitrate=%"PRId64, + tvhdebug(LS_TRANSCODE, "%04X: OUT: channel_layout=%s, rate=%d, fmt=%s, bitrate=%"PRId64, shortid(t), layout_buf, octx->sample_rate, av_get_sample_fmt_name(octx->sample_fmt), (int64_t)octx->bit_rate); @@ -718,7 +718,7 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) "out_sample_fmt", octx->sample_fmt, 1)) goto cleanup; if (avresample_open(as->resample_context) < 0) { - tvherror("transcode", "%04X: Error avresample_open", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Error avresample_open", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -728,26 +728,26 @@ transcoder_stream_audio(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) uint8_t **output = alloca(octx->channels * sizeof(uint8_t *)); if (av_samples_alloc(output, NULL, octx->channels, frame->nb_samples, octx->sample_fmt, 1) < 0) { - tvherror("transcode", "%04X: av_resamples_alloc failed", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: av_resamples_alloc failed", shortid(t)); transcoder_stream_invalidate(ts); goto scleanup; } length = avresample_convert(as->resample_context, NULL, 0, frame->nb_samples, frame->extended_data, 0, frame->nb_samples); - tvhtrace("transcode", "%04X: avresample_convert: %d", shortid(t), length); + tvhtrace(LS_TRANSCODE, "%04X: avresample_convert: %d", shortid(t), length); while (avresample_available(as->resample_context) > 0) { length = avresample_read(as->resample_context, output, frame->nb_samples); if (length > 0) { if (av_audio_fifo_realloc(as->fifo, av_audio_fifo_size(as->fifo) + length) < 0) { - tvhlog(LOG_ERR, "transcode", "%04X: Could not reallocate FIFO", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not reallocate FIFO", shortid(t)); transcoder_stream_invalidate(ts); goto scleanup; } if (av_audio_fifo_write(as->fifo, (void **)output, length) < length) { - tvhlog(LOG_ERR, "transcode", "%04X: Could not write to FIFO", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not write to FIFO", shortid(t)); goto scleanup; } } @@ -764,7 +764,7 @@ scleanup: /* Need to find out where we are going to do this. Normally at the end. int delay_samples = avresample_get_delay(as->resample_context); if (delay_samples) { - tvhlog(LOG_DEBUG, "transcode", "%d samples in resamples delay buffer.", delay_samples); + tvhdebug(LS_TRANSCODE, "%d samples in resamples delay buffer.", delay_samples); goto cleanup; } */ @@ -772,13 +772,13 @@ scleanup: } else { if (av_audio_fifo_realloc(as->fifo, av_audio_fifo_size(as->fifo) + frame->nb_samples) < 0) { - tvherror("transcode", "%04X: Could not reallocate FIFO", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not reallocate FIFO", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } if (av_audio_fifo_write(as->fifo, (void **)frame->extended_data, frame->nb_samples) < frame->nb_samples) { - tvherror("transcode", "%04X: Could not write to FIFO", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not write to FIFO", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -788,7 +788,7 @@ scleanup: as->aud_dec_pts += pkt->pkt_duration; while (av_audio_fifo_size(as->fifo) >= octx->frame_size) { - tvhtrace("transcode", "%04X: audio loop: fifo=%d, frame=%d", + tvhtrace(LS_TRANSCODE, "%04X: audio loop: fifo=%d, frame=%d", shortid(t), av_audio_fifo_size(as->fifo), octx->frame_size); av_frame_free(&frame); @@ -801,18 +801,18 @@ scleanup: frame->channel_layout = octx->channel_layout; frame->sample_rate = octx->sample_rate; if (av_frame_get_buffer(frame, 0) < 0) { - tvherror("transcode", "%04X: Could not allocate output frame samples", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not allocate output frame samples", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } if ((length = av_audio_fifo_read(as->fifo, (void **)frame->data, octx->frame_size)) != octx->frame_size) { - tvherror("transcode", "%04X: Could not read data from FIFO", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Could not read data from FIFO", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } - tvhtrace("transcode", "%04X: pre-encode: linesize=%d, samples=%d, pts=%" PRIi64, + tvhtrace(LS_TRANSCODE, "%04X: pre-encode: linesize=%d, samples=%d, pts=%" PRIi64, shortid(t), frame->linesize[0], length, as->aud_enc_pts); frame->pts = as->aud_enc_pts; @@ -822,12 +822,12 @@ scleanup: packet.data = NULL; packet.size = 0; length = avcodec_encode_audio2(octx, &packet, frame, &got_packet_ptr); - tvhtrace("transcode", "%04X: encoded: packet=%d, ret=%d, got=%d, pts=%" PRIi64, + tvhtrace(LS_TRANSCODE, "%04X: encoded: packet=%d, ret=%d, got=%d, pts=%" PRIi64, shortid(t), packet.size, length, got_packet_ptr, packet.pts); if ((length < 0) || (got_packet_ptr < -1)) { - tvherror("transcode", "%04X: Unable to encode audio (%d:%d)", + tvherror(LS_TRANSCODE, "%04X: Unable to encode audio (%d:%d)", shortid(t), length, got_packet_ptr); transcoder_stream_invalidate(ts); goto cleanup; @@ -856,7 +856,7 @@ scleanup: if (octx->extradata_size) n->pkt_meta = pktbuf_alloc(octx->extradata, octx->extradata_size); - tvhtrace("transcode", "%04X: deliver audio (pts = %" PRIi64 ", delay = %i)", + tvhtrace(LS_TRANSCODE, "%04X: deliver audio (pts = %" PRIi64 ", delay = %i)", shortid(t), n->pkt_pts, octx->delay); sm = streaming_msg_create_pkt(n); streaming_target_deliver2(ts->ts_target, sm); @@ -948,7 +948,7 @@ send_video_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt, if (epkt->size <= 0) { if (epkt->size) { - tvherror("transcode", "%04X: Unable to encode video (%d)", shortid(t), epkt->size); + tvherror(LS_TRANSCODE, "%04X: Unable to encode video (%d)", shortid(t), epkt->size); transcoder_stream_invalidate(ts); } @@ -1010,7 +1010,7 @@ send_video_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt, extract_mpeg2_global_data(n, epkt->data, epkt->size); } - tvhtrace("transcode", "%04X: deliver video (dts = %" PRIu64 ", pts = %" PRIu64 ")", shortid(t), n->pkt_dts, n->pkt_pts); + tvhtrace(LS_TRANSCODE, "%04X: deliver video (dts = %" PRIu64 ", pts = %" PRIu64 ")", shortid(t), n->pkt_dts, n->pkt_pts); if (!vs->vid_first_encoded) { vs->vid_first_pkt = n; @@ -1022,7 +1022,7 @@ send_video_packet(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt, sm = streaming_msg_create_pkt(vs->vid_first_pkt); streaming_target_deliver2(ts->ts_target, sm); } else { - tvhtrace("transcode", "%04X: video skip first packet", shortid(t)); + tvhtrace(LS_TRANSCODE, "%04X: video skip first packet", shortid(t)); } pkt_ref_dec(vs->vid_first_pkt); vs->vid_first_pkt = NULL; @@ -1067,7 +1067,7 @@ create_video_filter(video_stream_t *vs, transcoder_t *t, flt_bufsrc = avfilter_get_by_name("buffer"); flt_bufsink = avfilter_get_by_name("buffersink"); if (!flt_bufsrc || !flt_bufsink) { - tvherror("transcode", "%04X: libav default buffers unknown", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: libav default buffers unknown", shortid(t)); goto out_err; } @@ -1084,14 +1084,14 @@ create_video_filter(video_stream_t *vs, transcoder_t *t, err = avfilter_graph_create_filter(&vs->flt_bufsrcctx, flt_bufsrc, "in", opt, NULL, vs->flt_graph); if (err < 0) { - tvherror("transcode", "%04X: fltchain IN init error", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: fltchain IN init error", shortid(t)); goto out_err; } err = avfilter_graph_create_filter(&vs->flt_bufsinkctx, flt_bufsink, "out", NULL, NULL, vs->flt_graph); if (err < 0) { - tvherror("transcode", "%04X: fltchain OUT init error", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: fltchain OUT init error", shortid(t)); goto out_err; } @@ -1099,7 +1099,7 @@ create_video_filter(video_stream_t *vs, transcoder_t *t, err = av_opt_set_int_list(vs->flt_bufsinkctx, "pix_fmts", pix_fmts, AV_PIX_FMT_NONE, AV_OPT_SEARCH_CHILDREN); if (err < 0) { - tvherror("transcode", "%08X: fltchain cannot set output pixfmt", + tvherror(LS_TRANSCODE, "%08X: fltchain cannot set output pixfmt", shortid(t)); goto out_err; } @@ -1124,13 +1124,13 @@ create_video_filter(video_stream_t *vs, transcoder_t *t, &flt_outputs, NULL); if (err < 0) { - tvherror("transcode", "%04X: failed to init filter chain", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: failed to init filter chain", shortid(t)); goto out_err; } err = avfilter_graph_config(vs->flt_graph, NULL); if (err < 0) { - tvherror("transcode", "%04X: failed to config filter chain", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: failed to config filter chain", shortid(t)); goto out_err; } @@ -1191,12 +1191,12 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) memcpy(ictx->extradata, pktbuf_ptr(ts->ts_input_gh), pktbuf_len(ts->ts_input_gh)); } else { - tvherror("transcode", "%04X: missing meta data for H264", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: missing meta data for H264", shortid(t)); } } if (avcodec_open2(ictx, icodec, NULL) < 0) { - tvherror("transcode", "%04X: Unable to open %s decoder", shortid(t), icodec->name); + tvherror(LS_TRANSCODE, "%04X: Unable to open %s decoder", shortid(t), icodec->name); transcoder_stream_invalidate(ts); goto cleanup; } @@ -1232,7 +1232,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) length = avcodec_decode_video2(ictx, vs->vid_dec_frame, &got_picture, &packet); if (length <= 0) { if (length == AVERROR_INVALIDDATA) goto cleanup; - tvherror("transcode", "%04X: Unable to decode video (%d, %s)", + tvherror(LS_TRANSCODE, "%04X: Unable to decode video (%d, %s)", shortid(t), length, get_error_text(length)); goto cleanup; } @@ -1337,7 +1337,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) // Default = "medium". We gain more encoding speed compared to the loss of quality when lowering it _slightly_. // select preset according to system performance and codec type av_dict_set(&opts, "preset", t->t_props.tp_vcodec_preset, 0); - tvhinfo("transcode", "%04X: Using preset %s", shortid(t), t->t_props.tp_vcodec_preset); + tvhinfo(LS_TRANSCODE, "%04X: Using preset %s", shortid(t), t->t_props.tp_vcodec_preset); // All modern devices should support "high" profile av_dict_set(&opts, "profile", "high", 0); @@ -1368,7 +1368,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) // on all hardware ultrafast (or maybe superfast) should be safe // select preset according to system performance av_dict_set(&opts, "preset", t->t_props.tp_vcodec_preset, 0); - tvhinfo("transcode", "%04X: Using preset %s", shortid(t), t->t_props.tp_vcodec_preset); + tvhinfo(LS_TRANSCODE, "%04X: Using preset %s", shortid(t), t->t_props.tp_vcodec_preset); // disables encoder features which tend to be bottlenecks for the decoder/player av_dict_set(&opts, "tune", "fastdecode", 0); @@ -1390,7 +1390,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) maxrate = ceil(bitrate * 1.25); bufsize = maxrate * 3; - tvhdebug("transcode", "tuning HEVC encoder for ABR rate control, " + tvhdebug(LS_TRANSCODE, "tuning HEVC encoder for ABR rate control, " "bitrate: %dkbps, vbv-bufsize: %dkbits, vbv-maxrate: %dkbps", bitrate, bufsize, maxrate); @@ -1413,14 +1413,14 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) } if (avcodec_open2(octx, ocodec, &opts) < 0) { - tvherror("transcode", "%04X: Unable to open %s encoder", + tvherror(LS_TRANSCODE, "%04X: Unable to open %s encoder", shortid(t), ocodec->name); transcoder_stream_invalidate(ts); goto cleanup; } if (create_video_filter(vs, t, ictx, octx)) { - tvherror("transcode", "%04X: Video filter creation failed", + tvherror(LS_TRANSCODE, "%04X: Video filter creation failed", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; @@ -1429,7 +1429,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) /* push decoded frame into filter chain */ if (av_buffersrc_add_frame(vs->flt_bufsrcctx, vs->vid_dec_frame) < 0) { - tvherror("transcode", "%04X: filter input error", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: filter input error", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -1441,7 +1441,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) break; if (ret < 0) { - tvherror("transcode", "%04X: filter output error", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: filter output error", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -1461,7 +1461,7 @@ transcoder_stream_video(transcoder_t *t, transcoder_stream_t *ts, th_pkt_t *pkt) ret = avcodec_encode_video2(octx, &packet2, vs->vid_enc_frame, &got_output); if (ret < 0) { - tvherror("transcode", "%04X: Error encoding frame", shortid(t)); + tvherror(LS_TRANSCODE, "%04X: Error encoding frame", shortid(t)); transcoder_stream_invalidate(ts); goto cleanup; } @@ -1545,7 +1545,7 @@ transcoder_init_stream(transcoder_t *t, streaming_start_component_t *ssc) pktbuf_ref_inc(ssc->ssc_gh); } - tvhinfo("transcode", "%04X: %d:%s ==> Passthrough", + tvhinfo(LS_TRANSCODE, "%04X: %d:%s ==> Passthrough", shortid(t), ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type)); @@ -1625,7 +1625,7 @@ transcoder_init_subtitle(transcoder_t *t, streaming_start_component_t *ssc) LIST_INSERT_HEAD(&t->t_stream_list, (transcoder_stream_t*)ss, ts_link); - tvhinfo("transcode", "%04X: %d:%s ==> %s (%s)", + tvhinfo(LS_TRANSCODE, "%04X: %d:%s ==> %s (%s)", shortid(t), ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), streaming_component_type2txt(ss->ts_type), @@ -1723,7 +1723,7 @@ transcoder_init_audio(transcoder_t *t, streaming_start_component_t *ssc) LIST_INSERT_HEAD(&t->t_stream_list, (transcoder_stream_t*)as, ts_link); - tvhinfo("transcode", "%04X: %d:%s ==> %s (%s)", + tvhinfo(LS_TRANSCODE, "%04X: %d:%s ==> %s (%s)", shortid(t), ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), streaming_component_type2txt(as->ts_type), @@ -1852,7 +1852,7 @@ transcoder_init_video(transcoder_t *t, streaming_start_component_t *ssc) vs->vid_width = ssc->ssc_width; } - tvhinfo("transcode", "%04X: %d:%s %dx%d ==> %s %dx%d (%s)", + tvhinfo(LS_TRANSCODE, "%04X: %d:%s %dx%d ==> %s %dx%d (%s)", shortid(t), ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type), @@ -1915,7 +1915,7 @@ transcoder_calc_stream_count(transcoder_t *t, streaming_start_t *ss) { } } - tvhtrace("transcode", "%04X: transcoder_calc_stream_count=%d (video=%d, audio=%d, subtitle=%d)", + tvhtrace(LS_TRANSCODE, "%04X: transcoder_calc_stream_count=%d (video=%d, audio=%d, subtitle=%d)", shortid(t), (video + audio + subtitle), video, audio, subtitle); @@ -1956,7 +1956,7 @@ transcoder_start(transcoder_t *t, streaming_start_t *src) if (i == src->ss_num_components) { - tvhinfo("transcode", "Could not find requestd lang [%s] in stream, using first one", tp->tp_language); + tvhinfo(LS_TRANSCODE, "Could not find requestd lang [%s] in stream, using first one", tp->tp_language); requested_lang[0] = '\0'; } } @@ -1980,7 +1980,7 @@ transcoder_start(transcoder_t *t, streaming_start_t *src) rc = 0; if(!rc) - tvhinfo("transcode", "%04X: %d:%s ==> Filtered", + tvhinfo(LS_TRANSCODE, "%04X: %d:%s ==> Filtered", shortid(t), ssc->ssc_index, streaming_component_type2txt(ssc->ssc_type)); else diff --git a/src/plumbing/tsfix.c b/src/plumbing/tsfix.c index 6497b7b66..5515875d4 100644 --- a/src/plumbing/tsfix.c +++ b/src/plumbing/tsfix.c @@ -191,7 +191,7 @@ tsfix_stop(tsfix_t *tf) static void tsfix_packet_drop(tfstream_t *tfs, th_pkt_t *pkt, const char *reason) { - pkt_trace("tsfix", pkt, tfs->tfs_index, tfs->tfs_type, "drop"); + pkt_trace(LS_TSFIX, pkt, tfs->tfs_index, tfs->tfs_type, "drop"); pkt_ref_dec(pkt); } @@ -257,11 +257,11 @@ normalize_ts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt, int backlog) } tfs->tfs_bad_dts++; if (tfs->tfs_bad_dts < 5) { - tvhlog(LOG_ERR, "parser", - "transport stream %s, DTS discontinuity. " - "DTS = %" PRId64 ", last = %" PRId64, - streaming_component_type2txt(tfs->tfs_type), - dts, tfs->tfs_last_dts_norm); + tvherror(LS_TSFIX, + "transport stream %s, DTS discontinuity. " + "DTS = %" PRId64 ", last = %" PRId64, + streaming_component_type2txt(tfs->tfs_type), + dts, tfs->tfs_last_dts_norm); } } else { /* DTS wrapped, increase upper bits */ @@ -287,7 +287,7 @@ normalize_ts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt, int backlog) deliver: if (tvhtrace_enabled()) { char _odts[22], _opts[22]; - pkt_trace("tsfix", pkt, tfs->tfs_index, tfs->tfs_type, + pkt_trace(LS_TSFIX, pkt, tfs->tfs_index, tfs->tfs_type, "deliver odts %s opts %s ref %"PRId64" epoch %"PRId64, pts_to_string(odts, _odts), pts_to_string(opts, _opts), ref, tfs->tfs_dts_epoch); @@ -363,7 +363,7 @@ recover_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt) case PKT_B_FRAME: /* B-frames have same PTS as DTS, pass them on */ pkt->pkt_pts = pkt->pkt_dts; - tvhtrace("tsfix", "%-12s PTS b-frame set to %"PRId64, + tvhtrace(LS_TSFIX, "%-12s PTS b-frame set to %"PRId64, streaming_component_type2txt(tfs->tfs_type), pkt->pkt_dts); break; @@ -381,7 +381,7 @@ recover_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt) pts_is_greater_or_equal(pkt->pkt_dts, srch->pr_pkt->pkt_dts) > 0 && pts_diff(pkt->pkt_dts, srch->pr_pkt->pkt_dts) < 10 * 90000) { pkt->pkt_pts = srch->pr_pkt->pkt_dts; - tvhtrace("tsfix", "%-12s PTS *-frame set to %"PRId64", DTS %"PRId64, + tvhtrace(LS_TSFIX, "%-12s PTS *-frame set to %"PRId64", DTS %"PRId64, streaming_component_type2txt(tfs->tfs_type), pkt->pkt_pts, pkt->pkt_dts); break; @@ -418,7 +418,7 @@ compute_pts(tsfix_t *tf, tfstream_t *tfs, th_pkt_t *pkt) // If PTS is missing, set it to DTS if not video if(pkt->pkt_pts == PTS_UNSET && !tfs->tfs_video) { pkt->pkt_pts = pkt->pkt_dts; - tvhtrace("tsfix", "%-12s PTS set to %"PRId64, + tvhtrace(LS_TSFIX, "%-12s PTS set to %"PRId64, streaming_component_type2txt(tfs->tfs_type), pkt->pkt_pts); } @@ -466,7 +466,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) if (diff > 160000) diff = 160000; tf->tf_tsref = (tf->tf_tsref - diff) % PTS_MASK; - tvhtrace("tsfix", "reference clock set to %"PRId64" (backlog %"PRId64")", tf->tf_tsref, diff2); + tvhtrace(LS_TSFIX, "reference clock set to %"PRId64" (backlog %"PRId64")", tf->tf_tsref, diff2); tsfix_backlog(tf); } } else if (tfs->tfs_local_ref == PTS_UNSET && tf->tf_tsref != PTS_UNSET && @@ -478,7 +478,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) if (tfs->tfs_audio) { diff = tsfix_ts_diff(tf->tf_tsref, pkt->pkt_dts); if (diff > 2 * 90000) { - tvhwarn("tsfix", "The timediff for %s is big (%"PRId64"), using current dts", + tvhwarn(LS_TSFIX, "The timediff for %s is big (%"PRId64"), using current dts", streaming_component_type2txt(tfs->tfs_type), diff); tfs->tfs_local_ref = pkt->pkt_dts; } else { @@ -490,7 +490,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) if(tfs2->tfs_audio && tfs2->tfs_last_dts_in != PTS_UNSET) { diff = tsfix_ts_diff(tfs2->tfs_last_dts_in, pkt->pkt_dts); if (diff > 3 * 90000) { - tvhwarn("tsfix", "The timediff for DVBSUB is big (%"PRId64"), using audio dts", diff); + tvhwarn(LS_TSFIX, "The timediff for DVBSUB is big (%"PRId64"), using audio dts", diff); tfs->tfs_parent = tfs2; tfs->tfs_local_ref = tfs2->tfs_local_ref; } else { @@ -506,7 +506,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) diff = tsfix_ts_diff(tf->tf_tsref, pkt->pkt_dts); if (diff > 2 * 90000) { tfstream_t *tfs2; - tvhwarn("tsfix", "The timediff for TELETEXT is big (%"PRId64"), using current dts", diff); + tvhwarn(LS_TSFIX, "The timediff for TELETEXT is big (%"PRId64"), using current dts", diff); tfs->tfs_local_ref = pkt->pkt_dts; /* Text subtitles extracted from teletext have same timebase */ LIST_FOREACH(tfs2, &tf->tf_streams, tfs_link) @@ -532,7 +532,7 @@ tsfix_input_packet(tsfix_t *tf, streaming_message_t *sm) if(pkt->pkt_payload != NULL || pkt->pkt_pts != PTS_UNSET) { pkt->pkt_dts = (tfs->tfs_last_dts_in + pdur) & PTS_MASK; - tvhtrace("tsfix", "%-12s DTS set to last %"PRId64" +%d == %"PRId64", PTS = %"PRId64, + tvhtrace(LS_TSFIX, "%-12s DTS set to last %"PRId64" +%d == %"PRId64", PTS = %"PRId64, streaming_component_type2txt(tfs->tfs_type), tfs->tfs_last_dts_in, pdur, pkt->pkt_dts, pkt->pkt_pts); } diff --git a/src/profile.c b/src/profile.c index a31506bcd..985603b5a 100644 --- a/src/profile.c +++ b/src/profile.c @@ -87,12 +87,12 @@ profile_create if ((s = htsmsg_get_str(conf, "class")) != NULL) pb = profile_class_find(s); if (pb == NULL) { - tvherror("profile", "wrong class %s!", s); + tvherror(LS_PROFILE, "wrong class %s!", s); return NULL; } pro = pb->build(); if (pro == NULL) { - tvherror("profile", "Profile class %s is not available!", s); + tvherror(LS_PROFILE, "Profile class %s is not available!", s); return NULL; } LIST_INIT(&pro->pro_dvr_configs); @@ -100,7 +100,7 @@ profile_create pro->pro_contaccess = 1; if (idnode_insert(&pro->pro_id, uuid, pb->clazz, 0)) { if (uuid) - tvherror("profile", "invalid uuid '%s'", uuid); + tvherror(LS_PROFILE, "invalid uuid '%s'", uuid); free(pro); return NULL; } diff --git a/src/rtsp.c b/src/rtsp.c index d08125ae8..dcebe3e8a 100644 --- a/src/rtsp.c +++ b/src/rtsp.c @@ -138,7 +138,7 @@ rtsp_setup_decode( http_client_t *hc, int satip ) if (strncasecmp(argv[i], "timeout=", 8) == 0) { hc->hc_rtp_timeout = atoi(argv[i] + 8); if (hc->hc_rtp_timeout < 20 || hc->hc_rtp_timeout > 3600) { - tvhwarn("rtsp", "timeout value out of range 20-3600 (%i)", hc->hc_rtp_timeout); + tvhwarn(LS_RTSP, "timeout value out of range 20-3600 (%i)", hc->hc_rtp_timeout); return -EIO; } } diff --git a/src/satip/rtp.c b/src/satip/rtp.c index 986d579f2..cb1fe984e 100644 --- a/src/satip/rtp.c +++ b/src/satip/rtp.c @@ -113,7 +113,7 @@ satip_rtp_pmt_cb(mpegts_psi_table_t *mt, const uint8_t *buf, int len) return; if (sizeof(out) < ol + l + 5 + 4 /* crc */) { - tvherror("pass", "PMT entry too long (%i)", l); + tvherror(LS_PASS, "PMT entry too long (%i)", l); return; } @@ -360,7 +360,7 @@ satip_rtp_thread(void *aux) int tcp = rtp->port == RTSP_TCP_DATA; tcp_get_str_from_ip((struct sockaddr *)&rtp->peer, peername, sizeof(peername)); - tvhdebug("satips", "RTP streaming to %s:%d open", peername, + tvhdebug(LS_SATIPS, "RTP streaming to %s:%d open", peername, tcp ? IP_PORT(rtp->peer) : rtp->port); pthread_mutex_lock(&sq->sq_mutex); @@ -420,7 +420,7 @@ satip_rtp_thread(void *aux) } pthread_mutex_unlock(&sq->sq_mutex); - tvhdebug("satips", "RTP streaming to %s:%d closed (%s request)%s", + tvhdebug(LS_SATIPS, "RTP streaming to %s:%d closed (%s request)%s", peername, rtp->port, alive ? "remote" : "streaming", fatal ? " (fatal)" : ""); @@ -493,7 +493,7 @@ void satip_rtp_queue(void *id, th_subscription_t *subs, rtp->sig.snr = 28000; } - tvhtrace("satips", "rtp queue %p", rtp); + tvhtrace(LS_SATIPS, "rtp queue %p", rtp); pthread_mutex_lock(&satip_rtp_lock); TAILQ_INSERT_TAIL(&satip_rtp_sessions, rtp, link); @@ -535,7 +535,7 @@ void satip_rtp_update_pmt_pids(void *id, mpegts_apids_t *pmt_pids) break; if (!tbl) { tbl = calloc(1, sizeof(*tbl)); - dvb_table_parse_init(&tbl->tbl, "satip-pmt", pid, rtp); + dvb_table_parse_init(&tbl->tbl, "satip-pmt", LS_TBL_SATIP, pid, rtp); tbl->pid = pid; TAILQ_INSERT_TAIL(&rtp->pmt_tables, tbl, link); } @@ -560,7 +560,7 @@ void satip_rtp_close(void *id) pthread_mutex_lock(&satip_rtp_lock); rtp = satip_rtp_find(id); - tvhtrace("satips", "rtp close %p", rtp); + tvhtrace(LS_SATIPS, "rtp close %p", rtp); if (rtp) { TAILQ_REMOVE(&satip_rtp_sessions, rtp, link); sq = rtp->sq; @@ -866,7 +866,7 @@ satip_rtcp_thread(void *aux) char addrbuf[50]; int r, len, err; - tvhtrace("satips", "starting rtcp thread"); + tvhtrace(LS_SATIPS, "starting rtcp thread"); while (atomic_get(&satip_rtcp_run)) { us = 150000; do { @@ -884,7 +884,7 @@ satip_rtcp_thread(void *aux) if (tvhtrace_enabled()) { msg[len] = '\0'; tcp_get_str_from_ip((struct sockaddr*)&rtp->peer2, addrbuf, sizeof(addrbuf)); - tvhtrace("satips", "RTCP send to %s:%d : %s", addrbuf, ntohs(IP_PORT(rtp->peer2)), msg + 16); + tvhtrace(LS_SATIPS, "RTCP send to %s:%d : %s", addrbuf, ntohs(IP_PORT(rtp->peer2)), msg + 16); } if (rtp->port == RTSP_TCP_DATA) { satip_rtp_tcp_data(rtp, 1, msg, len); @@ -898,7 +898,7 @@ satip_rtcp_thread(void *aux) if (r < 0) { err = errno; tcp_get_str_from_ip((struct sockaddr*)&rtp->peer2, addrbuf, sizeof(addrbuf)); - tvhwarn("satips", "RTCP send to error %s:%d : %s", + tvhwarn(LS_SATIPS, "RTCP send to error %s:%d : %s", addrbuf, IP_PORT(rtp->peer2), strerror(err)); } } diff --git a/src/satip/rtsp.c b/src/satip/rtsp.c index de34e4aa5..c0d65cb81 100644 --- a/src/satip/rtsp.c +++ b/src/satip/rtsp.c @@ -217,7 +217,7 @@ rtsp_session_timer_cb(void *aux) { session_t *rs = aux; - tvhwarn("satips", "-/%s/%i: session closed (timeout)", rs->session, rs->stream); + tvhwarn(LS_SATIPS, "-/%s/%i: session closed (timeout)", rs->session, rs->stream); pthread_mutex_unlock(&global_lock); pthread_mutex_lock(&rtsp_lock); rtsp_close_session(rs); @@ -323,14 +323,14 @@ rtsp_slave_add buf, 0, NULL, NULL, buf, NULL); if (sub->ths == NULL) { - tvherror("satips", "%i/%s/%i: unable to subscribe service %s\n", + tvherror(LS_SATIPS, "%i/%s/%i: unable to subscribe service %s\n", rs->frontend, rs->session, rs->stream, slave->s_nicename); profile_chain_close(&sub->prch); free(sub); master->s_unlink(master, slave); } else { LIST_INSERT_HEAD(&rs->slaves, sub, link); - tvhdebug("satips", "%i/%s/%i: slave service %s subscribed", + tvhdebug(LS_SATIPS, "%i/%s/%i: slave service %s subscribed", rs->frontend, rs->session, rs->stream, slave->s_nicename); } } @@ -351,7 +351,7 @@ rtsp_slave_remove break; if (sub == NULL) return; - tvhdebug("satips", "%i/%s/%i: slave service %s unsubscribed", + tvhdebug(LS_SATIPS, "%i/%s/%i: slave service %s unsubscribed", rs->frontend, rs->session, rs->stream, slave->s_nicename); master->s_unlink(master, slave); if (sub->ths) @@ -469,7 +469,7 @@ rtsp_manage_descramble(session_t *rs) idnode_set_remove(found, &s->s_id); } if (si < found->is_count) - tvhwarn("satips", "%i/%s/%i: limit for descrambled services reached (wanted %zd allowed %d)", + tvhwarn(LS_SATIPS, "%i/%s/%i: limit for descrambled services reached (wanted %zd allowed %d)", rs->frontend, rs->session, rs->stream, (used - si) + found->is_count, rtsp_descramble); @@ -545,7 +545,7 @@ rtsp_start if (mux == NULL && mn2 && (rtsp_muxcnf == MUXCNF_AUTO || rtsp_muxcnf == MUXCNF_KEEP)) { dvb_mux_conf_str(&rs->dmc, buf, sizeof(buf)); - tvhwarn("satips", "%i/%s/%i: create mux %s", + tvhwarn(LS_SATIPS, "%i/%s/%i: create mux %s", rs->frontend, rs->session, rs->stream, buf); mux = mn2->mn_create_mux(mn2, (void *)(intptr_t)rs->nsession, @@ -558,7 +558,7 @@ rtsp_start } if (mux == NULL) { dvb_mux_conf_str(&rs->dmc, buf, sizeof(buf)); - tvhwarn("satips", "%i/%s/%i: unable to create mux %s%s", + tvhwarn(LS_SATIPS, "%i/%s/%i: unable to create mux %s%s", rs->frontend, rs->session, rs->stream, buf, (rtsp_muxcnf == MUXCNF_REJECT || rtsp_muxcnf == MUXCNF_REJECT_EXACT_MATCH ) ? " (configuration)" : ""); goto endclean; @@ -909,7 +909,7 @@ rtsp_parse_cmd if (fe > 0) { delsys = satip_rtsp_delsys(fe, &findex, NULL); if (delsys == DVB_SYS_NONE) { - tvherror("satips", "fe=%d does not exist", fe); + tvherror(LS_SATIPS, "fe=%d does not exist", fe); goto end; } } else { @@ -1129,7 +1129,7 @@ play: if (mpegts_pid_dump(&rs->pids, buf + r, sizeof(buf) - r, 0, 0) == 0) tvh_strlcatf(buf, sizeof(buf), r, ""); - tvhdebug("satips", "%i/%s/%d: %s from %s:%d %s", + tvhdebug(LS_SATIPS, "%i/%s/%d: %s from %s:%d %s", rs->frontend, rs->session, rs->stream, caller, hc->hc_peer_ipstr, IP_PORT(*hc->hc_peer), buf); @@ -1147,7 +1147,7 @@ end: eargs: TAILQ_FOREACH(arg, &hc->hc_req_args, link) - tvhwarn("satips", "%i/%s/%i: extra parameter '%s'='%s'", + tvhwarn(LS_SATIPS, "%i/%s/%i: extra parameter '%s'='%s'", rs->frontend, rs->session, rs->stream, arg->key, arg->val); goto end; @@ -1367,7 +1367,7 @@ rtsp_process_play(http_connection_t *hc, int setup) if (setup && rs->rtp_peer_port != RTSP_TCP_DATA) { if (udp_bind_double(&rs->udp_rtp, &rs->udp_rtcp, - "satips", "rtsp", "rtcp", + LS_SATIPS, "rtsp", "rtcp", rtsp_ip, 0, NULL, 4*1024, 4*1024, RTP_BUFSIZE, RTCP_BUFSIZE)) { @@ -1440,7 +1440,7 @@ rtsp_process_teardown(http_connection_t *hc) return 0; } - tvhdebug("satips", "-/%s/%i: teardown from %s:%d", + tvhdebug(LS_SATIPS, "-/%s/%i: teardown from %s:%d", hc->hc_session, stream, hc->hc_peer_ipstr, IP_PORT(*hc->hc_peer)); pthread_mutex_lock(&rtsp_lock); @@ -1656,7 +1656,7 @@ void satip_server_rtsp_init rtsp_nat_ip = nat_ip ? strdup(nat_ip) : NULL; free(s); if (!rtsp_server) - rtsp_server = tcp_server_create("satips", "SAT>IP RTSP", bindaddr, port, &ops, NULL); + rtsp_server = tcp_server_create(LS_SATIPS, "SAT>IP RTSP", bindaddr, port, &ops, NULL); if (reg) tcp_server_register(rtsp_server); } diff --git a/src/satip/server.c b/src/satip/server.c index b8fa4e203..0a65da34c 100644 --- a/src/satip/server.c +++ b/src/satip/server.c @@ -177,7 +177,7 @@ satip_server_http_xml(http_connection_t *hc) htsbuf_queue_flush(&q); if (devicelist == NULL || devicelist[0] == '\0') { - tvhwarn("satips", "SAT>IP server announces an empty tuner list to a client %s (missing %s)", + tvhwarn(LS_SATIPS, "SAT>IP server announces an empty tuner list to a client %s (missing %s)", hc->hc_peer_ipstr, !tuners ? "tuner settings - global config" : "network assignment"); } @@ -252,7 +252,7 @@ CONFIGID.UPNP.ORG: 0\r\n\ if (satips_upnp_discovery == NULL || satip_server_rtsp_port <= 0) return; - tvhtrace("satips", "sending byebye"); + tvhtrace(LS_SATIPS, "sending byebye"); for (attempt = 1; attempt <= 3; attempt++) { switch (attempt) { @@ -308,7 +308,7 @@ DEVICEID.SES.COM: %d\r\n\r\n" if (satips_upnp_discovery == NULL || satip_server_rtsp_port <= 0) return; - tvhtrace("satips", "sending announce"); + tvhtrace(LS_SATIPS, "sending announce"); for (attempt = 1; attempt <= 3; attempt++) { switch (attempt) { @@ -366,7 +366,7 @@ CONFIGID.UPNP.ORG: 0\r\n" if (tvhtrace_enabled()) { tcp_get_str_from_ip((struct sockaddr *)dst, buf, sizeof(buf)); - tvhtrace("satips", "sending discover reply to %s:%d%s%s", + tvhtrace(LS_SATIPS, "sending discover reply to %s:%d%s%s", buf, ntohs(IP_PORT(*dst)), deviceid ? " device: " : "", deviceid ?: ""); } @@ -471,7 +471,7 @@ satips_upnp_discovery_received if (tvhtrace_enabled()) { tcp_get_str_from_ip((struct sockaddr *)storage, buf2, sizeof(buf2)); - tvhtrace("satips", "received %s M-SEARCH from %s:%d", + tvhtrace(LS_SATIPS, "received %s M-SEARCH from %s:%d", conn->multicast ? "multicast" : "unicast", buf2, ntohs(IP_PORT(*storage))); } @@ -483,7 +483,7 @@ satips_upnp_discovery_received if (satip_server_deviceid >= 254) satip_server_deviceid = 1; tcp_get_str_from_ip((struct sockaddr *)storage, buf2, sizeof(buf2)); - tvhwarn("satips", "received duplicate SAT>IP DeviceID %s from %s:%d, using %d", + tvhwarn(LS_SATIPS, "received duplicate SAT>IP DeviceID %s from %s:%d, using %d", deviceid, buf2, ntohs(IP_PORT(*storage)), satip_server_deviceid); satips_upnp_send_discover_reply(storage, deviceid, 0); satips_upnp_send_byebye(); @@ -511,7 +511,7 @@ static void satips_rtsp_port(int def) if (!satip_server_rtsp_port_locked) rtsp_port = satip_server_conf.satip_rtsp > 0 ? satip_server_conf.satip_rtsp : def; if (getuid() != 0 && rtsp_port > 0 && rtsp_port < 1024) { - tvherror("satips", "RTSP port %d specified but no root perms, using 9983", rtsp_port); + tvherror(LS_SATIPS, "RTSP port %d specified but no root perms, using 9983", rtsp_port); rtsp_port = 9983; } satip_server_rtsp_port = rtsp_port; @@ -527,16 +527,16 @@ static void satip_server_info(const char *prefix, int descramble, int muxcnf) int fe, findex; const char *ftype; - tvhinfo("satips", "SAT>IP Server %sinitialized", prefix); - tvhinfo("satips", " HTTP %s:%d, RTSP %s:%d", + tvhinfo(LS_SATIPS, "SAT>IP Server %sinitialized", prefix); + tvhinfo(LS_SATIPS, " HTTP %s:%d, RTSP %s:%d", http_server_ip, http_server_port, http_server_ip, satip_server_rtsp_port); - tvhinfo("satips", " descramble %d, muxcnf %d", + tvhinfo(LS_SATIPS, " descramble %d, muxcnf %d", descramble, muxcnf); for (fe = 1; fe <= 128; fe++) { if (satip_rtsp_delsys(fe, &findex, &ftype) == DVB_TYPE_NONE) break; - tvhinfo("satips", " tuner[fe=%d]: %s #%d", fe, ftype, findex); + tvhinfo(LS_SATIPS, " tuner[fe=%d]: %s #%d", fe, ftype, findex); } } @@ -752,11 +752,11 @@ static void satip_server_init_common(const char *prefix, int announce) if (http_server_ip == NULL) { if (tcp_server_onall(http_server) && satip_server_bindaddr == NULL) { - tvherror("satips", "use --satip_bindaddr parameter to select the local IP for SAT>IP"); - tvherror("satips", "using Google lookup (might block the task until timeout)"); + tvherror(LS_SATIPS, "use --satip_bindaddr parameter to select the local IP for SAT>IP"); + tvherror(LS_SATIPS, "using Google lookup (might block the task until timeout)"); } if (tcp_server_bound(http_server, &http, PF_INET) < 0) { - tvherror("satips", "Unable to determine the HTTP/RTSP address"); + tvherror(LS_SATIPS, "Unable to determine the HTTP/RTSP address"); return; } tcp_get_str_from_ip((const struct sockaddr *)&http, http_ip, sizeof(http_ip)); @@ -802,7 +802,7 @@ static void satip_server_save(void) satip_server_init_common("re", 1); } else { pthread_mutex_unlock(&global_lock); - tvhinfo("satips", "SAT>IP Server shutdown"); + tvhinfo(LS_SATIPS, "SAT>IP Server shutdown"); satip_server_rtsp_done(); satips_upnp_send_byebye(); pthread_mutex_lock(&global_lock); @@ -859,7 +859,7 @@ void satip_server_register(void) if (satip_server_conf.satip_uuid == NULL) { /* This is not UPnP complaint UUID */ if (uuid_init_bin(&u, NULL)) { - tvherror("satips", "Unable to create UUID"); + tvherror(LS_SATIPS, "Unable to create UUID"); return; } bin2hex(uu + 0, 9, u.bin, 4); uu[ 8] = '-'; @@ -876,7 +876,7 @@ void satip_server_register(void) satips_upnp_discovery = upnp_service_create(upnp_service); if (satips_upnp_discovery == NULL) { - tvherror("satips", "unable to create UPnP discovery service"); + tvherror(LS_SATIPS, "unable to create UPnP discovery service"); } else { satips_upnp_discovery->us_received = satips_upnp_discovery_received; satips_upnp_discovery->us_destroy = satips_upnp_discovery_destroy; diff --git a/src/service.c b/src/service.c index 4d6ed155d..1898aee6e 100644 --- a/src/service.c +++ b/src/service.c @@ -434,14 +434,14 @@ service_print_filter(service_t *t) TAILQ_FOREACH(st, &t->s_filt_components, es_filt_link) { if (LIST_EMPTY(&st->es_caids)) { - tvhinfo("service", "esfilter: \"%s\" %03d %05d %s %s", + tvhinfo(LS_SERVICE, "esfilter: \"%s\" %03d %05d %s %s", t->s_nicename, st->es_index, st->es_pid, streaming_component_type2txt(st->es_type), lang_code_get(st->es_lang)); } else { LIST_FOREACH(ca, &st->es_caids, link) if (ca->use) - tvhinfo("service", "esfilter: \"%s\" %03d %05d %s %04x %06x", + tvhinfo(LS_SERVICE, "esfilter: \"%s\" %03d %05d %s %04x %06x", t->s_nicename, st->es_index, st->es_pid, streaming_component_type2txt(st->es_type), ca->caid, ca->providerid); @@ -542,7 +542,7 @@ filter: if (esf->esf_sindex && esf->esf_sindex != sindex) continue; if (esf->esf_log) - tvhlog(LOG_INFO, "service", "esfilter: \"%s\" %s %03d %03d %05d %04x %06x %s", + tvhinfo(LS_SERVICE, "esfilter: \"%s\" %s %03d %03d %05d %04x %06x %s", t->s_nicename, esfilter_class2txt(i), st->es_index, esf->esf_index, st->es_pid, esf->esf_caid, esf->esf_caprovider, esfilter_action2txt(esf->esf_action)); @@ -587,7 +587,7 @@ ca_ignore: service_build_filter_add(t, st, sta, &p); break; default: - tvhlog(LOG_DEBUG, "service", "Unknown esfilter action %d", esf->esf_action); + tvhdebug(LS_SERVICE, "Unknown esfilter action %d", esf->esf_action); break; } } else { @@ -595,7 +595,7 @@ ca_ignore: if (esf->esf_sindex && esf->esf_sindex != sindex) continue; if (esf->esf_log) - tvhlog(LOG_INFO, "service", "esfilter: \"%s\" %s %03d %03d %05d %s %s %s", + tvhinfo(LS_SERVICE, "esfilter: \"%s\" %s %03d %03d %05d %s %s %s", t->s_nicename, esfilter_class2txt(i), st->es_index, esf->esf_index, st->es_pid, streaming_component_type2txt(st->es_type), lang_code_get(st->es_lang), esfilter_action2txt(esf->esf_action)); @@ -630,7 +630,7 @@ ignore: service_build_filter_add(t, st, sta, &p); break; default: - tvhlog(LOG_DEBUG, "service", "Unknown esfilter action %d", esf->esf_action); + tvhdebug(LS_SERVICE, "Unknown esfilter action %d", esf->esf_action); break; } } @@ -681,7 +681,7 @@ service_start(service_t *t, int instance, int weight, int flags, lock_assert(&global_lock); - tvhtrace("service", "starting %s", t->s_nicename); + tvhtrace(LS_SERVICE, "starting %s", t->s_nicename); assert(t->s_status != SERVICE_RUNNING); t->s_streaming_status = 0; @@ -808,7 +808,7 @@ service_find_instance TAILQ_FOREACH(si, sil, si_link) { const char *name = ch ? channel_get_name(ch) : NULL; if (!name && s) name = s->s_nicename; - tvhdebug("service", "%d: %s si %p %s weight %d prio %d error %d", + tvhdebug(LS_SERVICE, "%d: %s si %p %s weight %d prio %d error %d", si->si_instance, name, si, si->si_source, si->si_weight, si->si_prio, si->si_error); } @@ -816,7 +816,7 @@ service_find_instance /* Already running? */ TAILQ_FOREACH(si, sil, si_link) if(si->si_s->s_status == SERVICE_RUNNING && si->si_error == 0) { - tvhtrace("service", "return already running %p", si); + tvhtrace(LS_SERVICE, "return already running %p", si); return si; } @@ -857,9 +857,9 @@ service_find_instance } /* Start */ - tvhtrace("service", "will start new instance %d", si->si_instance); + tvhtrace(LS_SERVICE, "will start new instance %d", si->si_instance); if (service_start(si->si_s, si->si_instance, weight, flags, timeout, postpone)) { - tvhtrace("service", "tuning failed"); + tvhtrace(LS_SERVICE, "tuning failed"); si->si_error = SM_CODE_TUNING_FAILED; if (*error < SM_CODE_TUNING_FAILED) *error = SM_CODE_TUNING_FAILED; @@ -1013,7 +1013,7 @@ service_create0 { if (idnode_insert(&t->s_id, uuid, class, 0)) { if (uuid) - tvherror("service", "invalid uuid '%s'", uuid); + tvherror(LS_SERVICE, "invalid uuid '%s'", uuid); free(t); return NULL; } @@ -1375,7 +1375,7 @@ service_set_streaming_status_flags_(service_t *t, int set) t->s_streaming_status = set; - tvhlog(LOG_DEBUG, "service", "%s: Status changed to %s%s%s%s%s%s%s%s%s", + tvhdebug(LS_SERVICE, "%s: Status changed to %s%s%s%s%s%s%s%s%s", service_nicename(t), set & TSS_INPUT_HARDWARE ? "[Hardware input] " : "", set & TSS_INPUT_SERVICE ? "[Input on service] " : "", diff --git a/src/service_mapper.c b/src/service_mapper.c index 9b67db630..6714aacd9 100644 --- a/src/service_mapper.c +++ b/src/service_mapper.c @@ -83,19 +83,19 @@ service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ) } if (!f) continue; } - tvhtrace("service_mapper", "check service %s (%s)", + tvhtrace(LS_SERVICE_MAPPER, "check service %s (%s)", s->s_nicename, idnode_uuid_as_str(&s->s_id, ubuf)); /* Already mapped (or in progress) */ if (s->s_sm_onqueue) continue; if (LIST_FIRST(&s->s_channels)) continue; - tvhtrace("service_mapper", " not mapped"); + tvhtrace(LS_SERVICE_MAPPER, " not mapped"); service_mapper_stat.total++; service_mapper_stat.ignore++; /* Disabled */ if (!s->s_is_enabled(s, 0)) continue; - tvhtrace("service_mapper", " enabled"); + tvhtrace(LS_SERVICE_MAPPER, " enabled"); /* Get service info */ pthread_mutex_lock(&s->s_stream_mutex); @@ -105,7 +105,7 @@ service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ) /* Skip non-TV / Radio */ if (!tr) continue; - tvhtrace("service_mapper", " radio or tv"); + tvhtrace(LS_SERVICE_MAPPER, " radio or tv"); /* Skip encrypted */ if (!conf->encrypted && e) continue; @@ -113,7 +113,7 @@ service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ) /* Queue */ if (conf->check_availability) { - tvhtrace("service_mapper", " queue for checking"); + tvhtrace(LS_SERVICE_MAPPER, " queue for checking"); qd = 1; smi = malloc(sizeof(*smi)); smi->s = s; @@ -123,7 +123,7 @@ service_mapper_start ( const service_mapper_conf_t *conf, htsmsg_t *uuids ) /* Process */ } else { - tvhtrace("service_mapper", " process"); + tvhtrace(LS_SERVICE_MAPPER, " process"); service_mapper_process(conf, s, NULL); } } @@ -272,9 +272,9 @@ service_mapper_process } if (!bq) { service_mapper_stat.ok++; - tvhinfo("service_mapper", "%s: success", s->s_nicename); + tvhinfo(LS_SERVICE_MAPPER, "%s: success", s->s_nicename); } else { - tvhinfo("bouquet", "%s: mapped service from %s", s->s_nicename, bq->bq_name ?: ""); + tvhinfo(LS_BOUQUET, "%s: mapped service from %s", s->s_nicename, bq->bq_name ?: ""); } /* Remove */ @@ -310,7 +310,7 @@ service_mapper_thread ( void *aux ) while (!(smi = TAILQ_FIRST(&service_mapper_queue))) { if (working) { working = 0; - tvhinfo("service_mapper", "idle"); + tvhinfo(LS_SERVICE_MAPPER, "idle"); } tvh_cond_wait(&service_mapper_cond, &global_lock); if (!tvheadend_is_running()) @@ -323,11 +323,11 @@ service_mapper_thread ( void *aux ) if (!working) { working = 1; - tvhinfo("service_mapper", "starting"); + tvhinfo(LS_SERVICE_MAPPER, "starting"); } /* Subscribe */ - tvhinfo("service_mapper", "checking %s", s->s_nicename); + tvhinfo(LS_SERVICE_MAPPER, "checking %s", s->s_nicename); prch.prch_id = s; sub = subscription_create_from_service(&prch, NULL, SUBSCRIPTION_PRIO_MAPPER, @@ -337,11 +337,11 @@ service_mapper_thread ( void *aux ) /* Failed */ if (!sub) { - tvhinfo("service_mapper", "%s: could not subscribe", s->s_nicename); + tvhinfo(LS_SERVICE_MAPPER, "%s: could not subscribe", s->s_nicename); continue; } - tvhinfo("service_mapper", "waiting for input"); + tvhinfo(LS_SERVICE_MAPPER, "waiting for input"); service_ref(s); service_mapper_stat.active = s; api_service_mapper_notify(); @@ -392,7 +392,7 @@ service_mapper_thread ( void *aux ) subscription_unsubscribe(sub, UNSUBSCRIBE_FINAL); if(err) { - tvhinfo("service_mapper", "%s: failed [reason: %s]", s->s_nicename, err); + tvhinfo(LS_SERVICE_MAPPER, "%s: failed [reason: %s]", s->s_nicename, err); service_mapper_stat.fail++; } else service_mapper_process(&smi->conf, s, NULL); diff --git a/src/settings.c b/src/settings.c index 037dd5867..812997097 100644 --- a/src/settings.c +++ b/src/settings.c @@ -83,7 +83,7 @@ hts_settings_makedirs ( const char *inpath ) } x--; } - return makedirs("settings", path, 0700, 1, -1, -1); + return makedirs(LS_SETTINGS, path, 0700, 1, -1, -1); } /** @@ -147,13 +147,13 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...) /* Create directories */ if (hts_settings_makedirs(path)) return; - tvhdebug("settings", "saving to %s", path); + tvhdebug(LS_SETTINGS, "saving to %s", path); /* Create tmp file */ snprintf(tmppath, sizeof(tmppath), "%s.tmp", path); if((fd = tvh_open(tmppath, O_CREAT | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR)) < 0) { - tvhlog(LOG_ALERT, "settings", "Unable to create \"%s\" - %s", - tmppath, strerror(errno)); + tvhalert(LS_SETTINGS, "Unable to create \"%s\" - %s", + tmppath, strerror(errno)); return; } @@ -172,8 +172,8 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...) htsmsg_json_serialize(record, &hq, 1); TAILQ_FOREACH(hd, &hq.hq_q, hd_link) if(tvh_write(fd, hd->hd_data + hd->hd_data_off, hd->hd_data_len)) { - tvhlog(LOG_ALERT, "settings", "Failed to write file \"%s\" - %s", - tmppath, strerror(errno)); + tvhalert(LS_SETTINGS, "Failed to write file \"%s\" - %s", + tmppath, strerror(errno)); ok = 0; break; } @@ -188,7 +188,7 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...) if (r) ok = 0; } else { - tvhlog(LOG_ALERT, "settings", "Unable to pack the configuration data \"%s\"", path); + tvhalert(LS_SETTINGS, "Unable to pack the configuration data \"%s\"", path); } free(msgdata); #endif @@ -203,8 +203,8 @@ hts_settings_save(htsmsg_t *record, const char *pathfmt, ...) r = rename(tmppath, path); } if (r) - tvhlog(LOG_ALERT, "settings", "Unable to rename file \"%s\" to \"%s\" - %s", - tmppath, path, strerror(errno)); + tvhalert(LS_SETTINGS, "Unable to rename file \"%s\" to \"%s\" - %s", + tmppath, path, strerror(errno)); /* Delete tmp */ } else @@ -237,7 +237,7 @@ hts_settings_load_one(const char *filename) #if ENABLE_ZLIB uint32_t orig = (mem[8] << 24) | (mem[9] << 16) | (mem[10] << 8) | mem[11]; if (orig > 10*1024*1024U) { - tvhlog(LOG_ALERT, "settings", "too big gzip for %s", filename); + tvhalert(LS_SETTINGS, "too big gzip for %s", filename); r = NULL; } else if (orig > 0) { uint8_t *unpacked = tvh_gzip_inflate((uint8_t *)mem + 12, size - 12, orig); diff --git a/src/spawn.c b/src/spawn.c index feff168be..1d69a0261 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -92,7 +92,7 @@ spawn_pipe_read( th_pipe_t *p, char **_buf, int level ) break; } buf[len + r] = '\0'; - tvhlog_hexdump("spawn", buf + len, r); + tvhlog_hexdump(LS_SPAWN, buf + len, r); while (1) { s = buf; while (*s && *s != '\n' && *s != '\r') @@ -101,11 +101,11 @@ spawn_pipe_read( th_pipe_t *p, char **_buf, int level ) break; *s++ = '\0'; if (buf[0]) - tvhlog(level, "spawn", "%s", buf); + tvhlog(level, LS_SPAWN, "%s", buf); memmove(buf, s, strlen(s) + 1); } if (strlen(buf) == SPAWN_PIPE_READ_SIZE - 1) { - tvherror("spawn", "pipe buffer full"); + tvherror(LS_SPAWN, "pipe buffer full"); buf[0] = '\0'; } } @@ -508,7 +508,7 @@ spawn_and_give_stdout(const char *prog, char *argv[], char *envp[], if(p == -1) { pthread_mutex_unlock(&fork_lock); - tvherror("spawn", "Unable to fork() for \"%s\" -- %s", + tvherror(LS_SPAWN, "Unable to fork() for \"%s\" -- %s", prog, strerror(errno)); return -1; } @@ -591,7 +591,7 @@ spawnv(const char *prog, char *argv[], pid_t *pid, int redir_stdout, int redir_s if(p == -1) { pthread_mutex_unlock(&fork_lock); - tvherror("spawn", "Unable to fork() for \"%s\" -- %s", + tvherror(LS_SPAWN, "Unable to fork() for \"%s\" -- %s", prog, strerror(errno)); return -1; } diff --git a/src/subscriptions.c b/src/subscriptions.c index 646edd3fe..5a9943672 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -90,7 +90,7 @@ subscription_link_service(th_subscription_t *s, service_t *t) s->ths_service = t; LIST_INSERT_HEAD(&t->s_subscriptions, s, ths_service_link); - tvhtrace("subscription", "%04X: linking sub %p to svc %p type %i", + tvhtrace(LS_SUBSCRIPTION, "%04X: linking sub %p to svc %p type %i", shortid(s), s, t, t->s_type); pthread_mutex_lock(&t->s_stream_mutex); @@ -216,7 +216,7 @@ subscription_show_none(th_subscription_t *s) } #endif } - tvhlog(LOG_NOTICE, "subscription", "%04X: %s", shortid(s), buf); + tvhnotice(LS_SUBSCRIPTION, "%04X: %s", shortid(s), buf); } static void @@ -265,7 +265,7 @@ subscription_show_info(th_subscription_t *s) if (s->ths_client) tvh_strlcatf(buf, sizeof(buf), l, ", client=\"%s\"", s->ths_client); - tvhlog(LOG_INFO, "subscription", "%04X: %s", shortid(s), buf); + tvhinfo(LS_SUBSCRIPTION, "%04X: %s", shortid(s), buf); service_source_info_free(&si); } @@ -288,10 +288,10 @@ subscription_start_instance service_instance_t *si; if (s->ths_channel) - tvhtrace("subscription", "%04X: find service for %s weight %d", + tvhtrace(LS_SUBSCRIPTION, "%04X: find service for %s weight %d", shortid(s), channel_get_name(s->ths_channel), s->ths_weight); else - tvhtrace("subscription", "%04X: find instance for %s weight %d", + tvhtrace(LS_SUBSCRIPTION, "%04X: find instance for %s weight %d", shortid(s), s->ths_service->s_nicename, s->ths_weight); si = service_find_instance(s->ths_service, s->ths_channel, s->ths_source, s->ths_prch, @@ -341,7 +341,7 @@ subscription_reschedule(void) if(subgetstate(s) != SUBSCRIPTION_BAD_SERVICE) continue; /* And it not bad, so we're happy */ - tvhwarn("subscription", "%04X: service instance is bad, reason: %s", + tvhwarn(LS_SUBSCRIPTION, "%04X: service instance is bad, reason: %s", shortid(s), streaming_code2txt(s->ths_testing_error)); t->s_streaming_status = 0; @@ -367,7 +367,7 @@ subscription_reschedule(void) if(si == NULL) { if (s->ths_last_error != error || s->ths_last_find + sec2mono(2) >= mclk()) { - tvhtrace("subscription", "%04X: instance not available, retrying", shortid(s)); + tvhtrace(LS_SUBSCRIPTION, "%04X: instance not available, retrying", shortid(s)); if (s->ths_last_error != error) s->ths_last_find = mclk(); s->ths_last_error = error; @@ -375,10 +375,10 @@ subscription_reschedule(void) } if (s->ths_flags & SUBSCRIPTION_RESTART) { if (s->ths_channel) - tvhwarn("subscription", "%04X: restarting channel %s", + tvhwarn(LS_SUBSCRIPTION, "%04X: restarting channel %s", shortid(s), channel_get_name(s->ths_channel)); else - tvhwarn("subscription", "%04X: restarting service %s", + tvhwarn(LS_SUBSCRIPTION, "%04X: restarting service %s", shortid(s), s->ths_service->s_nicename); s->ths_testing_error = 0; s->ths_current_instance = NULL; @@ -437,7 +437,7 @@ subscription_set_postpone(void *aux, const char *path, int64_t postpone) pthread_mutex_lock(&global_lock); if (subscription_postpone != postpone) { subscription_postpone = postpone; - tvhinfo("subscriptions", "postpone set to %"PRId64" seconds", postpone); + tvhinfo(LS_SUBSCRIPTION, "postpone set to %"PRId64" seconds", postpone); LIST_FOREACH(s, &subscriptions, ths_global_link) { s->ths_postpone = postpone; if (s->ths_postpone_end > now && s->ths_postpone_end - now > postpone2) @@ -647,7 +647,7 @@ subscription_unsubscribe(th_subscription_t *s, int flags) if (s->ths_client) tvh_strlcatf(buf, sizeof(buf), l, ", client=\"%s\"", s->ths_client); tvhlog((flags & UNSUBSCRIBE_QUIET) != 0 ? LOG_TRACE : LOG_INFO, - "subscription", "%04X: %s", shortid(s), buf); + LS_SUBSCRIPTION, "%04X: %s", shortid(s), buf); if (t) service_remove_subscriber(t, s, SM_CODE_OK); @@ -780,10 +780,10 @@ subscription_create_from_channel_or_service(profile_chain_t *prch, if (tvhtrace_enabled()) { const char *pro_name = prch->prch_pro ? profile_get_name(prch->prch_pro) : ""; if (ch) - tvhtrace("subscription", "%04X: creating subscription for %s weight %d using profile %s", + tvhtrace(LS_SUBSCRIPTION, "%04X: creating subscription for %s weight %d using profile %s", shortid(s), channel_get_name(ch), weight, pro_name); else - tvhtrace("subscription", "%04X: creating subscription for service %s weight %d using profile %s", + tvhtrace(LS_SUBSCRIPTION, "%04X: creating subscription for service %s weight %d using profile %s", shortid(s), service->s_nicename, weight, pro_name); } s->ths_channel = ch; @@ -1167,8 +1167,8 @@ subscription_dummy_join(const char *id, int first) } if(t == NULL) { - tvhlog(LOG_ERR, "subscription", - "Unable to dummy join %s, service not found, retrying...", id); + tvherror(LS_SUBSCRIPTION, + "Unable to dummy join %s, service not found, retrying...", id); mtimer_arm_rel(&dummy_sub_timer, dummy_retry, strdup(id), sec2mono(1)); return; @@ -1181,6 +1181,5 @@ subscription_dummy_join(const char *id, int first) prch->prch_st = st; s = subscription_create_from_service(prch, NULL, 1, "dummy", 0, NULL, NULL, "dummy", NULL); - tvhlog(LOG_NOTICE, "subscription", - "%04X: Dummy join %s ok", shortid(s), id); + tvhnotice(LS_SUBSCRIPTION, "%04X: Dummy join %s ok", shortid(s), id); } diff --git a/src/tcp.c b/src/tcp.c index 5a6631b74..f9d350593 100644 --- a/src/tcp.c +++ b/src/tcp.c @@ -540,7 +540,7 @@ try_again: if (c1 && c2) { if (started + sec2mono(3) < mclk()) { - tvherror("tcp", "multiple connections are not allowed for user '%s' from '%s' " + tvherror(LS_TCP, "multiple connections are not allowed for user '%s' from '%s' " "(limit %u, streaming limit %u, active streaming %u, DVR %u)", aa->aa_username ?: "", aa->aa_representative ?: "", aa->aa_conn_limit, aa->aa_conn_limit_streaming, @@ -673,7 +673,7 @@ tcp_server_loop(void *aux) if(r < 0) { if (ERRNO_AGAIN(-r)) continue; - tvherror("tcp", "tcp_server_loop: tvhpoll_wait: %s", strerror(errno)); + tvherror(LS_TCP, "tcp_server_loop: tvhpoll_wait: %s", strerror(errno)); continue; } @@ -738,7 +738,7 @@ next: tvhthread_create(&tsl->tid, NULL, tcp_server_start, tsl, "tcp-start"); } } - tvhtrace("tcp", "server thread finished"); + tvhtrace(LS_TCP, "server thread finished"); return NULL; } @@ -752,7 +752,7 @@ static void *tcp_server_create_new #else void *tcp_server_create #endif - (const char *subsystem, const char *name, const char *bindaddr, + (int subsystem, const char *name, const char *bindaddr, int port, tcp_server_ops_t *ops, void *opaque) { int fd, x; @@ -775,8 +775,8 @@ void *tcp_server_create x = getaddrinfo(bindaddr, port_buf, &hints, &res); if(x != 0) { - tvhlog(LOG_ERR, "tcp", "getaddrinfo: %s: %s", bindaddr != NULL ? bindaddr : "*", - x == EAI_SYSTEM ? strerror(errno) : gai_strerror(x)); + tvherror(LS_TCP, "getaddrinfo: %s: %s", bindaddr != NULL ? bindaddr : "*", + x == EAI_SYSTEM ? strerror(errno) : gai_strerror(x)); return NULL; } @@ -811,7 +811,7 @@ void *tcp_server_create if(x != 0) { - tvhlog(LOG_ERR, "tcp", "bind: %s:%i: %s", bindaddr != NULL ? bindaddr : "*", port, strerror(errno)); + tvherror(LS_TCP, "bind: %s:%i: %s", bindaddr != NULL ? bindaddr : "*", port, strerror(errno)); close(fd); return NULL; } @@ -825,7 +825,7 @@ void *tcp_server_create ts->opaque = opaque; tcp_get_str_from_ip((const struct sockaddr *)&bound, buf, sizeof(buf)); - tvhlog(LOG_INFO, subsystem, "Starting %s server %s:%d", name, buf, htons(IP_PORT(bound))); + tvhinfo(subsystem, "Starting %s server %s:%d", name, buf, htons(IP_PORT(bound))); return ts; } @@ -862,7 +862,7 @@ tcp_server_create memset(&bound, 0, sizeof(bound)); s_len = sizeof(bound); if (getsockname(fd, (struct sockaddr *) &bound, &s_len) != 0) { - tvhlog(LOG_ERR, "tcp", "getsockname failed: %s", strerror(errno)); + tvherror(LS_TCP, "getsockname failed: %s", strerror(errno)); continue; } switch (bound.ss_family) { @@ -891,10 +891,10 @@ tcp_server_create ts->ops = *ops; ts->opaque = opaque; tcp_get_str_from_ip((const struct sockaddr *)&bound, buf, sizeof(buf)); - tvhlog(LOG_INFO, subsystem, "Starting %s server %s:%d (systemd)", name, buf, htons(IP_PORT(bound))); + tvhinfo(subsystem, "Starting %s server %s:%d (systemd)", name, buf, htons(IP_PORT(bound))); } else { /* no systemd-managed socket found, create a new one */ - tvhlog(LOG_INFO, "tcp", "No systemd socket: creating a new one"); + tvhinfo(LS_TCP, "No systemd socket: creating a new one"); ts = tcp_server_create_new(subsystem, name, bindaddr, port, ops, opaque); } @@ -1141,7 +1141,7 @@ tcp_server_done(void) t = mclk(); while (LIST_FIRST(&tcp_server_active) != NULL) { if (t + sec2mono(5) < mclk()) - tvhtrace("tcp", "tcp server %p active too long", LIST_FIRST(&tcp_server_active)); + tvhtrace(LS_TCP, "tcp server %p active too long", LIST_FIRST(&tcp_server_active)); pthread_mutex_unlock(&global_lock); tvh_safe_usleep(20000); pthread_mutex_lock(&global_lock); diff --git a/src/tcp.h b/src/tcp.h index 1c4024055..9d36fbd67 100644 --- a/src/tcp.h +++ b/src/tcp.h @@ -67,7 +67,7 @@ typedef void (tcp_server_callback_t)(int fd, void *opaque, struct sockaddr_storage *peer, struct sockaddr_storage *self); -void *tcp_server_create(const char *subsystem, const char *name, +void *tcp_server_create(int subsystem, const char *name, const char *bindaddr, int port, tcp_server_ops_t *ops, void *opaque); diff --git a/src/timeshift.c b/src/timeshift.c index f6092a574..5212d9315 100644 --- a/src/timeshift.c +++ b/src/timeshift.c @@ -46,7 +46,7 @@ timeshift_packet_log0 ( const char *source, timeshift_t *ts, streaming_message_t *sm ) { th_pkt_t *pkt = sm->sm_data; - tvhtrace("timeshift", + tvhtrace(LS_TIMESHIFT, "ts %d pkt %s - stream %d type %c pts %10"PRId64 " dts %10"PRId64" dur %10d len %6zu time %14"PRId64, ts->id, source, diff --git a/src/timeshift/timeshift_filemgr.c b/src/timeshift/timeshift_filemgr.c index 985854044..21195bfde 100644 --- a/src/timeshift/timeshift_filemgr.c +++ b/src/timeshift/timeshift_filemgr.c @@ -65,17 +65,16 @@ static void* timeshift_reaper_callback ( void *p ) pthread_mutex_unlock(×hift_reaper_lock); if (tsf->path) { - tvhtrace("timeshift", "remove file %s", tsf->path); + tvhtrace(LS_TIMESHIFT, "remove file %s", tsf->path); /* Remove */ unlink(tsf->path); dpath = dirname(tsf->path); if (rmdir(dpath) == -1) if (errno != ENOTEMPTY) - tvhlog(LOG_ERR, "timeshift", "failed to remove %s [e=%s]", - dpath, strerror(errno)); + tvherror(LS_TIMESHIFT, "failed to remove %s [e=%s]", dpath, strerror(errno)); } else { - tvhtrace("timeshift", "remove RAM segment (time %"PRId64", size %"PRId64")", + tvhtrace(LS_TIMESHIFT, "remove RAM segment (time %"PRId64", size %"PRId64")", tsf->time, (int64_t)tsf->size); } @@ -97,7 +96,7 @@ static void* timeshift_reaper_callback ( void *p ) pthread_mutex_lock(×hift_reaper_lock); } pthread_mutex_unlock(×hift_reaper_lock); - tvhtrace("timeshift", "reaper thread exit"); + tvhtrace(LS_TIMESHIFT, "reaper thread exit"); return NULL; } @@ -105,9 +104,9 @@ static void timeshift_reaper_remove ( timeshift_file_t *tsf ) { if (tvhtrace_enabled()) { if (tsf->path) - tvhtrace("timeshift", "queue file for removal %s", tsf->path); + tvhtrace(LS_TIMESHIFT, "queue file for removal %s", tsf->path); else - tvhtrace("timeshift", "queue file for removal - RAM segment time %li", (long)tsf->time); + tvhtrace(LS_TIMESHIFT, "queue file for removal - RAM segment time %li", (long)tsf->time); } pthread_mutex_lock(×hift_reaper_lock); TAILQ_INSERT_TAIL(×hift_reaper_list, tsf, link); @@ -125,11 +124,11 @@ timeshift_filemgr_dump0 ( timeshift_t *ts ) timeshift_file_t *tsf; if (TAILQ_EMPTY(&ts->files)) { - tvhtrace("timeshift", "ts %d file dump - EMPTY", ts->id); + tvhtrace(LS_TIMESHIFT, "ts %d file dump - EMPTY", ts->id); return; } TAILQ_FOREACH(tsf, &ts->files, link) { - tvhtrace("timeshift", "ts %d (full=%d) file dump tsf %p time %4"PRId64" last %10"PRId64" bad %d refcnt %d", + tvhtrace(LS_TIMESHIFT, "ts %d (full=%d) file dump tsf %p time %4"PRId64" last %10"PRId64" bad %d refcnt %d", ts->id, ts->full, tsf, tsf->time, tsf->last, tsf->bad, tsf->refcount); } } @@ -159,7 +158,7 @@ int timeshift_filemgr_makedirs ( int index, char *buf, size_t len ) if (timeshift_filemgr_get_root(buf, len)) return 1; snprintf(buf+strlen(buf), len-strlen(buf), "/%d", index); - return makedirs("timeshift", buf, 0700, 0, -1, -1); + return makedirs(LS_TIMESHIFT, buf, 0700, 0, -1, -1); } /* @@ -199,9 +198,9 @@ void timeshift_filemgr_remove assert(tsf->rfd < 0); if (tvhtrace_enabled()) { if (tsf->path) - tvhdebug("timeshift", "ts %d remove %s (size %"PRId64")", ts->id, tsf->path, (int64_t)tsf->size); + tvhdebug(LS_TIMESHIFT, "ts %d remove %s (size %"PRId64")", ts->id, tsf->path, (int64_t)tsf->size); else - tvhdebug("timeshift", "ts %d RAM segment remove time %"PRId64" (size %"PRId64", alloc size %"PRId64")", + tvhdebug(LS_TIMESHIFT, "ts %d RAM segment remove time %"PRId64" (size %"PRId64", alloc size %"PRId64")", ts->id, tsf->time, (int64_t)tsf->size, (int64_t)tsf->ram_size); } TAILQ_REMOVE(&ts->files, tsf, link); @@ -290,7 +289,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) timeshift_filemgr_remove(ts, tsf_hd, 0); tsf_hd = NULL; } else { - tvhlog(LOG_DEBUG, "timeshift", "ts %d buffer full", ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d buffer full", ts->id); ts->full = 1; } } @@ -306,7 +305,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) /* Full */ } else { - tvhlog(LOG_DEBUG, "timeshift", "ts %d buffer full", ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d buffer full", ts->id); ts->full = 1; } } @@ -315,7 +314,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) tsf_tmp = NULL; if (!ts->full) { - tvhtrace("timeshift", "ts %d RAM total %"PRId64" requested %"PRId64" segment %"PRId64, + tvhtrace(LS_TIMESHIFT, "ts %d RAM total %"PRId64" requested %"PRId64" segment %"PRId64, ts->id, atomic_pre_add_u64(×hift_total_ram_size, 0), timeshift_conf.ram_size, timeshift_conf.ram_segment_size); while (1) { @@ -329,7 +328,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) free(tsf_tmp); tsf_tmp = NULL; } else { - tvhtrace("timeshift", "ts %d create RAM segment with %"PRId64" bytes (time %"PRId64")", + tvhtrace(LS_TIMESHIFT, "ts %d create RAM segment with %"PRId64" bytes (time %"PRId64")", ts->id, tsf_tmp->ram_size, start_time); ts->ram_segments++; } @@ -338,7 +337,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) tsf_hd = TAILQ_FIRST(&ts->files); if (timeshift_conf.ram_fit && tsf_hd && !tsf_hd->refcount && tsf_hd->ram && ts->file_segments == 0) { - tvhtrace("timeshift", "ts %d remove RAM segment %"PRId64" (fit)", ts->id, tsf_hd->time); + tvhtrace(LS_TIMESHIFT, "ts %d remove RAM segment %"PRId64" (fit)", ts->id, tsf_hd->time); timeshift_filemgr_remove(ts, tsf_hd, 0); } else { break; @@ -356,7 +355,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) /* Create File */ snprintf(path, sizeof(path), "%s/tvh-%"PRId64, ts->path, start_time); - tvhtrace("timeshift", "ts %d create file %s", ts->id, path); + tvhtrace(LS_TIMESHIFT, "ts %d create file %s", ts->id, path); if ((fd = tvh_open(path, O_WRONLY | O_CREAT, 0600)) > 0) { tsf_tmp = timeshift_filemgr_file_init(ts, start_time); tsf_tmp->wfd = fd; @@ -368,7 +367,7 @@ timeshift_file_t *timeshift_filemgr_get ( timeshift_t *ts, int64_t start_time ) if (tsf_tmp && tsf_tl) { /* Copy across last start message */ if ((ti = TAILQ_LAST(&tsf_tl->sstart, timeshift_index_data_list)) || ts->smt_start) { - tvhtrace("timeshift", "ts %d copy smt_start to new file%s", + tvhtrace(LS_TIMESHIFT, "ts %d copy smt_start to new file%s", ts->id, ti ? " (from last file)" : ""); timeshift_index_data_t *ti2 = calloc(1, sizeof(timeshift_index_data_t)); if (ti) { diff --git a/src/timeshift/timeshift_reader.c b/src/timeshift/timeshift_reader.c index 9c25c3bc5..7feff7d52 100644 --- a/src/timeshift/timeshift_reader.c +++ b/src/timeshift/timeshift_reader.c @@ -93,7 +93,7 @@ static ssize_t _read_buf ( timeshift_file_t *tsf, int fd, void *buf, size_t size if (r < 0) { if (ERRNO_AGAIN(errno)) continue; - tvhtrace("timeshift", "read errno %d", errno); + tvhtrace(LS_TIMESHIFT, "read errno %d", errno); return -1; } if (r > 0) { @@ -164,7 +164,7 @@ static ssize_t _read_msg ( timeshift_file_t *tsf, int fd, streaming_message_t ** /* Wrong data size */ if (sz > 1024 * 1024) { - tvhtrace("timeshift", "wrong msg size (%lld/0x%llx)", (long long)sz, (long long)sz); + tvhtrace(LS_TIMESHIFT, "wrong msg size (%lld/0x%llx)", (long long)sz, (long long)sz); return -1; } @@ -370,16 +370,16 @@ static int _timeshift_do_skip timeshift_seek_t nseek; int end; - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip to %"PRId64" from %"PRId64, - ts->id, req_time, last_time); + tvhdebug(LS_TIMESHIFT, "ts %d skip to %"PRId64" from %"PRId64, + ts->id, req_time, last_time); timeshift_file_get(seek->file); /* Find */ end = _timeshift_skip(ts, req_time, last_time, seek, &nseek); if (nseek.frame) - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip found pkt @ %"PRId64, - ts->id, nseek.frame->time); + tvhdebug(LS_TIMESHIFT, "ts %d skip found pkt @ %"PRId64, + ts->id, nseek.frame->time); /* File changed (close) */ if (nseek.file != seek->file) @@ -394,7 +394,7 @@ static int _timeshift_do_skip nseek.file->roff = nseek.frame->pos; else nseek.file->roff = req_time > last_time ? nseek.file->size : 0; - tvhtrace("timeshift", "do skip seek->file %p roff %"PRId64, + tvhtrace(LS_TIMESHIFT, "do skip seek->file %p roff %"PRId64, nseek.file, (int64_t)nseek.file->roff); } @@ -420,13 +420,13 @@ static int _timeshift_read /* Open file */ if (tsf->rfd < 0 && !tsf->ram) { tsf->rfd = tvh_open(tsf->path, O_RDONLY, 0); - tvhtrace("timeshift", "ts %d open file %s (fd %i)", ts->id, tsf->path, tsf->rfd); + tvhtrace(LS_TIMESHIFT, "ts %d open file %s (fd %i)", ts->id, tsf->path, tsf->rfd); if (tsf->rfd < 0) return -1; } if (tsf->rfd >= 0) if ((off = lseek(tsf->rfd, tsf->roff, SEEK_SET)) != tsf->roff) - tvherror("timeshift", "ts %d seek to %s failed (off %"PRId64" != %"PRId64"): %s", + tvherror(LS_TIMESHIFT, "ts %d seek to %s failed (off %"PRId64" != %"PRId64"): %s", ts->id, tsf->path, (int64_t)tsf->roff, (int64_t)off, strerror(errno)); /* Read msg */ @@ -434,11 +434,11 @@ static int _timeshift_read if (r < 0) { streaming_message_t *e = streaming_msg_create_code(SMT_STOP, SM_CODE_UNDEFINED_ERROR); streaming_target_deliver2(ts->output, e); - tvhtrace("timeshift", "ts %d seek to %jd (woff %jd) (fd %i)", ts->id, (intmax_t)off, (intmax_t)tsf->woff, tsf->rfd); - tvhlog(LOG_ERR, "timeshift", "ts %d could not read buffer", ts->id); + tvhtrace(LS_TIMESHIFT, "ts %d seek to %jd (woff %jd) (fd %i)", ts->id, (intmax_t)off, (intmax_t)tsf->woff, tsf->rfd); + tvherror(LS_TIMESHIFT, "ts %d could not read buffer", ts->id); return -1; } - tvhtrace("timeshift", "ts %d seek to %jd (fd %i) read msg %p/%"PRId64" (%"PRId64")", + tvhtrace(LS_TIMESHIFT, "ts %d seek to %jd (fd %i) read msg %p/%"PRId64" (%"PRId64")", ts->id, (intmax_t)off, tsf->rfd, *sm, *sm ? (*sm)->sm_time : -1, (int64_t)r); /* Special case - EOF */ @@ -447,7 +447,7 @@ static int _timeshift_read _read_close(seek); _seek_set_file(seek, timeshift_filemgr_next(tsf, NULL, 0), 0); *wait = 0; - tvhtrace("timeshift", "ts %d eof, seek->file %p (prev %p)", ts->id, seek->file, tsf); + tvhtrace(LS_TIMESHIFT, "ts %d eof, seek->file %p (prev %p)", ts->id, seek->file, tsf); timeshift_filemgr_dump(ts); } } @@ -492,7 +492,7 @@ static void timeshift_fill_status current_time = end; } status->full = ts->full; - tvhtrace("timeshift", "ts %d status start %"PRId64" end %"PRId64 + tvhtrace(LS_TIMESHIFT, "ts %d status start %"PRId64" end %"PRId64 " current %"PRId64" state %d", ts->id, start, end, current_time, ts->state); status->shift = ts_rescale_inv(end - current_time, 1000000); @@ -570,7 +570,7 @@ void *timeshift_reader ( void *p ) /* Exit */ if (ctrl->sm_type == SMT_EXIT) { - tvhtrace("timeshift", "ts %d read exit request", ts->id); + tvhtrace(LS_TIMESHIFT, "ts %d read exit request", ts->id); run = 0; streaming_msg_free(ctrl); ctrl = NULL; @@ -597,14 +597,12 @@ void *timeshift_reader ( void *p ) /* Reject */ if (speed >= 100) { - tvhlog(LOG_DEBUG, "timeshift", "ts %d reject 1x+ in live mode", - ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d reject 1x+ in live mode", ts->id); speed = 100; /* Set position */ } else { - tvhlog(LOG_DEBUG, "timeshift", "ts %d enter timeshift mode", - ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d enter timeshift mode", ts->id); ts->dobuf = 1; _seek_reset(seek); tmp_file = timeshift_filemgr_newest(ts); @@ -629,8 +627,7 @@ void *timeshift_reader ( void *p ) /* Check keyframe mode */ keyframe = (speed < 0) || (speed > 400); if (keyframe != keyframe_mode) { - tvhlog(LOG_DEBUG, "timeshift", "using keyframe mode? %s", - keyframe ? "yes" : "no"); + tvhdebug(LS_TIMESHIFT, "using keyframe mode? %s", keyframe ? "yes" : "no"); keyframe_mode = keyframe; if (keyframe) seek->frame = NULL; @@ -639,11 +636,11 @@ void *timeshift_reader ( void *p ) /* Update */ if (speed != 100 || state != TS_LIVE) { ts->state = speed == 0 ? TS_PAUSE : TS_PLAY; - tvhtrace("timeshift", "reader - set %s", speed == 0 ? "TS_PAUSE" : "TS_PLAY"); + tvhtrace(LS_TIMESHIFT, "reader - set %s", speed == 0 ? "TS_PAUSE" : "TS_PLAY"); } if ((ts->state == TS_PLAY && state != TS_PLAY) || (speed != cur_speed)) { mono_play_time = mono_now; - tvhtrace("timeshift", "update play time TS_LIVE - %"PRId64" play buffer from %"PRId64, + tvhtrace(LS_TIMESHIFT, "update play time TS_LIVE - %"PRId64" play buffer from %"PRId64, mono_now, pause_time); if (speed != cur_speed) pause_time = last_time; @@ -651,7 +648,7 @@ void *timeshift_reader ( void *p ) pause_time = last_time; } cur_speed = speed; - tvhlog(LOG_DEBUG, "timeshift", "ts %d change speed %d", ts->id, speed); + tvhdebug(LS_TIMESHIFT, "ts %d change speed %d", ts->id, speed); } /* Send on the message */ @@ -689,7 +686,7 @@ void *timeshift_reader ( void *p ) /* Convert */ skip_time = ts_rescale(skip->time, 1000000); - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip %"PRId64" requested %"PRId64, ts->id, skip_time, skip->time); + tvhdebug(LS_TIMESHIFT, "ts %d skip %"PRId64" requested %"PRId64, ts->id, skip_time, skip->time); /* Live playback (stage1) */ if (ts->state == TS_LIVE) { @@ -710,17 +707,17 @@ void *timeshift_reader ( void *p ) /* May have failed */ if (skip->type == SMT_SKIP_REL_TIME) skip_time += last_time; - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip time %"PRId64, ts->id, skip_time); + tvhdebug(LS_TIMESHIFT, "ts %d skip time %"PRId64, ts->id, skip_time); /* Live (stage2) */ if (ts->state == TS_LIVE) { if (skip_time >= ts->buf_time - TIMESHIFT_PLAY_BUF) { - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip ignored, already live", ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d skip ignored, already live", ts->id); skip = NULL; } else { ts->state = TS_PLAY; ts->dobuf = 1; - tvhtrace("timeshift", "reader - set TS_PLAY"); + tvhtrace(LS_TIMESHIFT, "reader - set TS_PLAY"); } } @@ -731,12 +728,12 @@ void *timeshift_reader ( void *p ) end = _timeshift_do_skip(ts, skip_time, last_time, seek); if (seek->frame) { pause_time = seek->frame->time; - tvhtrace("timeshift", "ts %d skip - play buffer from %"PRId64" last_time %"PRId64, + tvhtrace(LS_TIMESHIFT, "ts %d skip - play buffer from %"PRId64" last_time %"PRId64, ts->id, pause_time, last_time); /* Adjust time */ if (mono_play_time != mono_now) - tvhtrace("timeshift", "ts %d update play time skip - %"PRId64, ts->id, mono_now); + tvhtrace(LS_TIMESHIFT, "ts %d update play time skip - %"PRId64, ts->id, mono_now); mono_play_time = mono_now; /* Clear existing packet */ @@ -750,7 +747,7 @@ void *timeshift_reader ( void *p ) } break; default: - tvhlog(LOG_ERR, "timeshift", "ts %d invalid/unsupported skip type: %d", ts->id, skip->type); + tvherror(LS_TIMESHIFT, "ts %d invalid/unsupported skip type: %d", ts->id, skip->type); skip = NULL; break; } @@ -785,7 +782,7 @@ void *timeshift_reader ( void *p ) deliver0 = (mono_now - mono_play_time) + TIMESHIFT_PLAY_BUF; deliver = (deliver0 * cur_speed) / 100; deliver = (deliver + pause_time); - tvhtrace("timeshift", "speed %d now %"PRId64" play_time %"PRId64" deliver %"PRId64" deliver0 %"PRId64, + tvhtrace(LS_TIMESHIFT, "speed %d now %"PRId64" play_time %"PRId64" deliver %"PRId64" deliver0 %"PRId64, cur_speed, mono_now, mono_play_time, deliver, deliver0); /* Determine next packet */ @@ -823,7 +820,7 @@ void *timeshift_reader ( void *p ) /* Status message */ skip->time = ts_rescale_inv(sm->sm_time, 1000000); skip->type = SMT_SKIP_ABS_TIME; - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip to pts %"PRId64" ok", ts->id, sm->sm_time); + tvhdebug(LS_TIMESHIFT, "ts %d skip to pts %"PRId64" ok", ts->id, sm->sm_time); /* Update timeshift status */ timeshift_fill_status(ts, &skip->timeshift, sm->sm_time); mono_last_status = mono_now; @@ -831,7 +828,7 @@ void *timeshift_reader ( void *p ) /* Report error */ skip->type = SMT_SKIP_ERROR; skip = NULL; - tvhlog(LOG_DEBUG, "timeshift", "ts %d skip failed (%d)", ts->id, sm ? sm->sm_type : -1); + tvhdebug(LS_TIMESHIFT, "ts %d skip failed (%d)", ts->id, sm ? sm->sm_type : -1); } streaming_target_deliver2(ts->output, ctrl); } else { @@ -859,7 +856,7 @@ void *timeshift_reader ( void *p ) else wait = (deliver - sm->sm_time) / 1000; if (wait == 0) wait = 1; - tvhtrace("timeshift", "ts %d wait %d speed %d sm_time %"PRId64" deliver %"PRId64, + tvhtrace(LS_TIMESHIFT, "ts %d wait %d speed %d sm_time %"PRId64" deliver %"PRId64, ts->id, wait, cur_speed, sm->sm_time, deliver); } @@ -875,12 +872,12 @@ void *timeshift_reader ( void *p ) /* Back to live (unless buffer is full) */ if ((end == 1 && !ts->full) || !seek->file) { - tvhlog(LOG_DEBUG, "timeshift", "ts %d eob revert to live mode", ts->id); + tvhdebug(LS_TIMESHIFT, "ts %d eob revert to live mode", ts->id); cur_speed = 100; ctrl = streaming_msg_create_code(SMT_SPEED, cur_speed); streaming_target_deliver2(ts->output, ctrl); ctrl = NULL; - tvhtrace("timeshift", "reader - set TS_LIVE"); + tvhtrace(LS_TIMESHIFT, "reader - set TS_LIVE"); /* Flush timeshift buffer to live */ if (_timeshift_flush_to_live(ts, seek, &wait) == -1) { @@ -897,20 +894,20 @@ void *timeshift_reader ( void *p ) } else { if (cur_speed <= 0) { cur_speed = 0; - tvhtrace("timeshift", "reader - set TS_PAUSE"); + tvhtrace(LS_TIMESHIFT, "reader - set TS_PAUSE"); ts->state = TS_PAUSE; } else { cur_speed = 100; - tvhtrace("timeshift", "reader - set TS_PLAY"); + tvhtrace(LS_TIMESHIFT, "reader - set TS_PLAY"); if (ts->state != TS_PLAY) { ts->state = TS_PLAY; ts->dobuf = 1; if (mono_play_time != mono_now) - tvhtrace("timeshift", "update play time (pause) - %"PRId64, mono_now); + tvhtrace(LS_TIMESHIFT, "update play time (pause) - %"PRId64, mono_now); mono_play_time = mono_now; } } - tvhlog(LOG_DEBUG, "timeshift", "ts %d sob speed %d last time %"PRId64, ts->id, cur_speed, last_time); + tvhdebug(LS_TIMESHIFT, "ts %d sob speed %d last time %"PRId64, ts->id, cur_speed, last_time); pause_time = last_time; ctrl = streaming_msg_create_code(SMT_SPEED, cur_speed); streaming_target_deliver2(ts->output, ctrl); @@ -927,7 +924,7 @@ void *timeshift_reader ( void *p ) _read_close(seek); if (sm) streaming_msg_free(sm); if (ctrl) streaming_msg_free(ctrl); - tvhtrace("timeshift", "ts %d exit reader thread", ts->id); + tvhtrace(LS_TIMESHIFT, "ts %d exit reader thread", ts->id); return NULL; } diff --git a/src/timeshift/timeshift_writer.c b/src/timeshift/timeshift_writer.c index 9cd6221eb..199214415 100644 --- a/src/timeshift/timeshift_writer.c +++ b/src/timeshift/timeshift_writer.c @@ -69,7 +69,7 @@ static ssize_t _write alloc = MAX(count, 4*1024*1024); ram = realloc(tsf->ram, tsf->ram_size + alloc); if (ram == NULL) { - tvhwarn("timeshift", "RAM timeshift memalloc failed"); + tvhwarn(LS_TIMESHIFT, "RAM timeshift memalloc failed"); pthread_mutex_unlock(&tsf->ram_lock); return -1; } diff --git a/src/trap.c b/src/trap.c index f76fb98d1..0c288580a 100644 --- a/src/trap.c +++ b/src/trap.c @@ -153,7 +153,7 @@ traphandler(int sig, siginfo_t *si, void *UC) #endif const char *reason = NULL; - tvhlog_spawn(LOG_ALERT, "CRASH", "Signal: %d in %s ", sig, line1); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "Signal: %d in %s ", sig, line1); switch(sig) { case SIGSEGV: @@ -170,10 +170,10 @@ traphandler(int sig, siginfo_t *si, void *UC) break; } - tvhlog_spawn(LOG_ALERT, "CRASH", "Fault address %p (%s)", + tvhlog_spawn(LOG_ALERT, LS_CRASH, "Fault address %p (%s)", si->si_addr, reason ?: "N/A"); - tvhlog_spawn(LOG_ALERT, "CRASH", "Loaded libraries: %s ", libs); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "Loaded libraries: %s ", libs); #ifdef NGREG snprintf(tmpbuf, sizeof(tmpbuf), "Register dump [%d]: ", (int)NGREG); @@ -181,10 +181,10 @@ traphandler(int sig, siginfo_t *si, void *UC) sappend(tmpbuf, sizeof(tmpbuf), "%016" PRIx64, uc->uc_mcontext.gregs[i]); } #endif - tvhlog_spawn(LOG_ALERT, "CRASH", "%s", tmpbuf); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "%s", tmpbuf); #if ENABLE_EXECINFO - tvhlog_spawn(LOG_ALERT, "CRASH", "STACKTRACE"); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "STACKTRACE"); for(i = 0; i < nframes; i++) { @@ -192,7 +192,7 @@ traphandler(int sig, siginfo_t *si, void *UC) if(dladdr(frames[i], &dli)) { if(dli.dli_sname != NULL && dli.dli_saddr != NULL) { - tvhlog_spawn(LOG_ALERT, "CRASH", "%s+0x%tx (%s)", + tvhlog_spawn(LOG_ALERT, LS_CRASH, "%s+0x%tx (%s)", dli.dli_sname, frames[i] - dli.dli_saddr, dli.dli_fname); @@ -200,19 +200,19 @@ traphandler(int sig, siginfo_t *si, void *UC) } if(self[0] && !add2lineresolve(self, frames[i], buf, sizeof(buf))) { - tvhlog_spawn(LOG_ALERT, "CRASH", "%s %p", buf, frames[i]); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "%s %p", buf, frames[i]); continue; } if(dli.dli_fname != NULL && dli.dli_fbase != NULL) { - tvhlog_spawn(LOG_ALERT, "CRASH", "%s %p", + tvhlog_spawn(LOG_ALERT, LS_CRASH, "%s %p", dli.dli_fname, frames[i]); continue; } - tvhlog_spawn(LOG_ALERT, "CRASH", "%p", frames[i]); + tvhlog_spawn(LOG_ALERT, LS_CRASH, "%p", frames[i]); } } #endif diff --git a/src/tvheadend.h b/src/tvheadend.h index c3f82058a..b34220874 100644 --- a/src/tvheadend.h +++ b/src/tvheadend.h @@ -806,7 +806,7 @@ static inline uint8_t *sbuf_peek(sbuf_t *sb, int off) { return sb->sb_data + off char *md5sum ( const char *str, int lowercase ); -int makedirs ( const char *subsys, const char *path, int mode, int mstrict, gid_t gid, uid_t uid ); +int makedirs ( int subsys, const char *path, int mode, int mstrict, gid_t gid, uid_t uid ); int rmtree ( const char *path ); diff --git a/src/tvhlog.c b/src/tvhlog.c index 4931d7b60..1b3f83aeb 100644 --- a/src/tvhlog.c +++ b/src/tvhlog.c @@ -67,6 +67,105 @@ static const char *logtxtmeta[9][2] = { {"TRACE", "\033[32m"}, }; +struct logsubsystxt { + const char *name; + const char *desc; +}; + +static struct logsubsystxt logsubsys[] = { + [LS_NONE] = { "", N_("None") }, + [LS_START] = { "START", N_("START") }, + [LS_STOP] = { "STOP", N_("STOP") }, + [LS_CRASH] = { "CRASH", N_("CRASH") }, + [LS_CPU] = { "CPU", N_("CPU") }, + [LS_MAIN] = { "main", N_("Main") }, + [LS_GTIMER] = { "gtimer", N_("Global timer") }, + [LS_MTIMER] = { "mtimer", N_("Monitonic timer") }, + [LS_THREAD] = { "thread", N_("Thread") }, + [LS_TVHPOLL] = { "tvhpoll", N_("Poll multiplexer") }, + [LS_TIME] = { "time", N_("Time") }, + [LS_SPAWN] = { "spawn", N_("Spawn") }, + [LS_FSMONITOR] = { "fsmonitor", N_("Filesystem monitor") }, + [LS_LOCK] = { "lock", N_("Locking") }, + [LS_UUID] = { "uuid", N_("UUID") }, + [LS_IDNODE] = { "idnode", N_("Node subsystem") }, + [LS_URL] = { "url", N_("URL") }, + [LS_TCP] = { "tcp", N_("TCP Protocol") }, + [LS_RTSP] = { "rtsp", N_("RTSP Protocol") }, + [LS_UPNP] = { "upnp", N_("UPnP Protocol") }, + [LS_SETTINGS] = { "settings", N_("Settings") }, + [LS_CONFIG] = { "config", N_("Configuration") }, + [LS_ACCESS] = { "access", N_("Access (ACL)") }, + [LS_CRON] = { "cron", N_("Cron") }, + [LS_DBUS] = { "dbus", N_("DBUS") }, + [LS_AVAHI] = { "avahi", N_("Avahi") }, + [LS_BONJOUR] = { "bonjour", N_("Bonjour") }, + [LS_API] = { "api", N_("API") }, + [LS_HTTP] = { "http", N_("HTTP Server") }, + [LS_HTTPC] = { "httpc", N_("HTTP Client") }, + [LS_HTSP] = { "htsp", N_("HTSP Server") }, + [LS_HTSP_SUB] = { "htsp-sub", N_("HTSP Subscription") }, + [LS_HTSP_REQ] = { "htsp-req", N_("HTSP Request") }, + [LS_HTSP_ANS] = { "htsp-ans", N_("HTSP Answer") }, + [LS_IMAGECACHE] = { "imagecache", N_("Image Cache") }, + [LS_TBL] = { "tbl", N_("DVB SI Tables") }, + [LS_TBL_BASE] = { "tbl-base", N_("Base DVB SI Tables (PAT,CAT,PMT,SDT etc.)") }, + [LS_TBL_CSA] = { "tbl-csa", N_("DVB CSA (descrambling) Tables") }, + [LS_TBL_EIT] = { "tbl-eit", N_("DVB EPG Tables") }, + [LS_TBL_TIME] = { "tbl-time", N_("DVB Time Tables") }, + [LS_TBL_ATSC] = { "tbl-atsc", N_("ATSC SI Tables") }, + [LS_TBL_PASS] = { "tbl-pass", N_("Passthrough Muxer SI Tables") }, + [LS_TBL_SATIP] = { "tbl-satip", N_("SAT>IP Server SI Tables") }, + [LS_FASTSCAN] = { "fastscan", N_("Fastscan DVB") }, + [LS_PARSER] = { "parser", N_("MPEG-TS Parser") }, + [LS_TS] = { "TS", N_("Transport Stream") }, + [LS_GLOBALHEADERS] = { "globalheaders", N_("Global Headers") }, + [LS_TSFIX] = { "tsfix", N_("Time Stamp Fix") }, + [LS_HEVC] = { "hevc", N_("HEVC - H.265") }, + [LS_MUXER] = { "muxer", N_("Muxer") }, + [LS_PASS] = { "pass", N_("Pass-thru muxer") }, + [LS_MKV] = { "mkv", N_("Matroska muxer") }, + [LS_SERVICE] = { "service", N_("Service") }, + [LS_CHANNEL] = { "channel", N_("Channel") }, + [LS_SUBSCRIPTION] = { "subscription", N_("Subscription") }, + [LS_SERVICE_MAPPER]= { "service-mapper",N_("Service Mapper") }, + [LS_BOUQUET] = { "bouquet", N_("Bouquet") }, + [LS_ESFILTER] = { "esfilter", N_("Elementary Stream Filter") }, + [LS_PROFILE] = { "profile", N_("Streaming Profile") }, + [LS_DESCRAMBLER] = { "descrambler", N_("Descrambler") }, + [LS_CACLIENT] = { "caclient", N_("CA (descrambling) Client") }, + [LS_CSA] = { "csa", N_("CSA (descrambling)") }, + [LS_CAPMT] = { "capmt", N_("CAPMT CA Client") }, + [LS_CWC] = { "cwc", N_("CWC CA Client") }, + [LS_DVR] = { "dvr", N_("Digital Video Recorder") }, + [LS_EPG] = { "epg", N_("Electronic Program Guide") }, + [LS_EPGDB] = { "epgdb", N_("EPG Database") }, + [LS_EPGGRAB] = { "epggrab", N_("EPG Grabber") }, + [LS_CHARSET] = { "charset", N_("Charset") }, + [LS_DVB] = { "dvb", N_("DVB") }, + [LS_MPEGTS] = { "mpegts", N_("MPEG-TS") }, + [LS_MUXSCHED] = { "muxsched", N_("Mux Scheduler") }, + [LS_LIBAV] = { "libav", N_("libav / ffmpeg") }, + [LS_TRANSCODE] = { "transcode", N_("Transcode") }, + [LS_IPTV] = { "iptv", N_("IPTV") }, + [LS_IPTV_PCR] = { "iptv-pcr", N_("IPTV PCR") }, + [LS_LINUXDVB] = { "linuxdvb", N_("LinuxDVB Input") }, + [LS_DISEQC] = { "diseqc", N_("DiseqC") }, + [LS_EN50221] = { "en50221", N_("CI Module") }, + [LS_EN50494] = { "en50494", N_("Unicable (EN50494)") }, + [LS_SATIP] = { "satip", N_("SAT>IP Client") }, + [LS_SATIPS] = { "satips", N_("SAT>IP Server") }, + [LS_TVHDHOMERUN] = { "tvhdhomerun", N_("TVHDHomeRun Client") }, + [LS_PSIP] = { "psip", N_("ATSC PSIP EPG") }, + [LS_OPENTV] = { "opentv", N_("OpenTV EPG") }, + [LS_PYEPG] = { "pyepg", N_("PyEPG Import") }, + [LS_XMLTV] = { "xmltv", N_("XMLTV EPG Import") }, + [LS_WEBUI] = { "webui", N_("Web User Interface") }, + [LS_TIMESHIFT] = { "timeshift", N_("Timeshift") }, + [LS_SCANFILE] = { "scanfile", N_("Scanfile") }, + [LS_TSFILE] = { "tsfile", N_("MPEG-TS File") }, +}; + static void tvhlog_get_subsys ( htsmsg_t *ss, char *subsys, size_t len ) { @@ -264,7 +363,7 @@ tvhlog_thread ( void *p ) } void tvhlogv ( const char *file, int line, int severity, - const char *subsys, const char *fmt, va_list *args ) + int subsys, const char *fmt, va_list *args ) { int ok, options, notify; size_t l; @@ -288,11 +387,11 @@ void tvhlogv ( const char *file, int line, int severity, if (severity <= atomic_get(&tvhlog_level)) { if (tvhlog_trace) { ok = htsmsg_get_u32_or_default(tvhlog_trace, "all", 0); - ok = htsmsg_get_u32_or_default(tvhlog_trace, subsys, ok); + ok = htsmsg_get_u32_or_default(tvhlog_trace, logsubsys[subsys].name, ok); } if (!ok && severity == LOG_DEBUG && tvhlog_debug) { ok = htsmsg_get_u32_or_default(tvhlog_debug, "all", 0); - ok = htsmsg_get_u32_or_default(tvhlog_debug, subsys, ok); + ok = htsmsg_get_u32_or_default(tvhlog_debug, logsubsys[subsys].name, ok); } } } else { @@ -318,7 +417,7 @@ void tvhlogv ( const char *file, int line, int severity, if (options & TVHLOG_OPT_THREAD) { tvh_strlcatf(buf, sizeof(buf), l, "tid %ld: ", (long)pthread_self()); } - tvh_strlcatf(buf, sizeof(buf), l, "%s: ", subsys); + tvh_strlcatf(buf, sizeof(buf), l, "%s: ", logsubsys[subsys].name); if (options & TVHLOG_OPT_FILELINE && severity >= LOG_DEBUG) tvh_strlcatf(buf, sizeof(buf), l, "(%s:%d) ", file, line); if (args) @@ -353,7 +452,7 @@ void tvhlogv ( const char *file, int line, int severity, * Map args */ void _tvhlog ( const char *file, int line, int severity, - const char *subsys, const char *fmt, ... ) + int subsys, const char *fmt, ... ) { va_list args; va_start(args, fmt); @@ -367,7 +466,7 @@ void _tvhlog ( const char *file, int line, int severity, #define HEXDUMP_WIDTH 16 void _tvhlog_hexdump(const char *file, int line, int severity, - const char *subsys, const uint8_t *data, ssize_t len ) + int subsys, const uint8_t *data, ssize_t len ) { int i, c; char str[1024]; diff --git a/src/tvhlog.h b/src/tvhlog.h index 748f73720..17eb2a29c 100644 --- a/src/tvhlog.h +++ b/src/tvhlog.h @@ -55,12 +55,12 @@ void tvhlog_get_debug ( char *subsys, size_t len ); void tvhlog_set_trace ( const char *subsys ); void tvhlog_get_trace ( char *subsys, size_t len ); void tvhlogv ( const char *file, int line, int severity, - const char *subsys, const char *fmt, va_list *args ); + int subsys, const char *fmt, va_list *args ); void _tvhlog ( const char *file, int line, int severity, - const char *subsys, const char *fmt, ... ) + int subsys, const char *fmt, ... ) __attribute__((format(printf,5,6))); void _tvhlog_hexdump ( const char *file, int line, int severity, - const char *subsys, const uint8_t *data, ssize_t len ); + int subsys, const uint8_t *data, ssize_t len ); static inline void tvhlog_limit_reset ( tvhlog_limit_t *limit ) { limit->last = 0; limit->count = 0; } static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay ) @@ -89,6 +89,101 @@ static inline int tvhlog_limit ( tvhlog_limit_t *limit, uint32_t delay ) #define LOG_TVH_NOTIFY 0x40000000 +/* Subsystems */ +enum { + LS_NONE, + LS_START, + LS_STOP, + LS_CRASH, + LS_MAIN, + LS_GTIMER, + LS_MTIMER, + LS_CPU, + LS_THREAD, + LS_TVHPOLL, + LS_TIME, + LS_SPAWN, + LS_FSMONITOR, + LS_LOCK, + LS_UUID, + LS_IDNODE, + LS_URL, + LS_TCP, + LS_RTSP, + LS_UPNP, + LS_SETTINGS, + LS_CONFIG, + LS_ACCESS, + LS_CRON, + LS_DBUS, + LS_AVAHI, + LS_BONJOUR, + LS_API, + LS_HTTP, + LS_HTTPC, + LS_HTSP, + LS_HTSP_SUB, + LS_HTSP_REQ, + LS_HTSP_ANS, + LS_IMAGECACHE, + LS_TBL, + LS_TBL_BASE, + LS_TBL_CSA, + LS_TBL_EIT, + LS_TBL_TIME, + LS_TBL_ATSC, + LS_TBL_PASS, + LS_TBL_SATIP, + LS_FASTSCAN, + LS_PARSER, + LS_TS, + LS_GLOBALHEADERS, + LS_TSFIX, + LS_HEVC, + LS_MUXER, + LS_PASS, + LS_MKV, + LS_SERVICE, + LS_CHANNEL, + LS_SUBSCRIPTION, + LS_SERVICE_MAPPER, + LS_BOUQUET, + LS_ESFILTER, + LS_PROFILE, + LS_DESCRAMBLER, + LS_CACLIENT, + LS_CSA, + LS_CAPMT, + LS_CWC, + LS_DVR, + LS_EPG, + LS_EPGDB, + LS_EPGGRAB, + LS_CHARSET, + LS_DVB, + LS_MPEGTS, + LS_MUXSCHED, + LS_LIBAV, + LS_TRANSCODE, + LS_IPTV, + LS_IPTV_PCR, + LS_LINUXDVB, + LS_DISEQC, + LS_EN50221, + LS_EN50494, + LS_SATIP, + LS_SATIPS, + LS_TVHDHOMERUN, + LS_PSIP, + LS_OPENTV, + LS_PYEPG, + LS_XMLTV, + LS_WEBUI, + LS_TIMESHIFT, + LS_SCANFILE, + LS_TSFILE +}; + /* Macros */ #define tvhlog(severity, subsys, fmt, ...)\ _tvhlog(__FILE__, __LINE__, severity | LOG_TVH_NOTIFY, subsys, fmt, ##__VA_ARGS__) diff --git a/src/tvhpoll.c b/src/tvhpoll.c index c6e3d85c6..a12dcfd07 100644 --- a/src/tvhpoll.c +++ b/src/tvhpoll.c @@ -71,14 +71,12 @@ tvhpoll_create ( size_t n ) int fd; #if ENABLE_EPOLL if ((fd = epoll_create1(EPOLL_CLOEXEC)) < 0) { - tvhlog(LOG_ERR, "tvhpoll", "failed to create epoll [%s]", - strerror(errno)); + tvherror(LS_TVHPOLL, "failed to create epoll [%s]", strerror(errno)); return NULL; } #elif ENABLE_KQUEUE if ((fd = kqueue()) == -1) { - tvhlog(LOG_ERR, "tvhpoll", "failed to create kqueue [%s]", - strerror(errno)); + tvherror(LS_TVHPOLL, "failed to create kqueue [%s]", strerror(errno)); return NULL; } #else @@ -129,7 +127,7 @@ int tvhpoll_add EV_SET(tp->ev+i, evs[i].fd, EVFILT_WRITE, EV_ADD, 0, 0, (intptr_t*)evs[i].data.u64); rc = kevent(tp->fd, tp->ev+i, 1, NULL, 0, NULL); if (rc == -1) { - tvhlog(LOG_ERR, "tvhpoll", "failed to add kqueue WRITE filter [%d|%d]", + tvherror(LS_TVHPOLL, "failed to add kqueue WRITE filter [%d|%d]", evs[i].fd, rc); return -1; } @@ -138,8 +136,7 @@ int tvhpoll_add EV_SET(tp->ev+i, evs[i].fd, EVFILT_READ, EV_ADD, 0, 0, (intptr_t*)evs[i].data.u64); rc = kevent(tp->fd, tp->ev+i, 1, NULL, 0, NULL); if (rc == -1) { - tvhlog(LOG_ERR, "tvhpoll", "failed to add kqueue READ filter [%d|%d]", - evs[i].fd, rc); + tvherror(LS_TVHPOLL, "failed to add kqueue READ filter [%d|%d]", evs[i].fd, rc); return -1; } } diff --git a/src/tvhtime.c b/src/tvhtime.c index 1061c3406..03e0ecbc9 100644 --- a/src/tvhtime.c +++ b/src/tvhtime.c @@ -89,7 +89,7 @@ tvhtime_update ( time_t utc, const char *srcname ) localtime_r(&utc, &tm); - tvhtrace("time", "%s - current time is %04d/%02d/%02d %02d:%02d:%02d", + tvhtrace(LS_TIME, "%s - current time is %04d/%02d/%02d %02d:%02d:%02d", srcname, tm.tm_year+1900, tm.tm_mon+1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); @@ -105,14 +105,14 @@ tvhtime_update ( time_t utc, const char *srcname ) if ((diff = llabs(t2 - t1)) > config.tvhtime_tolerance) { #if ENABLE_STIME if (stime(&utc) < 0) - tvherror("time", "%s - unable to update system time: %s", srcname, strerror(errno)); + tvherror(LS_TIME, "%s - unable to update system time: %s", srcname, strerror(errno)); else - tvhdebug("time", "%s - updated system clock", srcname); + tvhdebug(LS_TIME, "%s - updated system clock", srcname); #else - tvhnotice("time", "%s - stime(2) not implemented", srcname); + tvhnotice(LS_TIME, "%s - stime(2) not implemented", srcname); #endif } else { - tvhwarn("time", "%s - time not updated (diff %"PRId64")", srcname, diff); + tvhwarn(LS_TIME, "%s - time not updated (diff %"PRId64")", srcname, diff); } } @@ -121,7 +121,7 @@ tvhtime_update ( time_t utc, const char *srcname ) if (!(ntp_shm = ntp_shm_init())) return; - tvhtrace("time", "ntp delta = %"PRId64" us\n", t2 - t1); + tvhtrace(LS_TIME, "ntp delta = %"PRId64" us\n", t2 - t1); ntp_shm->valid = 0; ntp_shm->count++; ntp_shm->clockTimeStampSec = utc; diff --git a/src/udp.c b/src/udp.c index 7f0a6e12f..bb607256c 100644 --- a/src/udp.c +++ b/src/udp.c @@ -153,7 +153,7 @@ udp_get_solip( void ) } udp_connection_t * -udp_bind ( const char *subsystem, const char *name, +udp_bind ( int subsystem, const char *name, const char *bindaddr, int port, const char *ifname, int rxsize, int txsize ) { @@ -167,7 +167,7 @@ udp_bind ( const char *subsystem, const char *name, uc->host = bindaddr ? strdup(bindaddr) : NULL; uc->port = port; uc->ifname = ifname ? strdup(ifname) : NULL; - uc->subsystem = subsystem ? strdup(subsystem) : NULL; + uc->subsystem = subsystem; uc->name = name ? strdup(name) : NULL; uc->rxtxsize = rxsize; @@ -298,7 +298,7 @@ error: int udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2, - const char *subsystem, const char *name1, + int subsystem, const char *name1, const char *name2, const char *host, int port, const char *ifname, int rxsize1, int rxsize2, int txsize1, int txsize2 ) @@ -340,7 +340,7 @@ fail: } udp_connection_t * -udp_sendinit ( const char *subsystem, const char *name, +udp_sendinit ( int subsystem, const char *name, const char *ifname, int txsize ) { int fd, ifindex; @@ -349,7 +349,7 @@ udp_sendinit ( const char *subsystem, const char *name, uc = calloc(1, sizeof(udp_connection_t)); uc->fd = -1; uc->ifname = ifname ? strdup(ifname) : NULL; - uc->subsystem = subsystem ? strdup(subsystem) : NULL; + uc->subsystem = subsystem; uc->name = name ? strdup(name) : NULL; uc->rxtxsize = txsize; @@ -453,7 +453,6 @@ udp_close( udp_connection_t *uc ) free(uc->host); free(uc->peer_host); free(uc->ifname); - free(uc->subsystem); free(uc->name); free(uc); } diff --git a/src/udp.h b/src/udp.h index b584ac875..bb6a5bf6b 100644 --- a/src/udp.h +++ b/src/udp.h @@ -36,23 +36,23 @@ typedef struct udp_connection { int peer_multicast; struct sockaddr_storage peer; int fd; - char *subsystem; + int subsystem; char *name; int rxtxsize; } udp_connection_t; udp_connection_t * -udp_bind ( const char *subsystem, const char *name, +udp_bind ( int subsystem, const char *name, const char *bindaddr, int port, const char *ifname, int rxsize, int txsize ); int udp_bind_double ( udp_connection_t **_u1, udp_connection_t **_u2, - const char *subsystem, const char *name1, + int subsystem, const char *name1, const char *name2, const char *host, int port, const char *ifname, int rxsize1, int rxsize2, int txsize1, int txsize2 ); udp_connection_t * -udp_sendinit ( const char *subsystem, const char *name, +udp_sendinit ( int subsystem, const char *name, const char *ifname, int txsize ); int udp_connect ( udp_connection_t *uc, const char *name, diff --git a/src/upnp.c b/src/upnp.c index 024bdf5be..5193b0703 100644 --- a/src/upnp.c +++ b/src/upnp.c @@ -137,12 +137,12 @@ upnp_thread( void *aux ) size_t size; int r, delay_ms; - multicast = udp_bind("upnp", "upnp_thread_multicast", + multicast = udp_bind(LS_UPNP, "upnp_thread_multicast", "239.255.255.250", 1900, NULL, 32*1024, 32*1024); if (multicast == NULL || multicast == UDP_FATAL_ERROR) goto error; - unicast = udp_bind("upnp", "upnp_thread_unicast", bindaddr, 0, + unicast = udp_bind(LS_UPNP, "upnp_thread_unicast", bindaddr, 0, NULL, 32*1024, 32*1024); if (unicast == NULL || unicast == UDP_FATAL_ERROR) goto error; @@ -172,10 +172,10 @@ upnp_thread( void *aux ) if (size > 0 && tvhtrace_enabled()) { char tbuf[256]; inet_ntop(ip.ss_family, IP_IN_ADDR(ip), tbuf, sizeof(tbuf)); - tvhtrace("upnp", "%s - received data from %s:%hu [size=%zi]", + tvhtrace(LS_UPNP, "%s - received data from %s:%hu [size=%zi]", conn == multicast ? "multicast" : "unicast", tbuf, (unsigned short) IP_PORT(ip), size); - tvhlog_hexdump("upnp", buf, size); + tvhlog_hexdump(LS_UPNP, buf, size); } /* TODO: a filter */ TAILQ_FOREACH(us, &upnp_services, us_link) diff --git a/src/url.c b/src/url.c index 7f3b9ce44..4700e165c 100644 --- a/src/url.c +++ b/src/url.c @@ -164,7 +164,7 @@ urlparse ( const char *str, url_t *url ) if (!urlparse_exp) { urlparse_exp = calloc(1, sizeof(regex_t)); if (regcomp(urlparse_exp, URL_RE, REG_ICASE | REG_EXTENDED)) { - tvherror("url", "failed to compile regexp"); + tvherror(LS_URL, "failed to compile regexp"); exit(1); } } diff --git a/src/utils.c b/src/utils.c index 26c6b2531..9e5126299 100644 --- a/src/utils.c +++ b/src/utils.c @@ -484,7 +484,7 @@ md5sum ( const char *str, int lowercase ) #define FILE_MODE_BITS(x) (x&(S_IRWXU|S_IRWXG|S_IRWXO)) int -makedirs ( const char *subsys, const char *inpath, int mode, +makedirs ( int subsys, const char *inpath, int mode, int mstrict, gid_t gid, uid_t uid ) { int err, ok; @@ -669,7 +669,7 @@ static void deferred_unlink_cb(void *s, int dearmed) { if (unlink((const char *)s)) - tvherror("main", "unable to remove file '%s'", (const char *)s); + tvherror(LS_MAIN, "unable to remove file '%s'", (const char *)s); free(s); } @@ -686,7 +686,7 @@ deferred_unlink_dir_cb(void *s, int dearmed) int l; if (unlink((const char *)du->filename)) - tvherror("main", "unable to remove file '%s'", (const char *)du->filename); + tvherror(LS_MAIN, "unable to remove file '%s'", (const char *)du->filename); /* Remove all directories up to rootdir */ diff --git a/src/uuid.c b/src/uuid.c index e4597b582..a2439e4e2 100644 --- a/src/uuid.c +++ b/src/uuid.c @@ -98,7 +98,7 @@ uuid_init ( void ) { fd = tvh_open(RANDOM_PATH, O_RDONLY, 0); if (fd == -1) { - tvherror("uuid", "failed to open %s", RANDOM_PATH); + tvherror(LS_UUID, "failed to open %s", RANDOM_PATH); exit(1); } } @@ -107,7 +107,7 @@ void uuid_random ( uint8_t *buf, size_t bufsize ) { if (read(fd, buf, bufsize) != bufsize) { - tvherror("uuid", "random failed: %s", strerror(errno)); + tvherror(LS_UUID, "random failed: %s", strerror(errno)); exit(1); } } @@ -119,12 +119,12 @@ uuid_init_bin ( tvh_uuid_t *u, const char *str ) memset(u, 0, sizeof(tvh_uuid_t)); if (str) { if (strlen(str) != UUID_HEX_SIZE - 1) { - tvherror("uuid", "wrong uuid size"); + tvherror(LS_UUID, "wrong uuid size"); return -EINVAL; } return hex2bin(u->bin, sizeof(u->bin), str); } else if (read(fd, u->bin, sizeof(u->bin)) != sizeof(u->bin)) { - tvherror("uuid", "failed to read from %s", RANDOM_PATH); + tvherror(LS_UUID, "failed to read from %s", RANDOM_PATH); return -EINVAL; } return 0; diff --git a/src/webui/simpleui.c b/src/webui/simpleui.c index 7203e6e92..cbe94e6b9 100644 --- a/src/webui/simpleui.c +++ b/src/webui/simpleui.c @@ -508,7 +508,7 @@ page_status(http_connection_t *hc, #ifdef ENABLE_GETLOADAVG loads = getloadavg (avg, 3); if (loads == -1) { - tvhlog(LOG_DEBUG, "webui", "Error getting load average from getloadavg()"); + tvhdebug(LS_WEBUI, "Error getting load average from getloadavg()"); loads = 0; /* should we return an error or a 0 on error */ htsbuf_qprintf(hq, "0\n"); diff --git a/src/webui/webui.c b/src/webui/webui.c index ffdbde915..abbf36582 100644 --- a/src/webui/webui.c +++ b/src/webui/webui.c @@ -255,7 +255,7 @@ page_static_file(http_connection_t *hc, const char *_remain, void *opaque) fb_file *fp = fb_open(path, 0, (nogzip || gzip) ? 0 : 1); if (!fp) { - tvhlog(LOG_ERR, "webui", "failed to open %s", path); + tvherror(LS_WEBUI, "failed to open %s", path); return HTTP_STATUS_INTERNAL; } size = fb_size(fp); @@ -350,11 +350,11 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, if (r == ETIMEDOUT) { /* Check socket status */ if (tcp_socket_dead(hc->hc_fd)) { - tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", hc->hc_url_orig); + tvhdebug(LS_WEBUI, "Stop streaming %s, client hung up", hc->hc_url_orig); run = 0; } else if((!started && mclk() - lastpkt > sec2mono(grace)) || (started && ptimeout > 0 && mclk() - lastpkt > sec2mono(ptimeout))) { - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); + tvhwarn(LS_WEBUI, "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); run = 0; } break; @@ -392,8 +392,8 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, case SMT_START: grace = 10; if(!started) { - tvhlog(LOG_DEBUG, "webui", "%s streaming %s", - hc->hc_no_output ? "Probe" : "Start", hc->hc_url_orig); + tvhdebug(LS_WEBUI, "%s streaming %s", + hc->hc_no_output ? "Probe" : "Start", hc->hc_url_orig); http_output_content(hc, muxer_mime(mux, sm->sm_data)); if (hc->hc_no_output) { @@ -414,26 +414,26 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, started = 1; } else if(muxer_reconfigure(mux, sm->sm_data) < 0) { - tvhlog(LOG_WARNING, "webui", "Unable to reconfigure stream %s", hc->hc_url_orig); + tvhwarn(LS_WEBUI, "Unable to reconfigure stream %s", hc->hc_url_orig); } break; case SMT_STOP: if(sm->sm_code != SM_CODE_SOURCE_RECONFIGURED) { - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, %s", hc->hc_url_orig, - streaming_code2txt(sm->sm_code)); + tvhwarn(LS_WEBUI, "Stop streaming %s, %s", hc->hc_url_orig, + streaming_code2txt(sm->sm_code)); run = 0; } break; case SMT_SERVICE_STATUS: if(tcp_socket_dead(hc->hc_fd)) { - tvhlog(LOG_DEBUG, "webui", "Stop streaming %s, client hung up", - hc->hc_url_orig); + tvhdebug(LS_WEBUI, "Stop streaming %s, client hung up", + hc->hc_url_orig); run = 0; } else if((!started && mclk() - lastpkt > sec2mono(grace)) || (started && ptimeout > 0 && mclk() - lastpkt > sec2mono(ptimeout))) { - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); + tvhwarn(LS_WEBUI, "Stop streaming %s, timeout waiting for packets", hc->hc_url_orig); run = 0; } break; @@ -447,14 +447,14 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, break; case SMT_NOSTART: - tvhlog(LOG_WARNING, "webui", "Couldn't start streaming %s, %s", - hc->hc_url_orig, streaming_code2txt(sm->sm_code)); + tvhwarn(LS_WEBUI, "Couldn't start streaming %s, %s", + hc->hc_url_orig, streaming_code2txt(sm->sm_code)); run = 0; break; case SMT_EXIT: - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, %s", hc->hc_url_orig, - streaming_code2txt(sm->sm_code)); + tvhwarn(LS_WEBUI, "Stop streaming %s, %s", hc->hc_url_orig, + streaming_code2txt(sm->sm_code)); run = 0; break; } @@ -463,7 +463,7 @@ http_stream_run(http_connection_t *hc, profile_chain_t *prch, if(mux->m_errors) { if (!mux->m_eos) - tvhlog(LOG_WARNING, "webui", "Stop streaming %s, muxer reported errors", hc->hc_url_orig); + tvhwarn(LS_WEBUI, "Stop streaming %s, muxer reported errors", hc->hc_url_orig); run = 0; } } @@ -1843,7 +1843,7 @@ webui_init(int xspf) webui_xspf = xspf; if (tvheadend_webui_debug) - tvhlog(LOG_INFO, "webui", "Running web interface in debug mode"); + tvhinfo(LS_WEBUI, "Running web interface in debug mode"); s = tvheadend_webroot; tvheadend_webroot = NULL; diff --git a/src/wrappers.c b/src/wrappers.c index 9b3572c0a..a354f2ee7 100644 --- a/src/wrappers.c +++ b/src/wrappers.c @@ -154,7 +154,7 @@ thread_wrapper ( void *p ) signal(SIGQUIT, doquit); /* Run */ - tvhtrace("thread", "created thread %ld [%s / %p(%p)]", + tvhtrace(LS_THREAD, "created thread %ld [%s / %p(%p)]", (long)pthread_self(), ts->name, ts->run, ts->arg); void *r = ts->run(ts->arg); free(ts);