rename struct filter_chain_info to filter_chain
authorAndre <maan@p133.(none)>
Wed, 24 May 2006 01:45:28 +0000 (03:45 +0200)
committerAndre <maan@p133.(none)>
Wed, 24 May 2006 01:45:28 +0000 (03:45 +0200)
aacdec.c
filter.c
filter.h
filter_chain.c
mp3dec.c
oggdec.c
wav.c

index c36f6877c901c2a6e9bf9fdc41284147c627045d..e07c146e89289585f7eb20fbdb9a2ccf79fc0c3f 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -52,7 +52,7 @@ struct private_aacdec_data {
 static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
 {
        struct private_aacdec_data *padd = fn->private_data;
 static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
 {
        struct private_aacdec_data *padd = fn->private_data;
-       struct filter_chain_info *fci = fn->fci;
+       struct filter_chain *fc = fn->fc;
        int i, ret;
        unsigned char *p, *outbuffer;
        unsigned char *inbuf = (unsigned char*)input_buffer;
        int i, ret;
        unsigned char *p, *outbuffer;
        unsigned char *inbuf = (unsigned char*)input_buffer;
@@ -60,7 +60,7 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
 
        if (fn->loaded > fn->bufsize * 4 / 5)
                return 0;
 
        if (fn->loaded > fn->bufsize * 4 / 5)
                return 0;
-       if (len < 1000 && !*fci->eof)
+       if (len < 1000 && !*fc->eof)
                return 0;
 
        if (!padd->initialized) {
                return 0;
 
        if (!padd->initialized) {
@@ -86,10 +86,10 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                                        &channels) < 0)
                                goto out;
                }
                                        &channels) < 0)
                                goto out;
                }
-               fci->samplerate = rate;
-               fci->channels = channels;
+               fc->samplerate = rate;
+               fc->channels = channels;
                PARA_INFO_LOG("rate: %u, channels: %d\n",
                PARA_INFO_LOG("rate: %u, channels: %d\n",
-                       fci->samplerate, fci->channels);
+                       fc->samplerate, fc->channels);
                padd->initialized = 1;
        }
        if (padd->decoder_length > 0) {
                padd->initialized = 1;
        }
        if (padd->decoder_length > 0) {
index a035c6e652cdfebed3d59708d763768c5c5e3bc2..c84b4823c745474f5ba92d59053f824cf946ca06 100644 (file)
--- a/filter.c
+++ b/filter.c
@@ -29,8 +29,8 @@ INIT_FILTER_ERRLISTS;
 
 #define INBUF_SIZE 32 * 1024
 
 
 #define INBUF_SIZE 32 * 1024
 
-static struct filter_chain_info filter_chain_info_struct;
-static struct filter_chain_info *fci = &filter_chain_info_struct;
+static struct filter_chain filter_chain_struct;
+static struct filter_chain *fc = &filter_chain_struct;
 
 struct gengetopt_args_info conf;
 
 
 struct gengetopt_args_info conf;
 
@@ -55,11 +55,11 @@ static int init_active_filter_list(void)
        int i, filter_num;
        struct filter_node *fn;
 
        int i, filter_num;
        struct filter_node *fn;
 
-       INIT_LIST_HEAD(&fci->filters);
+       INIT_LIST_HEAD(&fc->filters);
 
 
-       fci->inbuf = inbuf;
-       fci->in_loaded = &loaded;
-       fci->eof = &eof;
+       fc->inbuf = inbuf;
+       fc->in_loaded = &loaded;
+       fc->eof = &eof;
 
        for (i = 0; i < conf.filter_given; i++) {
                char *fa = para_strdup(conf.filter_arg[i]);
 
        for (i = 0; i < conf.filter_given; i++) {
                char *fa = para_strdup(conf.filter_arg[i]);
@@ -69,13 +69,13 @@ static int init_active_filter_list(void)
                        free(fn);
                        return filter_num;
                }
                        free(fn);
                        return filter_num;
                }
-               fn->fci = fci;
+               fn->fc = fc;
                INIT_LIST_HEAD(&fn->callbacks);
                fn->filter = &filters[filter_num];
                PARA_DEBUG_LOG("adding %s to filter chain\n", fn->filter->name);
                INIT_LIST_HEAD(&fn->callbacks);
                fn->filter = &filters[filter_num];
                PARA_DEBUG_LOG("adding %s to filter chain\n", fn->filter->name);
-               list_add_tail(&fn->node, &fci->filters);
+               list_add_tail(&fn->node, &fc->filters);
        }
        }
