This allows filters to change the output buffer size on the fly.
struct private_alsa_write_data *pad = wn->private_data;
struct writer_node_group *wng = wn->wng;
size_t frames, bytes = *wng->loaded - wn->written;
- unsigned char *data = (unsigned char*)wng->buf + wn->written;
+ unsigned char *data = (unsigned char*)*wng->bufp + wn->written;
struct timeval tv;
snd_pcm_sframes_t ret;
PARA_INFO_LOG("opening %s filters\n", audio_formats[s->format]);
s->fc = para_calloc(sizeof(struct filter_chain));
s->fc->filter_nodes = para_malloc(nf * sizeof(struct filter_node));
- s->fc->inbuf = s->receiver_node->buf;
+ s->fc->inbufp = &s->receiver_node->buf;
s->fc->in_loaded = &s->receiver_node->loaded;
s->fc->input_error = &s->receiver_node->task.error;
s->fc->task.pre_select = filter_pre_select;
f->open(fn);
PARA_NOTICE_LOG("%s filter %d/%d (%s) started in slot %d\n",
audio_formats[s->format], i, nf, f->name, slot_num);
- s->fc->outbuf = fn->buf;
+ s->fc->outbufp = &fn->buf;
s->fc->out_loaded = &fn->loaded;
}
register_task(&s->fc->task);
else
s->wng = wng_new(a->num_writers);
if (s->fc) {
- s->wng->buf = s->fc->outbuf;
+ s->wng->bufp = s->fc->outbufp;
s->wng->loaded = s->fc->out_loaded;
s->wng->input_error = &s->fc->task.error;
s->wng->channels = &s->fc->channels;
s->fc->output_error = &s->wng->task.error;
PARA_INFO_LOG("samplerate: %d\n", *s->wng->samplerate);
} else {
- s->wng->buf = s->receiver_node->buf;
+ s->wng->bufp = &s->receiver_node->buf;
s->wng->loaded = &s->receiver_node->loaded;
s->wng->input_error = &s->receiver_node->task.error;
}
}
if (ct->status == CL_RECEIVING) {
stdout_set_defaults(&sot);
- sot.buf = ct->buf;
+ sot.bufp = &ct->buf;
sot.loaded = &ct->loaded;
sot.input_error = &ct->task.error;
register_task(&sot.task);
if (!FD_ISSET(pfwd->fd, &s->wfds))
return 1;
// PARA_INFO_LOG("writing %zd\n", *wng->loaded);
- ret = write(pfwd->fd, wng->buf + wn->written,
+ ret = write(pfwd->fd, *wng->bufp + wn->written,
*wng->loaded - wn->written);
if (ret < 0)
return -E_FW_WRITE;
struct filter *f = filters + fn->filter_num;
f->open(fn);
PARA_INFO_LOG("opened %s filter\n", f->name);
- fc->outbuf = fn->buf;
+ fc->outbufp = &fn->buf;
fc->out_loaded = &fn->loaded;
}
}
return -E_NO_FILTERS;
fc->num_filters = conf.filter_given;
fc->filter_nodes = para_malloc(fc->num_filters * sizeof(struct filter_node));
- fc->inbuf = sit->buf;
+ fc->inbufp = &sit->buf;
fc->in_loaded = &sit->loaded;
fc->input_error = &sit->task.error;
fc->task.error = 0;
sit->output_error = &fc->task.error;
stdout_set_defaults(sot);
- sot->buf = fc->outbuf;
+ sot->bufp = fc->outbufp;
sot->loaded = fc->out_loaded;
sot->input_error = &fc->task.error;
* buffer used to read from stdin for para_filter; the output buffer of the
* current receiver for para_audiod).
*/
- char *inbuf;
+ char **inbufp;
/**
* The output buffer of the filter chain.
*
* Points to the output buffer of the last filter in the filter chain.
*/
- char *outbuf;
+ char **outbufp;
/** Contains the number of bytes loaded in the input buffer. */
size_t *in_loaded;
/** Contains the number of bytes loaded in the output buffer. */
return;
}
again:
- ib = fc->inbuf;
+ ib = *fc->inbufp;
loaded = fc->in_loaded;
conv = 0;
FOR_EACH_FILTER_NODE(fn, fc, i) {
r_opened = 1;
stdout_set_defaults(&sot);
- sot.buf = rn.buf;
+ sot.bufp = &rn.buf;
sot.loaded = &rn.loaded;
sot.input_error = &rn.task.error;
register_task(&sot.task);
}
if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
return;
- ret = write(STDOUT_FILENO, sot->buf, *sot->loaded);
+ ret = write(STDOUT_FILENO, *sot->bufp, *sot->loaded);
if (ret < 0) {
t->error = -ERRNO_TO_PARA_ERROR(errno);
return;
}
*sot->loaded -= ret;
if (*sot->loaded)
- memmove(sot->buf, sot->buf + ret, *sot->loaded);
+ memmove(*sot->bufp, *sot->bufp + ret, *sot->loaded);
}
/**
* The task structure used for writing to stdout.
*/
struct stdout_task {
- /** Pointer to the data buffer. */
- char *buf;
+ /** Pointer to the data buffer pointer. */
+ char **bufp;
/** Number of bytes loaded in \a buf. */
size_t *loaded;
/** Pointer to the error variable of the feeding task. */
sit.bufsize = conf.bufsize_arg * 1024;
sit.buf = para_malloc(sit.bufsize);
- wng->buf = sit.buf;
+ wng->bufp = &sit.buf;
wng->loaded = &sit.loaded;
wng->input_error = &sit.task.error;
/** Non-zero if an error or end of file was encountered by the feeding task. */
int *input_error;
/** Current output buffer. */
- char *buf;
+ char **bufp;
/** Number of bytes loaded in the output buffer. */
size_t *loaded;
/** Number of audio channels of the current stream. */
}
if (*g->loaded && min_written) {
// PARA_INFO_LOG("moving %zd bytes\n", *g->loaded);
- memmove(g->buf, g->buf + min_written, *g->loaded);
+ memmove(*g->bufp, *g->bufp + min_written, *g->loaded);
}
}