diff --git a/src/subscriptions.c b/src/subscriptions.c index 2edf4d73..86abfcd7 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -51,10 +51,10 @@ static int subscription_postpone; /** * */ -int -subscriptions_active(void) +static inline int +shortid(th_subscription_t *s) { - return LIST_FIRST(&subscriptions) != NULL; + return s->ths_id & 0xffff; } /* ************************************************************************** @@ -73,7 +73,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", "linking sub %p to svc %p", s, t); + tvhtrace("subscription", "%04X: linking sub %p to svc %p", shortid(s), s, t); pthread_mutex_lock(&t->s_stream_mutex); @@ -122,7 +122,7 @@ subscription_unlink_service0(th_subscription_t *s, int reason, int stop) /* Ignore - not actually linked */ if (!s->ths_current_instance) return; - tvhtrace("subscription", "unlinking sub %p from svc %p", s, t); + tvhtrace("subscription", "%04X: unlinking sub %p from svc %p", shortid(s), s, t); pthread_mutex_lock(&t->s_stream_mutex); @@ -198,9 +198,9 @@ subscription_show_none(th_subscription_t *s) { channel_t *ch = s->ths_channel; tvhlog(LOG_NOTICE, "subscription", - "No transponder available for subscription \"%s\" " + "%04X: No transponder available for subscription \"%s\" " "to channel \"%s\"", - s->ths_title, ch ? channel_get_name(ch) : "none"); + shortid(s), s->ths_title, ch ? channel_get_name(ch) : "none"); } static void @@ -233,7 +233,7 @@ subscription_show_info(th_subscription_t *s) s->ths_client ?: ""); } - tvhlog(LOG_INFO, "subscription", "%s", buf); + tvhlog(LOG_INFO, "subscription", "%04X: %s", shortid(s), buf); } /** @@ -306,11 +306,11 @@ subscription_reschedule(void) error = s->ths_testing_error; if (s->ths_channel) - tvhtrace("subscription", "find service for %s weight %d", - channel_get_name(s->ths_channel), s->ths_weight); + tvhtrace("subscription", "%04X: find service for %s weight %d", + shortid(s), channel_get_name(s->ths_channel), s->ths_weight); else - tvhtrace("subscription", "find instance for %s weight %d", - s->ths_service->s_nicename, s->ths_weight); + tvhtrace("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_instances, &error, s->ths_weight, s->ths_flags, s->ths_timeout, @@ -320,7 +320,7 @@ subscription_reschedule(void) if(si == NULL) { if (s->ths_last_error != error || s->ths_last_find + 2 >= dispatch_clock) { - tvhtrace("subscription", "instance not available, retrying"); + tvhtrace("subscription", "%04X: instance not available, retrying", shortid(s)); if (s->ths_last_error != error) s->ths_last_find = dispatch_clock; s->ths_last_error = error; @@ -328,11 +328,11 @@ subscription_reschedule(void) } if (s->ths_flags & SUBSCRIPTION_RESTART) { if (s->ths_channel) - tvhwarn("subscription", "restarting channel %s", - channel_get_name(s->ths_channel)); + tvhwarn("subscription", "%04X: restarting channel %s", + shortid(s), channel_get_name(s->ths_channel)); else - tvhwarn("subscription", "restarting service %s", - s->ths_service->s_nicename); + tvhwarn("subscription", "%04X: restarting service %s", + shortid(s), s->ths_service->s_nicename); s->ths_testing_error = 0; s->ths_current_instance = NULL; service_instance_list_clear(&s->ths_instances); @@ -541,7 +541,7 @@ subscription_unsubscribe(th_subscription_t *s) s->ths_username ?: "", s->ths_client ?: ""); } - tvhlog(LOG_INFO, "subscription", "%s", buf); + tvhlog(LOG_INFO, "subscription", "%04X: %s", shortid(s), buf); if(t) service_remove_subscriber(t, s, SM_CODE_OK); @@ -648,11 +648,14 @@ subscription_create_from_channel_or_service(channel_t *ch, assert(!ch || !t); assert(st); - if (ch) - tvhtrace("subscription", "creating subscription for %s weight %d", - channel_get_name(ch), weight); s = subscription_create(pro, weight, name, st, flags, subscription_input, hostname, username, client); + if (ch) + tvhtrace("subscription", "%04X: creating subscription for %s weight %d", + shortid(s), channel_get_name(ch), weight); + else + tvhtrace("subscription", "%04X: creating subscription for service %s weight %d", + shortid(s), t->s_nicename, weight); s->ths_channel = ch; s->ths_service = t; if (ch) @@ -793,9 +796,10 @@ subscription_create_from_mux(mpegts_mux_t *mm, profile_t *pro, ss->ss_si.si_service = strdup("rawmux"); tvhinfo("subscription", - "'%s' subscribing to mux, weight: %d, adapter: '%s', " - "network: '%s', mux: '%s', hostname: '%s', username: '%s', " - "client: '%s'", + "%04X: \"%s\" subscribing to mux, weight: %d, adapter: \"%s\", " + "network: \"%s\", mux: \"%s\", hostname: \"%s\", username: \"%s\", " + "client: \"%s\"", + shortid(s), s->ths_title, s->ths_weight, ss->ss_si.si_adapter ?: "", @@ -1054,6 +1058,7 @@ subscription_dummy_join(const char *id, int first) { service_t *t = service_find_by_identifier(id); streaming_target_t *st; + th_subscription_t *s; if(first) { gtimer_arm(&dummy_sub_timer, dummy_retry, strdup(id), 2); @@ -1070,8 +1075,8 @@ subscription_dummy_join(const char *id, int first) st = calloc(1, sizeof(streaming_target_t)); streaming_target_init(st, dummy_callback, NULL, 0); - subscription_create_from_service(t, NULL, 1, "dummy", st, 0, NULL, NULL, "dummy"); + s = subscription_create_from_service(t, NULL, 1, "dummy", st, 0, NULL, NULL, "dummy"); - tvhlog(LOG_NOTICE, "subscription", - "Dummy join %s ok", id); + tvhlog(LOG_NOTICE, "subscription", + "%04X: Dummy join %s ok", shortid(s), id); } diff --git a/src/subscriptions.h b/src/subscriptions.h index e3f07cb5..76461bad 100644 --- a/src/subscriptions.h +++ b/src/subscriptions.h @@ -188,7 +188,9 @@ void subscription_unlink_mux(th_subscription_t *s, int reason); void subscription_dummy_join(const char *id, int first); -int subscriptions_active(void); + +static inline int subscriptions_active(void) + { return LIST_FIRST(&subscriptions) != NULL; } struct htsmsg; struct htsmsg *subscription_create_msg(th_subscription_t *s);