-       if (list_empty(&fci->filters))
+       if (list_empty(&fc->filters))
                return -E_NO_FILTERS;
        return 1;
 }
                return -E_NO_FILTERS;
        return 1;
 }
@@ -84,11 +84,11 @@ static void open_filters(void)
 {
        struct filter_node *fn;
 
 {
        struct filter_node *fn;
 
-       list_for_each_entry(fn, &fci->filters, node) {
+       list_for_each_entry(fn, &fc->filters, node) {
                fn->filter->open(fn);
                PARA_INFO_LOG("opened %s filter\n", fn->filter->name);
                fn->filter->open(fn);
                PARA_INFO_LOG("opened %s filter\n", fn->filter->name);
-               fci->outbuf = fn->buf;
-               fci->out_loaded = &fn->loaded;
+               fc->outbuf = fn->buf;
+               fc->out_loaded = &fn->loaded;
        }
 }
 
        }
 }
 
@@ -135,10 +135,10 @@ int main(int argc, char *argv[])
        if (ret < 0)
                goto out;
        open_filters();
        if (ret < 0)
                goto out;
        open_filters();
-       ib = fci->inbuf;
-       ob = fci->outbuf;
-       il = fci->in_loaded;
-       ol = fci->out_loaded;
+       ib = fc->inbuf;
+       ob = fc->outbuf;
+       il = fc->in_loaded;
+       ol = fc->out_loaded;
        PARA_DEBUG_LOG("ib %p in, ob: %p\n", ib, ob);
 again:
        if (*il < INBUF_SIZE && !eof) {
        PARA_DEBUG_LOG("ib %p in, ob: %p\n", ib, ob);
 again:
        if (*il < INBUF_SIZE && !eof) {
@@ -150,7 +150,7 @@ again:
                        eof = 1;
                *il += ret;
        }
                        eof = 1;
                *il += ret;
        }
-       ret = filter_io(fci);
+       ret = filter_io(fc);
        if (ret < 0)
                goto out;
        converted = ret;
        if (ret < 0)
                goto out;
        converted = ret;
@@ -171,6 +171,6 @@ again:
 out:
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
 out:
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret));
-       close_filters(fci);
+       close_filters(fc);
        return ret;
 }
        return ret;
 }
index 2fb9ad175fbeecaf816c4707e79d2fe96091461d..a6b390719e72d0d9b1852915b4747f9cca4cfb5a 100644 (file)
--- a/filter.h
+++ b/filter.h
  * describes one running instance of a chain of filters
  *
  */
  * describes one running instance of a chain of filters
  *
  */
