]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Use only a single buffer pointer for filters/receivers.
authorAndre Noll <maan@systemlinux.org>
Sat, 2 May 2009 09:46:46 +0000 (11:46 +0200)
committerAndre Noll <maan@systemlinux.org>
Sat, 2 May 2009 09:46:46 +0000 (11:46 +0200)
This allows filters to change the output buffer size on the fly.

13 files changed:
alsa_write.c
audiod.c
client.c
file_write.c
filter.c
filter.h
filter_common.c
recv.c
stdout.c
stdout.h
write.c
write.h
write_common.c

index f63b7a5eb43261183c3ee0e0920c5d23c20afa9e..dd91cd84f1d5e648a2b1a4f0fa3a7859a7f51093 100644 (file)
@@ -164,7 +164,7 @@ static int alsa_write_post_select(__a_unused struct sched *s,
        struct private_alsa_write_data *pad = wn->private_data;
        struct writer_node_group *wng = wn->wng;
        size_t frames, bytes = *wng->loaded - wn->written;
        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;
 
        struct timeval tv;
        snd_pcm_sframes_t ret;
 
index 6d7cce5efdf109f251dfa112fb5ed6593d2c0d02..778196542d63dc855a6c8ccd6228362b434b698f 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -382,7 +382,7 @@ static void open_filters(int slot_num)
        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));
        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;
        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;
@@ -402,7 +402,7 @@ static void open_filters(int slot_num)
                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);
                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);
                s->fc->out_loaded = &fn->loaded;
        }
        register_task(&s->fc->task);
@@ -420,7 +420,7 @@ static void open_writers(int slot_num)
        else
                s->wng = wng_new(a->num_writers);
        if (s->fc) {
        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->wng->loaded = s->fc->out_loaded;
                s->wng->input_error = &s->fc->task.error;
                s->wng->channels = &s->fc->channels;
@@ -428,7 +428,7 @@ static void open_writers(int slot_num)
                s->fc->output_error = &s->wng->task.error;
                PARA_INFO_LOG("samplerate: %d\n", *s->wng->samplerate);
        } else {
                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;
        }
                s->wng->loaded = &s->receiver_node->loaded;
                s->wng->input_error = &s->receiver_node->task.error;
        }
index 2123421e71b099bb632b99c563aaafd5b0c70aaf..003c1e609f8ce1e606fecd9ad3b7092e76987936 100644 (file)
--- a/client.c
+++ b/client.c
@@ -40,7 +40,7 @@ static void supervisor_post_select(__a_unused struct sched *s, struct task *t)
        }
        if (ct->status == CL_RECEIVING) {
                stdout_set_defaults(&sot);
        }
        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);
                sot.loaded = &ct->loaded;
                sot.input_error = &ct->task.error;
                register_task(&sot.task);
index 0950e303da07daab08429f425fe8a6548c70eb3f..92777d7ddc4af81b173b5017559af6ea1a1af407 100644 (file)
@@ -79,7 +79,7 @@ static int file_write_post_select(struct sched *s, struct writer_node *wn)
        if (!FD_ISSET(pfwd->fd, &s->wfds))
                return 1;
 //     PARA_INFO_LOG("writing %zd\n", *wng->loaded);
        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;
                *wng->loaded - wn->written);
        if (ret < 0)
                return -E_FW_WRITE;
index 9311a20a6f0ef035f9491c2d3856006a8cd2f3f5..b8a7c5c19231d415f0e2488a6275f619901e2d65 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -56,7 +56,7 @@ static void open_filters(void)
                struct filter *f = filters + fn->filter_num;
                f->open(fn);
                PARA_INFO_LOG("opened %s filter\n", f->name);
                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;
        }
 }
                fc->out_loaded = &fn->loaded;
        }
 }
@@ -70,7 +70,7 @@ static int init_filter_chain(void)
                return -E_NO_FILTERS;
        fc->num_filters = conf.filter_given;
        fc->filter_nodes = para_malloc(fc->num_filters * sizeof(struct filter_node));
                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;
        fc->in_loaded = &sit->loaded;
        fc->input_error = &sit->task.error;
        fc->task.error = 0;
@@ -170,7 +170,7 @@ int main(int argc, char *argv[])
        sit->output_error = &fc->task.error;
 
        stdout_set_defaults(sot);
        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;
 
        sot->loaded = fc->out_loaded;
        sot->input_error = &fc->task.error;
 
