From: Andre Date: Wed, 24 May 2006 01:45:28 +0000 (+0200) Subject: rename struct filter_chain_info to filter_chain X-Git-Tag: v0.2.14~101^2~24 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=607ac63646d7c31aa1792dcf1d9a60e498654376 rename struct filter_chain_info to filter_chain --- diff --git a/aacdec.c b/aacdec.c index c36f6877..e07c146e 100644 --- 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; - 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; @@ -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 (len < 1000 && !*fci->eof) + if (len < 1000 && !*fc->eof) 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; } - fci->samplerate = rate; - fci->channels = channels; + fc->samplerate = rate; + fc->channels = channels; PARA_INFO_LOG("rate: %u, channels: %d\n", - fci->samplerate, fci->channels); + fc->samplerate, fc->channels); padd->initialized = 1; } if (padd->decoder_length > 0) { diff --git a/filter.c b/filter.c index a035c6e6..c84b4823 100644 --- a/filter.c +++ b/filter.c @@ -29,8 +29,8 @@ INIT_FILTER_ERRLISTS; #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; @@ -55,11 +55,11 @@ static int init_active_filter_list(void) 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]); @@ -69,13 +69,13 @@ static int init_active_filter_list(void) 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); - 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; } @@ -84,11 +84,11 @@ static void open_filters(void) { 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); - 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(); - 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) { @@ -150,7 +150,7 @@ again: eof = 1; *il += ret; } - ret = filter_io(fci); + ret = filter_io(fc); if (ret < 0) goto out; converted = ret; @@ -171,6 +171,6 @@ again: out: if (ret < 0) PARA_EMERG_LOG("%s\n", PARA_STRERROR(-ret)); - close_filters(fci); + close_filters(fc); return ret; } diff --git a/filter.h b/filter.h index 2fb9ad17..a6b39071 100644 --- a/filter.h +++ b/filter.h @@ -22,71 +22,71 @@ * 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 */ - 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); diff --git a/filter_chain.c b/filter_chain.c index 4c1f94bc..d755e434 100644 --- a/filter_chain.c +++ b/filter_chain.c @@ -95,10 +95,10 @@ static void call_callbacks(struct filter_node *fn, char *inbuf, size_t inlen, /** * 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 - * 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 @@ -109,28 +109,30 @@ static void call_callbacks(struct filter_node *fn, char *inbuf, size_t inlen, * * \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: - ib = fci->inbuf; - loaded = fci->in_loaded; + ib = fc->inbuf; + loaded = fc->in_loaded; 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; - 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) { - if (!fci->error) - fci->error = -ret; + if (!fc->error) + fc->error = -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) { @@ -152,26 +154,26 @@ again: /** * 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 */ -void close_filters(struct filter_chain_info *fci) +void close_filters(struct filter_chain *fc) { struct filter_node *fn, *tmp; - if (!fci) + if (!fc) 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); - 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); diff --git a/mp3dec.c b/mp3dec.c index af9de548..c02432ee 100644 --- a/mp3dec.c +++ b/mp3dec.c @@ -67,8 +67,8 @@ next_frame: 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) @@ -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, - fn->fci->samplerate, copy - off); + fn->fc->samplerate, copy - off); return copy - off; } return copy; diff --git a/oggdec.c b/oggdec.c index 3554eb1b..637fa965 100644 --- 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; - 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); @@ -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 (len fci->eof && !fn->fci->error) { + if (len fc->eof && !fn->fc->error) { 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; - 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, @@ -167,7 +167,7 @@ again: 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; } diff --git a/wav.c b/wav.c index e229317d..b955695f 100644 --- 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) { - 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;