}
}
-static void open_receiver(int format)
+static int open_receiver(int format)
{
struct audio_format_info *a = &afi[format];
struct slot_info *s;
int ret, slot_num;
struct receiver_node *rn;
+ const struct timeval restart_delay = {1, 0};
- slot_num = get_empty_slot();
- if (slot_num < 0)
- clean_exit(EXIT_FAILURE, PARA_STRERROR(-slot_num));
+ ret = get_empty_slot();
+ if (ret < 0)
+ goto err;
+ slot_num = ret;
s = &slot[slot_num];
s->format = format;
s->receiver_node = para_calloc(sizeof(struct receiver_node));
rn->conf = a->receiver_conf;
ret = a->receiver->open(s->receiver_node);
if (ret < 0) {
- PARA_ERROR_LOG("failed to open receiver (%s)\n",
- PARA_STRERROR(-ret));
free(s->receiver_node);
s->receiver_node = NULL;
- return;
+ goto err;
}
PARA_NOTICE_LOG("started %s: %s receiver in slot %d\n",
audio_formats[s->format], a->receiver->name, slot_num);
rn->task.event_handler = rn_event_handler;
sprintf(rn->task.status, "%s receiver node", rn->receiver->name);
register_task(&rn->task);
+ return 1;
+err:
+ PARA_ERROR_LOG("%s\n", PARA_STRERROR(-ret));
+ tv_add(now, &restart_delay, &afi[format].restart_barrier);
+ return ret;
}
static int receiver_running(int format)
s->timeout = diff;
return 0;
}
- open_receiver(i);
- return 1;
+ return open_receiver(i) < 0? 0 : 1;
}
static void compute_time_diff(const struct timeval *status_time)