static int alsa_open_btr(struct writer_node *wn)
{
- struct alsa_write_args_info *conf = wn->conf;
struct private_alsa_write_data *pad = para_calloc(sizeof(*pad));
- int ret;
- char *buf = NULL;
sprintf(wn->task.status, "alsa writer");
wn->private_data = pad;
-
- /* defaults */
- pad->samplerate = conf->samplerate_arg;
- pad->channels = conf->channels_arg;
-
- if (!conf->samplerate_given) { /* config option trumps btr_exec */
- /* ask parent btr nodes */
- ret = btr_exec_up(wn->btrn, "samplerate", &buf);
- if (ret >= 0) {
- int32_t rate;
- ret = para_atoi32(buf, &rate);
- if (ret < 0) /* should not happen */
- goto out;
- pad->samplerate = rate;
- }
- freep(&buf);
- }
-
- if (!conf->channels_given) {
- ret = btr_exec_up(wn->btrn, "channels", &buf);
- if (ret >= 0) {
- int32_t ch;
- ret = para_atoi32(buf, &ch);
- if (ret < 0)
- goto out;
- pad->channels = ch;
- }
- freep(&buf);
- }
- PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->samplerate);
- ret = 1;
-out:
- freep(&buf);
- if (ret < 0)
- free(pad);
- return ret;
+ return 1;
}
static int alsa_open(struct writer_node *wn)
{
if (btr_no_parent(wn->btrn) && (!pad->handle || bytes < pad->bytes_per_frame))
goto err;
if (!pad->handle) {
+ char *buf;
+ struct alsa_write_args_info *conf = wn->conf;
if (bytes == 0) /* no data available */
return;
PARA_CRIT_LOG("alsa init\n");
+ /* defaults */
+ pad->samplerate = conf->samplerate_arg;
+ pad->channels = conf->channels_arg;
+ if (!conf->samplerate_given) { /* config option trumps btr_exec */
+ /* ask parent btr nodes */
+ buf = NULL;
+ ret = btr_exec_up(wn->btrn, "samplerate", &buf);
+ PARA_CRIT_LOG("ret: %d\n", ret);
+ if (ret >= 0) {
+ int32_t rate;
+
+ ret = para_atoi32(buf, &rate);
+ free(buf);
+ if (ret < 0) /* should not happen */
+ goto err;
+ pad->samplerate = rate;
+ }
+ }
+ if (!conf->channels_given) {
+ buf = NULL;
+ ret = btr_exec_up(wn->btrn, "channels", &buf);
+ if (ret >= 0) {
+ int32_t ch;
+
+ ret = para_atoi32(buf, &ch);
+ freep(&buf);
+ if (ret < 0)
+ goto err;
+ pad->channels = ch;
+ }
+ }
+ PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->samplerate);
+ ret = 1;
ret = alsa_init(pad, wn->conf);
if (ret < 0)
goto err;