n = OPT_GIVEN(USER_ALLOW);
if (n == 0)
return;
- uid_whitelist = para_malloc(n * sizeof(uid_t));
+ uid_whitelist = alloc(n * sizeof(uid_t));
for (i = 0; i < n; i++) {
const char *arg = lls_string_val(i, OPT_RESULT(USER_ALLOW));
int32_t val;
task_reap(&s->receiver_node->task);
free(s->receiver_node);
s->receiver_node = NULL;
- stat_task->current_audio_format_num = -1;
+ if (audiod_status == AUDIOD_ON)
+ stat_task->current_audio_format_num = -1;
tv_add(now, &(struct timeval)EMBRACE(0, 200 * 1000),
&a->restart_barrier);
}
s->wns = NULL;
}
+static void notify_writers(int error)
+{
+ int i;
+
+ FOR_EACH_SLOT(i) {
+ struct slot_info *s = slot + i;
+ struct audio_format_info *a;
+ int j;
+
+ if (s->format < 0)
+ continue;
+ a = afi + s->format;
+ for (j = 0; j < a->num_writers; j++)
+ task_notify(s->wns[j].task, error);
+ }
+}
+
static void close_filters(struct slot_info *s)
{
int i;
return;
PARA_INFO_LOG("opening %s filters\n", audio_formats[s->format]);
assert(s->fns == NULL);
- s->fns = para_calloc(nf * sizeof(struct filter_node));
+ s->fns = zalloc(nf * sizeof(struct filter_node));
parent = s->receiver_node->btrn;
for (i = 0; i < nf; i++) {
char buf[20];
struct btr_node *parent = s->fns[a->num_filters - 1].btrn;
assert(s->wns == NULL);
- s->wns = para_calloc(PARA_MAX(1U, a->num_writers)
+ s->wns = zalloc(PARA_MAX(1U, a->num_writers)
* sizeof(struct writer_node));
for (i = 0; i < a->num_writers; i++) {
wn = s->wns + i;
if (ret < 0)
return ret;
slot_num = ret;
- rn = para_calloc(sizeof(*rn));
+ rn = zalloc(sizeof(*rn));
rn->receiver = r;
rn->lpr = a->receiver_lpr;
rn->btrn = btr_new_node(&(struct btr_node_description)
if (count > 5) {
int s = tv_diff(&diff, &stat_task->sa_time_diff, &tmp);
if (tv_diff(&max_deviation, &tmp, NULL) < 0)
- PARA_WARNING_LOG("time diff jump: %lums\n",
- s * tv2ms(&tmp));
+ PARA_WARNING_LOG("time diff jump: %c%lums\n",
+ s < 0? '-' : '+', tv2ms(&tmp));
}
count++;
sa_time_diff_sign = tv_convex_combination(
return -E_MISSING_COLON;
*cmd = p + 1;
len = p - txt;
- re = malloc(len + 1);
+ re = alloc(len + 1);
strncpy(re, txt, len);
re[len] = '\0';
ret = get_matching_audio_format_nums(re);
struct lls_parse_result *flpr;
filter_num = filter_setup(cmdline, &cfg, &flpr);
- a->filter_lpr = para_realloc(a->filter_lpr,
- (nf + 1) * sizeof(flpr));
- 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_lpr = arr_realloc(a->filter_lpr, nf + 1, sizeof(flpr));
+ a->filter_conf = arr_realloc(a->filter_conf, nf + 1, sizeof(void *));
+ a->filter_nums = arr_realloc(a->filter_nums, nf + 1, sizeof(unsigned));
a->filter_nums[nf] = filter_num;
a->filter_conf[nf] = cfg;
if (a->num_writers > 0)
continue; /* already set up */
a->num_writers = 1;
- a->wids = para_malloc(sizeof(int));
- a->writer_lpr = para_malloc(sizeof(struct lls_parse_result *));
+ a->wids = alloc(sizeof(int));
+ a->writer_lpr = alloc(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_name(a->wids[0]));
case SIGINT:
case SIGTERM:
case SIGHUP:
- PARA_NOTICE_LOG("received signal %d\n", signum);
+ PARA_WARNING_LOG("terminating on signal %d\n", signum);
task_notify_all(s, E_AUDIOD_SIGNAL);
return -E_AUDIOD_SIGNAL;
}
return ret;
ret = handle_connect(ct->fd, &s->rfds);
if (ret < 0) {
- PARA_ERROR_LOG("%s\n", para_strerror(-ret));
+ PARA_NOTICE_LOG("%s\n", para_strerror(-ret));
if (ret == -E_AUDIOD_TERM) {
task_notify_all(s, -ret);
return ret;
struct slot_info *sl;
close_unused_slots();
- if (audiod_status != AUDIOD_ON ||
- !(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING))
+ if (audiod_status != AUDIOD_ON)
+ return notify_writers(E_NOT_PLAYING);
+ if (!(stat_task->vss_status & VSS_STATUS_FLAG_PLAYING))
return notify_receivers(E_NOT_PLAYING);
if (!must_start_decoder())
return;