lock_assert(&global_lock);
+ tvhtrace("service", "starting %s", t->s_nicename);
+
assert(t->s_status != SERVICE_RUNNING);
t->s_streaming_status = 0;
TAILQ_FOREACH(si, sil, si_link) {
const char *name = ch ? channel_get_name(ch) : NULL;
if (!name && s) name = s->s_nicename;
- tvhdebug("service", "%s si %p weight %d prio %d error %d\n",
+ tvhdebug("service", "%s si %p weight %d prio %d error %d",
name, si, si->si_weight, si->si_prio, si->si_error);
}
/* Already running? */
TAILQ_FOREACH(si, sil, si_link)
- if(si->si_s->s_status == SERVICE_RUNNING && si->si_error == 0)
+ if(si->si_s->s_status == SERVICE_RUNNING && si->si_error == 0) {
+ tvhtrace("service", "return already running %p", si);
return si;
+ }
/* Forced or Idle */
TAILQ_FOREACH(si, sil, si_link)
}
/* Start */
- service_start(si->si_s, si->si_instance);
+ tvhtrace("service", "will start new instance %d", si->si_instance);
+ if (service_start(si->si_s, si->si_instance)) {
+ tvhtrace("service", "tuning failed");
+ *error = SM_CODE_TUNING_FAILED;
+ si = NULL;
+ }
return si;
}
int n;
streaming_message_t *sm;
lock_assert(&t->s_stream_mutex);
-
+
n = t->s_streaming_status;
n |= set;
void
service_mapper_process ( service_t *s )
{
- int num;
channel_t *chn = NULL;
+ const char *name;
/* Ignore */
if (s->s_status == SERVICE_ZOMBIE)
goto exit;
/* Find existing channel */
- num = s->s_channel_number(s);
- if (service_mapper_conf.merge_same_name && s->s_channel_name)
- chn = channel_find_by_name(s->s_channel_name(s) ?: "");
+ name = service_get_channel_name(s);
+ if (service_mapper_conf.merge_same_name && name && *name)
+ chn = channel_find_by_name(name);
if (!chn)
- chn = channel_create(NULL, NULL, s->s_channel_name(s));
+ chn = channel_create(NULL, NULL, NULL);
/* Map */
if (chn) {
} else if (service_is_sdtv(s)) {
channel_tag_map(chn, channel_tag_find_by_name("TV channels", 1));
channel_tag_map(chn, channel_tag_find_by_name("SDTV", 1));
- } else {
+ } else if (service_is_radio(s)) {
channel_tag_map(chn, channel_tag_find_by_name("Radio", 1));
}
- /* Set number */
- if (!chn->ch_number && num)
- chn->ch_number = num;
-
/* Provider */
if (service_mapper_conf.provider_tags)
if ((prov = s->s_provider_name(s)))
streaming_queue_t sq;
streaming_message_t *sm;
const char *err;
- streaming_target_t *st;
streaming_queue_init(&sq, 0);
/* Subscribe */
tvhinfo("service_mapper", "%s: checking availability", s->s_nicename);
- st = tsfix_create(&sq.sq_st);
- sub = subscription_create_from_service(s, 2, "service_mapper", st,
+ sub = subscription_create_from_service(s, 3, "service_mapper", &sq.sq_st,
0, NULL, NULL, "service_mapper");
/* Failed */
run = 0;
err = service_tss2text(status);
}
+ } else if (sm->sm_type == SMT_NOSTART) {
+ run = 0;
+ err = "could not start";
}
streaming_msg_free(sm);
pthread_mutex_lock(&global_lock);
subscription_unsubscribe(sub);
- tsfix_destroy(st);
if(err)
- tvhinfo("service_mapper", "%s: failed %s", s->s_nicename, err);
+ tvhinfo("service_mapper", "%s: failed [err %s]", s->s_nicename, err);
else
service_mapper_process(s);