-struct filter_chain_info {
-/**
- *
- *
- * the number of channels of the current stream
- *
- * Set by the decoding filter
- */
-       unsigned int channels;
-/**
- *
- *
- * current samplerate in Hz
- *
- * Set by the decoding filter
- */
-       unsigned int samplerate;
-/**
- *
- *
- * the list containing all filter nodes in this filter chain
- */
-       struct list_head filters;
-/**
- *
- *
- * the input buffer of the filter chain
- *
- * This is set to point to the output buffer of the receiving application (the
- * buffer used to read from stdin for para_filter; the output buffer of the
- * current receiver for para_audiod)
- */
-       char *inbuf;
-/**
- *
- *
- * the output buffer of the filter chain
- *
- * Points to the output buffer of the last filter in the filter chain
-**/
-       char *outbuf;
-/**
- *
- *
- * pointer to variable containing the number of bytes loaded in the input buffer
- */
-       size_t *in_loaded;
-/**
- *
- *
- * pointer to variable containing the number of bytes loaded in the output buffer
- */
-       size_t *out_loaded;
-/**
- *
- *
- * non-zero if end of file was encountered
- */
-       int *eof;
-/**
- *
- *
- * non-zero if an error occured
- */
-       int error;
+struct filter_chain {
+       /**
       *
       *
       * the number of channels of the current stream
       *
       * Set by the decoding filter
       */
+               unsigned int channels;
+       /**
       *
       *
       * current samplerate in Hz
       *
       * Set by the decoding filter
       */
+               unsigned int samplerate;
+       /**
       *
       *
       * the list containing all filter nodes in this filter chain
       */
+               struct list_head filters;
+       /**
       *
       *
       * the input buffer of the filter chain
       *
       * This is set to point to the output buffer of the receiving application (the
       * buffer used to read from stdin for para_filter; the output buffer of the
       * current receiver for para_audiod)
       */
+               char *inbuf;
+       /**
       *
       *
       * the output buffer of the filter chain
       *
       * Points to the output buffer of the last filter in the filter chain
+       **/
+               char *outbuf;
+       /**
       *
       *
       * pointer to variable containing the number of bytes loaded in the input buffer
       */
+               size_t *in_loaded;
+       /**
       *
       *
       * pointer to variable containing the number of bytes loaded in the output buffer
       */
+               size_t *out_loaded;
+       /**
       *
       *
       * non-zero if end of file was encountered
       */
+               int *eof;
+       /**
       *
       *
       * non-zero if an error occured
       */
+               int error;
 };
 
 /**
 };
 
 /**
@@ -104,7 +104,7 @@ struct filter_node {
  *
  * the filter chain this filter node belongs to
  */
  *
  * the filter chain this filter node belongs to
  */
-       struct filter_chain_info *fci;
+       struct filter_chain *fc;
 /**
  *
  *
 /**
  *
  *
@@ -212,8 +212,8 @@ struct filter_callback {
 };
 
 
 };
 
 
-void close_filters(struct filter_chain_info *fci);
-int filter_io(struct filter_chain_info *fci);
+void close_filters(struct filter_chain *fc);
+int filter_io(struct filter_chain *fc);
 void filter_init(struct filter *all_filters);
 int check_filter_arg(char *filter_arg, void **conf);
 int del_filter_callback(struct filter_callback *fcb);
 void filter_init(struct filter *all_filters);
 int check_filter_arg(char *filter_arg, void **conf);
 int del_filter_callback(struct filter_callback *fcb);
index 4c1f94bcb890526548e1702209625add432232e1..d755e43483c385a419d84d625076438a4ed9211b 100644 (file)
@@ -95,10 +95,10 @@ static void call_callbacks(struct filter_node *fn, char *inbuf, size_t inlen,
 /**
  * call the convert function of each filter
  *
 /**
  * call the convert function of each filter
  *
- * \param fci the filter chain containing the list of filter nodes.
+ * \param fc the filter chain containing the list of filter nodes.
  *
  * This is the core function of the filter subsystem. It loops over the list of
  *
  * This is the core function of the filter subsystem. It loops over the list of
- * filter nodes determined by \a fci and calls the filter's convert function if
+ * filter nodes determined by \a fc and calls the filter's convert function if
  * there is input available for the filter node in question. If the convert
  * function consumed some or all of its input data, all registered input
  * callbacks are called.  Similarly, if a convert function produced output, all
  * there is input available for the filter node in question. If the convert
  * function consumed some or all of its input data, all registered input
  * callbacks are called.  Similarly, if a convert function produced output, all
@@ -109,28 +109,30 @@ static void call_callbacks(struct filter_node *fn, char *inbuf, size_t inlen,
  *
  * \sa filter_node, filter#convert, filter_callback
  */
  *
  * \sa filter_node, filter#convert, filter_callback
  */
-int filter_io(struct filter_chain_info *fci)
+int filter_io(struct filter_chain *fc)
 {
        struct filter_node *fn;
        char *ib;
        size_t *loaded;
        int conv, conv_total = 0;
 again:
 {
        struct filter_node *fn;
        char *ib;
        size_t *loaded;
        int conv, conv_total = 0;
 again:
-       ib = fci->inbuf;
-       loaded = fci->in_loaded;
+       ib = fc->inbuf;
+       loaded = fc->in_loaded;
        conv = 0;
        conv = 0;
-       list_for_each_entry(fn, &fci->filters, node) {
+       list_for_each_entry(fn, &fc->filters, node) {
                int ret;
                if (*loaded && fn->loaded < fn->bufsize) {
                        size_t old_fn_loaded = fn->loaded;
                int ret;
                if (*loaded && fn->loaded < fn->bufsize) {
                        size_t old_fn_loaded = fn->loaded;
-                       PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n", fci, *loaded, fn->filter->name);
+                       PARA_DEBUG_LOG("fc %p loaded: %zd, calling %s convert\n",
+                               fc, *loaded, fn->filter->name);
                        ret = fn->filter->convert(ib, *loaded, fn);
                        if (ret < 0) {
                        ret = fn->filter->convert(ib, *loaded, fn);
                        if (ret < 0) {
-                               if (!fci->error)
-                                       fci->error = -ret;
+                               if (!fc->error)
+                                       fc->error = -ret;
                                return ret;
                        }
                                return ret;
                        }
-                       call_callbacks(fn, ib, ret, fn->buf + old_fn_loaded, fn->loaded - old_fn_loaded);
+                       call_callbacks(fn, ib, ret, fn->buf + old_fn_loaded,
+                               fn->loaded - old_fn_loaded);
                        *loaded -= ret;
                        conv += ret;
                        if (*loaded && ret) {
                        *loaded -= ret;
                        conv += ret;
                        if (*loaded && ret) {
@@ -152,26 +154,26 @@ again:
 /**
  * close all filter nodes and its callbacks
  *
 /**
  * close all filter nodes and its callbacks
  *
- * \param fci the filter chain to close
+ * \param fc the filter chain to close
  *
  *
- * For each filter node determined by \a fci, call the close function of each
+ * For each filter node determined by \a fc, call the close function of each
  * registered filter callback as well as the close function of the
  * corresponding filter.  Free all resources and destroy all callback lists and
  * the filter node list.
  *
  * \sa filter::close, filter_callback::close
  */
  * registered filter callback as well as the close function of the
  * corresponding filter.  Free all resources and destroy all callback lists and
  * the filter node list.
  *
  * \sa filter::close, filter_callback::close
  */
-void close_filters(struct filter_chain_info *fci)
+void close_filters(struct filter_chain *fc)
 {
        struct filter_node *fn, *tmp;
 
 {
        struct filter_node *fn, *tmp;
 
-       if (!fci)
+       if (!fc)
                return;
                return;
-       PARA_DEBUG_LOG("closing filter chain %p\n", fci);
-       list_for_each_entry_safe(fn, tmp, &fci->filters, node) {
-               PARA_NOTICE_LOG("closing %s filter callbacks (fci %p, fn %p)\n", fn->filter->name, fci, fn);
+       PARA_DEBUG_LOG("closing filter chain %p\n", fc);
+       list_for_each_entry_safe(fn, tmp, &fc->filters, node) {
+               PARA_NOTICE_LOG("closing %s filter callbacks (fc %p, fn %p)\n", fn->filter->name, fc, fn);
                close_callbacks(fn);
                close_callbacks(fn);
-               PARA_NOTICE_LOG("closing %s filter (fci %p, fn %p)\n", fn->filter->name, fci, fn);
+               PARA_NOTICE_LOG("closing %s filter (fc %p, fn %p)\n", fn->filter->name, fc, fn);
                fn->filter->close(fn);
                list_del(&fn->node);
                free(fn);
                fn->filter->close(fn);
                list_del(&fn->node);
                free(fn);
index af9de5484a0f9f150a153500fef42fd6a2920f9e..c02432eee8fa82ed8a1ab633afebac47fccb89df 100644 (file)
--- a/mp3dec.c
+++ b/mp3dec.c
@@ -67,8 +67,8 @@ next_frame:
                        goto out;
                return FRAME_HEADER_SIZE;
        }
                        goto out;
                return FRAME_HEADER_SIZE;
        }
-       fn->fci->samplerate = pmd->frame.header.samplerate;
-       fn->fci->channels = MAD_NCHANNELS(&pmd->frame.header);
+       fn->fc->samplerate = pmd->frame.header.samplerate;
+       fn->fc->channels = MAD_NCHANNELS(&pmd->frame.header);
        ret = mad_frame_decode(&pmd->frame, &pmd->stream);
        if (ret) {
                if (MAD_RECOVERABLE(pmd->stream.error) || pmd->stream.error == MAD_ERROR_BUFLEN)
        ret = mad_frame_decode(&pmd->frame, &pmd->stream);
        if (ret) {
                if (MAD_RECOVERABLE(pmd->stream.error) || pmd->stream.error == MAD_ERROR_BUFLEN)
@@ -99,7 +99,7 @@ out:
        if (pmd->stream.next_frame) { /* we still have some data */
                size_t off = pmd->stream.bufend - pmd->stream.next_frame;
                PARA_DEBUG_LOG("converted %zd, rate: %u, returning %zd\n", len - off,
        if (pmd->stream.next_frame) { /* we still have some data */
                size_t off = pmd->stream.bufend - pmd->stream.next_frame;
                PARA_DEBUG_LOG("converted %zd, rate: %u, returning %zd\n", len - off,
-                       fn->fci->samplerate, copy - off);
+                       fn->fc->samplerate, copy - off);
                return copy - off;
        }
        return copy;
                return copy - off;
        }
        return copy;
index 3554eb1b8ff3c6135d47e21c88e5abfd480b0dc5..637fa965b3d49d3dd35966791f2b882903b570ac 100644 (file)
--- a/oggdec.c
+++ b/oggdec.c
@@ -53,7 +53,7 @@ static size_t cb_read(void *buf, size_t size, size_t nmemb, void *datasource)
        size_t ret, have = pod->inbuf_len - pod->converted;
        char *p = pod->inbuf + pod->converted;
 
        size_t ret, have = pod->inbuf_len - pod->converted;
        char *p = pod->inbuf + pod->converted;
 
-       if (*fn->fci->eof)
+       if (*fn->fc->eof)
                return 0;
 //     PARA_DEBUG_LOG("pod = %p\n", pod);
 //     PARA_DEBUG_LOG("vorbis requests %d bytes, have %d\n", size * nmemb, have);
                return 0;
 //     PARA_DEBUG_LOG("pod = %p\n", pod);
 //     PARA_DEBUG_LOG("vorbis requests %d bytes, have %d\n", size * nmemb, have);
@@ -133,7 +133,7 @@ static ssize_t ogg_convert(char *inbuffer, size_t len, struct filter_node *fn)
 
        if (!pod->vf) {
                int ib = 1024 * conf->initial_buffer_arg; /* initial buffer */
 
        if (!pod->vf) {
                int ib = 1024 * conf->initial_buffer_arg; /* initial buffer */
-               if (len <ib && !*fn->fci->eof && !fn->fci->error) {
+               if (len <ib && !*fn->fc->eof && !fn->fc->error) {
                        PARA_INFO_LOG("initial input buffer %zd/%d, waiting for more data\n",
                                len, ib);
                        return 0;
                        PARA_INFO_LOG("initial input buffer %zd/%d, waiting for more data\n",
                                len, ib);
                        return 0;
@@ -154,9 +154,9 @@ static ssize_t ogg_convert(char *inbuffer, size_t len, struct filter_node *fn)
                        return -E_OGGDEC_BADHEADER;
                if (ret < 0)
                        return -E_OGGDEC_FAULT;
                        return -E_OGGDEC_BADHEADER;
                if (ret < 0)
                        return -E_OGGDEC_FAULT;
-               fn->fci->channels = ov_info(pod->vf, 0)->channels;
-               fn->fci->samplerate = ov_info(pod->vf, 0)->rate;
-               PARA_NOTICE_LOG("%d channels, %d Hz\n", fn->fci->channels, fn->fci->samplerate);
+               fn->fc->channels = ov_info(pod->vf, 0)->channels;
+               fn->fc->samplerate = ov_info(pod->vf, 0)->rate;
+               PARA_NOTICE_LOG("%d channels, %d Hz\n", fn->fc->channels, fn->fc->samplerate);
        }
 again:
        ret = ov_read(pod->vf, fn->buf + fn->loaded, fn->bufsize - fn->loaded,
        }
 again:
        ret = ov_read(pod->vf, fn->buf + fn->loaded, fn->bufsize - fn->loaded,
@@ -167,7 +167,7 @@ again:
        if (ret < 0)
                return -E_OGGDEC_BADLINK;
        fn->loaded += ret;
        if (ret < 0)
                return -E_OGGDEC_BADLINK;
        fn->loaded += ret;
-       if (!*fn->fci->eof && !fn->fci->error && fn->loaded < fn->bufsize)
+       if (!*fn->fc->eof && !fn->fc->error && fn->loaded < fn->bufsize)
                goto again;
        return pod->converted;
 }
                goto again;
        return pod->converted;
 }
diff --git a/wav.c b/wav.c
index e229317dd6309380263673f359de4d4d8d50e59b..b955695f70bce73aea60df566722658089f3661a 100644 (file)
--- a/wav.c
+++ b/wav.c
@@ -66,7 +66,7 @@ static ssize_t wav_convert(char *inbuf, size_t len, struct filter_node *fn)
        int *bof = fn->private_data;
 
        if (*bof) {
        int *bof = fn->private_data;
 
        if (*bof) {
-               make_wav_header(fn->fci->channels, fn->fci->samplerate, fn);
+               make_wav_header(fn->fc->channels, fn->fc->samplerate, fn);
                fn->loaded = WAV_HEADER_LEN;
                *bof = 0;
 //             return 0;
                fn->loaded = WAV_HEADER_LEN;
                *bof = 0;
 //             return 0;