PARA_INFO_LOG("dumping alsa configuration\n");
snd_pcm_dump(pad->handle, output_log);
PARA_INFO_LOG("dumping alsa configuration\n");
snd_pcm_dump(pad->handle, output_log);
- snd_output_buffer_string(output_log, &buf);
- for (;;) {
- char *p = strchr(buf, '\n');
- if (!p) /* omit last output line, it's empty */
+ sz = snd_output_buffer_string(output_log, &buf);
+ for (p = buf; p < buf + sz;) {
+ char *q = memchr(p, '\n', buf + sz - p);
+ if (!q)
btr_merge(btrn, wn->min_iqs);
bytes = btr_next_buffer(btrn, &data);
if (ret < 0 || bytes < wn->min_iqs) { /* eof */
btr_merge(btrn, wn->min_iqs);
bytes = btr_next_buffer(btrn, &data);
if (ret < 0 || bytes < wn->min_iqs) { /* eof */
PARA_DEBUG_LOG("waiting for device to drain\n");
tv_add(now, &(struct timeval)EMBRACE(0, 200 * 1000),
&pad->drain_barrier);
PARA_DEBUG_LOG("waiting for device to drain\n");
tv_add(now, &(struct timeval)EMBRACE(0, 200 * 1000),
&pad->drain_barrier);
pad = para_calloc(sizeof(*pad));
get_btr_sample_rate(btrn, &val);
pad->sample_rate = val;
pad = para_calloc(sizeof(*pad));
get_btr_sample_rate(btrn, &val);
pad->sample_rate = val;
frames = bytes / pad->bytes_per_frame;
frames = snd_pcm_writei(pad->handle, data, frames);
if (frames == 0 || frames == -EAGAIN) {
frames = bytes / pad->bytes_per_frame;
frames = snd_pcm_writei(pad->handle, data, frames);
if (frames == 0 || frames == -EAGAIN) {
if (frames == -EPIPE) {
PARA_WARNING_LOG("underrun (tried to write %zu bytes)\n", bytes);
snd_pcm_prepare(pad->handle);
if (frames == -EPIPE) {
PARA_WARNING_LOG("underrun (tried to write %zu bytes)\n", bytes);
snd_pcm_prepare(pad->handle);
}
PARA_ERROR_LOG("alsa write error: %s\n", snd_strerror(-frames));
ret = -E_ALSA;
err:
assert(ret < 0);
btr_remove_node(&wn->btrn);
}
PARA_ERROR_LOG("alsa write error: %s\n", snd_strerror(-frames));
ret = -E_ALSA;
err:
assert(ret < 0);
btr_remove_node(&wn->btrn);