#include "string.h"
#include "fd.h"
#include "write.h"
-#include "write_common.h"
#include "signal.h"
#include "version.h"
struct lls_parse_result **filter_lpr;
/** the number of filters that should be activated for this audio format */
unsigned int num_writers;
- /** Array of writer numbers to be activated. */
- int *writer_nums;
- /** pointer to the array of writer configurations */
- void **writer_conf;
+ /** Array of writer IDs to be activated. */
+ int *wids;
+ /** Parsed writer command line(s) */
+ struct lls_parse_result **writer_lpr;
/** do not start receiver/filters/writer before this time */
struct timeval restart_barrier;
};
static void writer_cleanup(struct writer_node *wn)
{
- struct writer *w;
-
if (!wn)
return;
- w = writers + wn->writer_num;
- PARA_INFO_LOG("closing %s\n", writer_names[wn->writer_num]);
- w->close(wn);
+ PARA_INFO_LOG("closing %s\n", writer_name(wn->wid));
+ writer_get(wn->wid)->close(wn);
btr_remove_node(&wn->btrn);
task_reap(&wn->task);
}
* sizeof(struct writer_node));
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];
+ wn->wid = a->wids[i];
+ wn->lpr = a->writer_lpr[i];
register_writer_node(wn, parent, &sched);
PARA_NOTICE_LOG("%s writer started in slot %d\n",
- writer_names[a->writer_nums[i]], (int)(s - slot));
+ writer_name(a->wids[i]), (int)(s - slot));
}
}
struct audio_format_info *a;
for (i = 0; i < conf.writer_given; i++) {
- void *wconf;
- int j, nw, writer_num, af_mask;
+ int j, nw, af_mask;
ret = parse_stream_command(conf.writer_arg[i], &cmd);
if (ret < 0)
a = afi + j;
if ((af_mask & (1 << j)) == 0) /* no match */
continue;
- 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;
+ a->wids = para_realloc(a->wids, (nw + 1) * sizeof(int));
+ a->writer_lpr = para_realloc(a->writer_lpr,
+ (nw + 1) * sizeof(struct lls_parse_result *));
+ a->wids[nw] = check_writer_arg_or_die(cmd,
+ a->writer_lpr + nw);
PARA_INFO_LOG("%s writer #%d: %s\n", audio_formats[j],
- nw, writer_names[writer_num]);
+ nw, writer_name(a->wids[nw]));
a->num_writers++;
}
}
/* Use default writer for audio formats which are not yet set up. */
FOR_EACH_AUDIO_FORMAT(i) {
- void *writer_conf;
- int writer_num;
a = afi + i;
if (a->num_writers > 0)
continue; /* already set up */
- writer_conf = check_writer_arg_or_die(NULL, &writer_num);
- a->writer_nums = para_malloc(sizeof(int));
- a->writer_nums[0] = writer_num;
- a->writer_conf = para_malloc(sizeof(void *));
- a->writer_conf[0] = writer_conf;
a->num_writers = 1;
+ a->wids = para_malloc(sizeof(int));
+ a->writer_lpr = para_malloc(sizeof(struct lls_parse_result *));
+ a->wids[0] = check_writer_arg_or_die(NULL, a->writer_lpr);
PARA_INFO_LOG("%s writer: %s (default)\n", audio_formats[i],
- writer_names[writer_num]);
+ writer_name(a->wids[0]));
}
return 1;
}
version_handle_flag("audiod", conf.version_given);
/* init receivers/filters/writers early to make help work */
recv_init();
- writer_init();
if (conf.help_given || conf.detailed_help_given)
print_help_and_die();
daemon_set_priority(conf.priority_arg);