Move the allocation of the private_oss_write_data struct to oss_init() and
adjust the the check whether oss has been initialized accordingly.
- if (ret < 0 || powd->fd < 0)
return sched_min_delay(s);
para_fd_set(powd->fd, &s->wfds, &s->max_fileno);
}
return sched_min_delay(s);
para_fd_set(powd->fd, &s->wfds, &s->max_fileno);
}
{
struct private_oss_write_data *powd = wn->private_data;
{
struct private_oss_write_data *powd = wn->private_data;
- if (powd->fd >= 0)
- close(powd->fd);
+ if (!powd)
+ return;
+ close(powd->fd);
int ret, format;
unsigned ch, rate;
struct oss_write_args_info *conf = wn->conf;
int ret, format;
unsigned ch, rate;
struct oss_write_args_info *conf = wn->conf;
- struct private_oss_write_data *powd = wn->private_data;
+ struct private_oss_write_data *powd = para_calloc(sizeof(*powd));
+ wn->private_data = powd;
PARA_INFO_LOG("opening %s\n", conf->device_arg);
ret = para_open(conf->device_arg, O_WRONLY, 0);
if (ret < 0)
PARA_INFO_LOG("opening %s\n", conf->device_arg);
ret = para_open(conf->device_arg, O_WRONLY, 0);
if (ret < 0)
powd->fd = ret;
ret = mark_fd_nonblocking(powd->fd);
if (ret < 0)
powd->fd = ret;
ret = mark_fd_nonblocking(powd->fd);
if (ret < 0)
return 1;
err:
close(powd->fd);
return 1;
err:
close(powd->fd);
goto out;
if (ret == 0)
return;
goto out;
if (ret == 0)
return;
int32_t rate, ch, format;
get_btr_sample_rate(btrn, &rate);
get_btr_channels(btrn, &ch);
int32_t rate, ch, format;
get_btr_sample_rate(btrn, &rate);
get_btr_channels(btrn, &ch);
-static void oss_open(struct writer_node *wn)
+static void oss_open(__a_unused struct writer_node *wn)
- struct private_oss_write_data *powd = para_calloc(sizeof(*powd));
-
- powd->fd = -1;
- wn->private_data = powd;
}
__malloc static void *oss_parse_config_or_die(const char *options)
}
__malloc static void *oss_parse_config_or_die(const char *options)