// We constantly update the track time to event about it to our clients.
static void *thread_update_track_time(void *userdata) {
	const gint64 one_sec_unit = 1000000000LL;
	char tbuf[32];
	gint64 last_duration = -1, last_position = -1;
	for (;;) {
		usleep(500000);  // 500ms
		service_lock();
		gint64 duration, position;
		const int pos_result = output_get_position(&duration, &position);
		if (pos_result == 0) {
			if (duration != last_duration) {
				print_upnp_time(tbuf, sizeof(tbuf), duration);
				replace_var(TRANSPORT_VAR_CUR_TRACK_DUR, tbuf);
				last_duration = duration;
			}
			if (position / one_sec_unit != last_position) {
				print_upnp_time(tbuf, sizeof(tbuf), position);
				replace_var(TRANSPORT_VAR_REL_TIME_POS, tbuf);
				last_position = position / one_sec_unit;
			}
		}
		service_unlock();
	}
	return NULL;  // not reached.
}
static void shared_meta_time_change(uint32_t total, uint32_t current)
{
	char tbuf[32];
	service_lock();
	print_upnp_time(tbuf, sizeof(tbuf), total);
	replace_var(TRANSPORT_VAR_CUR_TRACK_DUR, tbuf);
	print_upnp_time(tbuf, sizeof(tbuf), current);
	replace_var(TRANSPORT_VAR_REL_TIME_POS, tbuf);
	service_unlock();
}