- PARA_ERROR_LOG("%s\n", "failed to set nonblock mode");
- return period_size * pad->bytes_per_frame;
+ PARA_ERROR_LOG("failed to set nonblock mode\n");
+ pad->buffer_frames = 1000 * pad->buffer_time / pad->samplerate;
+ PARA_INFO_LOG("max buffered frames: %d\n", pad->buffer_frames);
+ return 1;
+}
+
+/* Open an instance of the alsa writer. */
+static int alsa_open(struct writer_node *wn)
+{
+ struct alsa_write_args_info *conf = wn->conf;
+ struct writer_node_group *wng = wn->wng;
+ struct private_alsa_write_data *pad = para_calloc(sizeof(*pad));
+
+ wn->private_data = pad;
+ if (!conf->samplerate_given && wng->samplerate)
+ pad->samplerate = *wng->samplerate;
+ else
+ pad->samplerate = conf->samplerate_arg;
+ if (!conf->channels_given && wng->channels)
+ pad->channels = *wng->channels;
+ else
+ pad->channels = conf->channels_arg;
+ PARA_INFO_LOG("%d channel(s), %dHz\n", pad->channels, pad->samplerate);
+ return 1;