Currently we set the slot's audio format number even if the receiver could not
be opened. This confuses the slot clearing code as no writer is active in
this case which triggers the assertion
para_audiod: audiod.c:384: close_writers: Assertion `s->wns'
Fix it by not touching the slot info structure unless we have successfully started
the receiver. Also perform some minor cleanups while we're at it.
Thanks to Gerrit Renker for pointing out this bug.
int ret, slot_num;
struct receiver *r = a->receiver;
struct receiver_node *rn;
int ret, slot_num;
struct receiver *r = a->receiver;
struct receiver_node *rn;
- const struct timeval restart_delay = {2, 0};
+ tv_add(now, &(struct timeval)EMBRACE(2, 0), &a->restart_barrier);
ret = get_empty_slot();
if (ret < 0)
ret = get_empty_slot();
if (ret < 0)
- s = &slot[slot_num];
- s->format = format;
- s->receiver_node = para_calloc(sizeof(struct receiver_node));
- rn = s->receiver_node;
+ rn = para_calloc(sizeof(*rn));
rn->receiver = r;
rn->conf = a->receiver_conf;
rn->btrn = btr_new_node(&(struct btr_node_description)
rn->receiver = r;
rn->conf = a->receiver_conf;
rn->btrn = btr_new_node(&(struct btr_node_description)
if (ret < 0) {
btr_free_node(rn->btrn);
free(rn);
if (ret < 0) {
btr_free_node(rn->btrn);
free(rn);
- s->receiver_node = NULL;
- goto err;
+ s = &slot[slot_num];
+ s->format = format;
+ s->receiver_node = rn;
PARA_NOTICE_LOG("started %s: %s receiver in slot %d\n",
PARA_NOTICE_LOG("started %s: %s receiver in slot %d\n",
- audio_formats[s->format], r->name, slot_num);
+ audio_formats[format], r->name, slot_num);
rn->task.pre_select = r->pre_select;
rn->task.post_select = r->post_select;
sprintf(rn->task.status, "%s receiver node", r->name);
register_task(&rn->task);
rn->task.pre_select = r->pre_select;
rn->task.post_select = r->post_select;
sprintf(rn->task.status, "%s receiver node", r->name);
register_task(&rn->task);
- ret = slot_num;
-err:
- if (ret < 0)
- PARA_ERROR_LOG("%s\n", para_strerror(-ret));
- tv_add(now, &restart_delay, &afi[format].restart_barrier);
- return ret;
}
/* return: 0: Not running, 1: Running, -1: Running but eof (or error) */
}
/* return: 0: Not running, 1: Running, -1: Running but eof (or error) */
if (!must_start_decoder())
return;
ret = open_receiver(stat_task->current_audio_format_num);
if (!must_start_decoder())
return;
ret = open_receiver(stat_task->current_audio_format_num);
+ if (ret < 0) {
+ PARA_ERROR_LOG("%s\n", para_strerror(-ret));
sl = slot + ret;
a = afi + sl->format;
if (a->num_filters)
sl = slot + ret;
a = afi + sl->format;
if (a->num_filters)