index da4729056a7cf8cd5c08800dc3b2ee617416d234..0bb51f5ae1e45bcd3396a91bfbba367cbafdec9c 100644 (file)
--- a/filter.h
+++ b/filter.h
@@ -59,13 +59,13 @@ struct filter_chain {
         * buffer used to read from stdin for para_filter; the output buffer of the
         * current receiver for para_audiod).
         */
         * 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.
         */
        /**
         * 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. */
        /** Contains the number of bytes loaded in the input buffer. */
        size_t *in_loaded;
        /** Contains the number of bytes loaded in the output buffer. */
index b601c6886d2767d090fddd33becf397f3730fe2e..ebda1ee74ad265275017d9ebe6eaf137de317fcb 100644 (file)
@@ -118,7 +118,7 @@ void filter_pre_select(__a_unused struct sched *s, struct task *t)
                return;
        }
 again:
                return;
        }
 again:
-       ib = fc->inbuf;
+       ib = *fc->inbufp;
        loaded = fc->in_loaded;
        conv = 0;
        FOR_EACH_FILTER_NODE(fn, fc, i) {
        loaded = fc->in_loaded;
        conv = 0;
        FOR_EACH_FILTER_NODE(fn, fc, i) {
diff --git a/recv.c b/recv.c
index 4f595e39aae21cbef207fc1418c5973d0fbd68a1..5de9c6be1779855b00a4698b6638aa4d67072305 100644 (file)
--- a/recv.c
+++ b/recv.c
@@ -95,7 +95,7 @@ int main(int argc, char *argv[])
        r_opened = 1;
 
        stdout_set_defaults(&sot);
        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);
        sot.loaded = &rn.loaded;
        sot.input_error = &rn.task.error;
        register_task(&sot.task);
index ce0d22093486281f4fd489c2fcb07d0bb25ef01c..e178fe0e180e9e687c2f3c92c65bbfdb26d7d9bb 100644 (file)
--- a/stdout.c
+++ b/stdout.c
@@ -68,14 +68,14 @@ static void stdout_post_select(struct sched *s, struct task *t)
        }
        if (!FD_ISSET(STDOUT_FILENO, &s->wfds))
                return;
        }
        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)
        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);
 }
 
 /**
 }
 
 /**
index 4149dad39155a1ed569bbd11a4d51f6bfa5337df..cca12e5f61e2538d99c766f350ee4ef002bce801 100644 (file)
--- a/stdout.h
+++ b/stdout.h
@@ -10,8 +10,8 @@
  * The task structure used for writing to stdout.
  */
 struct stdout_task {
  * 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. */
        /** Number of bytes loaded in \a buf. */
        size_t *loaded;
        /** Pointer to the error variable of the feeding task. */
diff --git a/write.c b/write.c
index c5a265652ec68c3b92e87f9ed93bbea9fcbc8364..cc1f716f8a962de165f93d0f090d21e591a43b11 100644 (file)
--- a/write.c
+++ b/write.c
@@ -214,7 +214,7 @@ int main(int argc, char *argv[])
        sit.bufsize = conf.bufsize_arg * 1024;
        sit.buf = para_malloc(sit.bufsize);
 
        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;
 
        wng->loaded = &sit.loaded;
        wng->input_error = &sit.task.error;
 
diff --git a/write.h b/write.h
index 71938a9ca5d7d22957b099047d96d2f7e8dee95f..365c237bf2b41e92e7ae14129d460d95396576ca 100644 (file)
--- a/write.h
+++ b/write.h
@@ -96,7 +96,7 @@ struct writer_node_group {
        /** Non-zero if an error or end of file was encountered by the feeding task. */
        int *input_error;
        /** Current output buffer. */
        /** 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. */
        /** Number of bytes loaded in the output buffer. */
        size_t *loaded;
        /** Number of audio channels of the current stream. */
index 4e81f62d68df57b04617a9e441f244c41cc3ed56..dcf7bb166ade3f9efa4d04afd4fb55e67e9c2d8e 100644 (file)
@@ -61,7 +61,7 @@ static void wng_post_select(struct sched *s, struct task *t)
        }
        if (*g->loaded && min_written) {
 //             PARA_INFO_LOG("moving %zd bytes\n", *g->loaded);
        }
        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);
        }
 }
 
        }
 }