- 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_nobtr(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;
-}
-
-static int alsa_open_btr(struct writer_node *wn)
-{
- struct private_alsa_write_data *pad = para_calloc(sizeof(*pad));
-
- sprintf(wn->task.status, "alsa writer");
- wn->private_data = pad;
- return 1;
-}
-static int alsa_open(struct writer_node *wn)
-{
- struct alsa_write_args_info *conf = wn->conf;
-
- if (conf->buffer_tree_given)
- return alsa_open_btr(wn);
- else
- return alsa_open_nobtr(wn);
-
-}
-
-static int alsa_write_pre_select(struct sched *s, struct writer_node *wn)
-{
- struct alsa_write_args_info *conf = wn->conf;
- struct private_alsa_write_data *pad = wn->private_data;
- struct writer_node_group *wng = wn->wng;
- struct timeval tv;
- snd_pcm_sframes_t avail, underrun;
-
- if (!pad->handle)
- return 1;
- if (conf->buffer_tree_given) {
- size_t sz = btr_get_input_queue_size(wn->btrn);
- if (sz < pad->bytes_per_frame)
- return 1;
- } else {
- if (*wng->loaded - wn->written < pad->bytes_per_frame)
- return 1;
+ err = snd_output_buffer_open(&log);
+ if (err == 0) {
+ char *buf;
+ PARA_INFO_LOG("dumping alsa configuration\n");
+ snd_pcm_dump(pad->handle, log);
+ snd_output_buffer_string(log, &buf);
+ for (;;) {
+ char *p = strchr(buf, '\n');
+ if (!p) /* omit last output line, it's empty */
+ break;
+ *p = '\0';
+ PARA_INFO_LOG("%s\n", buf);
+ buf = p + 1;
+ }
+ snd_output_close(log);