length / 60,
length % 60
);
- PARA_DEBUG_LOG("slot %d: %s\n", slot_num, msg);
+ //PARA_DEBUG_LOG("slot %d: %s\n", slot_num, msg);
return msg;
empty:
return para_strdup(NULL);
assert(s->wns == NULL);
s->wns = para_calloc(PARA_MAX(1U, a->num_writers)
* sizeof(struct writer_node));
- if (a->num_writers == 0)
- setup_writer_node(NULL, parent, s->wns);
- else {
- PARA_INFO_LOG("opening %s writers\n", audio_formats[s->format]);
- for (i = 0; i < a->num_writers; i++) {
- wn = s->wns + i;
- wn->conf = a->writer_conf[i];
- wn->writer_num = a->writer_nums[i];
- register_writer_node(wn, parent);
- }
+ PARA_INFO_LOG("opening %s writers\n", audio_formats[s->format]);
+ for (i = 0; i < a->num_writers; i++) {
+ wn = s->wns + i;
+ wn->conf = a->writer_conf[i];
+ wn->writer_num = a->writer_nums[i];
+ register_writer_node(wn, parent);
}
}
{
struct audio_format_info *a = &afi[format];
int filter_num, nf = a->num_filters;
+ void *cfg;
- filter_num = check_filter_arg(cmdline, &a->filter_conf[nf]);
+ filter_num = check_filter_arg(cmdline, &cfg);
if (filter_num < 0)
return filter_num;
+ a->filter_conf = para_realloc(a->filter_conf,
+ (nf + 1) * sizeof(void *));
+ a->filter_nums = para_realloc(a->filter_nums,
+ (nf + 1) * sizeof(unsigned));
a->filter_nums[nf] = filter_num;
+ a->filter_conf[nf] = cfg;
a->num_filters++;
PARA_INFO_LOG("%s filter %d: %s\n", audio_formats[format], nf,
filters[filter_num].name);
ret = parse_stream_command(conf.writer_arg[i], &cmd);
if (ret < 0)
- goto out;
+ return ret;
af_mask = ret;
FOR_EACH_AUDIO_FORMAT(j) {
a = afi + j;
if ((af_mask & (1 << j)) == 0) /* no match */
continue;
- ret = -E_WRITE_COMMON_SYNTAX;
- wconf = check_writer_arg(cmd, &writer_num);
- if (!wconf)
- goto out;
+ wconf = check_writer_arg_or_die(cmd, &writer_num);
nw = a->num_writers;
a->writer_nums = para_realloc(a->writer_nums, (nw + 1) * sizeof(int));
a->writer_conf = para_realloc(a->writer_conf, (nw + 1) * sizeof(void *));
a->writer_nums[nw] = writer_num;
a->writer_conf[nw] = wconf;
- PARA_INFO_LOG("%s writer #%d: %s\n", audio_formats[writer_num],
+ PARA_INFO_LOG("%s writer #%d: %s\n", audio_formats[j],
nw, writer_names[writer_num]);
a->num_writers++;
}
}
- ret = 1;
-out:
- return ret;
+ /* Use default writer for audio formats which are not yet set up. */
+ FOR_EACH_AUDIO_FORMAT(i) {
+ struct writer *w = writers + DEFAULT_WRITER;
+ a = afi + i;
+ if (a->num_writers > 0)
+ continue; /* already set up */
+ PARA_INFO_LOG("%s writer: %s (default)\n", audio_formats[i],
+ writer_names[DEFAULT_WRITER]);
+ a->writer_nums = para_malloc(sizeof(int));
+ a->writer_nums[0] = DEFAULT_WRITER;
+ a->writer_conf = para_malloc(sizeof(void *));
+ a->writer_conf[0] = w->parse_config_or_die("");
+ a->num_writers = 1;
+ }
+ return 1;
}
static int parse_receiver_args(void)
struct audio_format_info *a;
for (i = conf.receiver_given - 1; i >= 0; i--) {
- char *arg = conf.receiver_arg[i];
- char *recv_arg = strchr(arg, ':');
- int af_mask, j;
+ char *arg;
+ int j, af_mask;
- ret = -E_MISSING_COLON;
- if (!recv_arg)
- goto out;
- *recv_arg = '\0';
- recv_arg++;
- ret = get_matching_audio_format_nums(arg);
+ ret = parse_stream_command(conf.receiver_arg[i], &arg);
if (ret < 0)
goto out;
af_mask = ret;
*/
if (a->receiver_conf)
a->receiver->free_config(a->receiver_conf);
- a->receiver_conf = check_receiver_arg(recv_arg, &receiver_num);
+ a->receiver_conf = check_receiver_arg(arg, &receiver_num);
ret = -E_RECV_SYNTAX;
if (!a->receiver_conf)
goto out;
if (a->num_filters)
continue; /* no default -- nothing to to */
/*
- * If udp is used to receive this audiod format, add fecdec as
- * the first filter.
+ * udp and dccp streams are fec-encoded, so add fecdec as the
+ * first filter.
*/
if (strcmp(afi[i].receiver->name, "udp") == 0 ||
strcmp(afi[i].receiver->name, "dccp") == 0) {
static int parse_filter_args(void)
{
- int i, ret, nf;
+ int i, j, ret, af_mask;
- nf = PARA_MAX(2U, conf.filter_given);
- PARA_INFO_LOG("maximal number of filters: %d\n", nf);
- FOR_EACH_AUDIO_FORMAT(i) {
- afi[i].filter_conf = para_malloc(nf * sizeof(void *));
- afi[i].filter_nums = para_malloc(nf * sizeof(unsigned));
- }
if (!conf.no_default_filters_given)
return init_default_filters();
for (i = 0; i < conf.filter_given; i++) {
- char *arg = conf.filter_arg[i];
- char *filter_name = strchr(arg, ':');
- ret = -E_MISSING_COLON;
- if (!filter_name)
- goto out;
- *filter_name = '\0';
- filter_name++;
- ret = get_audio_format_num(arg);
- if (ret < 0)
- goto out;
- ret = add_filter(ret, filter_name);
+ char *arg;
+ ret = parse_stream_command(conf.filter_arg[i], &arg);
if (ret < 0)
goto out;
+ af_mask = ret;
+ FOR_EACH_AUDIO_FORMAT(j) {
+ if ((af_mask & (1 << j)) == 0) /* no match */
+ continue;
+ ret = add_filter(j, arg);
+ if (ret < 0)
+ goto out;
+ }
}
ret = init_default_filters(); /* use default values for the rest */
out:
{
if (!stat_task->ct)
return;
- btr_free_node(stat_task->ct->btrn);
client_close(stat_task->ct);
stat_task->ct = NULL;
clear_and_dump_items();