# HG changeset patch # User William Pitcock # Date 1190140761 18000 # Node ID 154f21dcd61e587881566be1ec6f6d0e60f0397b # Parent 0898b8139af84aea22496a535b65a3c30f35235b equalizer -> flow API diff -r 0898b8139af8 -r 154f21dcd61e src/audacious/iir.c --- a/src/audacious/iir.c Tue Sep 18 13:33:45 2007 -0500 +++ b/src/audacious/iir.c Tue Sep 18 13:39:21 2007 -0500 @@ -20,6 +20,8 @@ */ #include + +#include "main.h" #include "iir.h" /* Coefficients */ @@ -82,3 +84,42 @@ return rounded_value; } #endif + +static void +byteswap(size_t size, + gint16 * buf) +{ + gint16 *it; + size &= ~1; /* must be multiple of 2 */ + for (it = buf; it < buf + size / 2; ++it) + *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); +} + +void +iir_flow(FlowContext *context) +{ + static int init = 0; + int swapped = 0; + guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; + int caneq = (fmt == FMT_S16_NE || fmt == myorder); + + if (!caneq && cfg.equalizer_active) { /* wrong byte order */ + byteswap(context->len, context->data); /* so convert */ + ++swapped; + ++caneq; + } /* can eq now, mark swapd */ + else if (caneq && !cfg.equalizer_active) /* right order but no eq */ + caneq = 0; /* so don't eq */ + + if (caneq) { /* if eq enab */ + if (!init) { /* if first run */ + init_iir(); /* then init eq */ + ++init; + } + + iir(&context->data, context->len, context->channels); + + if (swapped) /* if was swapped */ + byteswap(context->len, context->data); /* swap back for output */ + } +} diff -r 0898b8139af8 -r 154f21dcd61e src/audacious/iir.h --- a/src/audacious/iir.h Tue Sep 18 13:33:45 2007 -0500 +++ b/src/audacious/iir.h Tue Sep 18 13:39:21 2007 -0500 @@ -23,6 +23,7 @@ #include #include "main.h" +#include "flow.h" #include "iir_cfs.h" /* @@ -79,5 +80,7 @@ extern unsigned int blength; #endif +void iir_flow(FlowContext *context); + #endif /* #define IIR_H */ diff -r 0898b8139af8 -r 154f21dcd61e src/audacious/output.c --- a/src/audacious/output.c Tue Sep 18 13:33:45 2007 -0500 +++ b/src/audacious/output.c Tue Sep 18 13:39:21 2007 -0500 @@ -204,17 +204,6 @@ } } -/* this should be in BYTES, NOT gint16s */ -static void -byteswap(size_t size, - gint16 * buf) -{ - gint16 *it; - size &= ~1; /* must be multiple of 2 */ - for (it = buf; it < buf + size / 2; ++it) - *(guint16 *) it = GUINT16_SWAP_LE_BE(*(guint16 *) it); -} - /* called by input plugin to peek at the output plugin's write progress */ gint get_written_time(void) @@ -432,16 +421,13 @@ ) { static Flow *postproc_flow = NULL; - static int init = 0; - int swapped = 0; - guint myorder = G_BYTE_ORDER == G_LITTLE_ENDIAN ? FMT_S16_LE : FMT_S16_BE; - int caneq = (fmt == FMT_S16_NE || fmt == myorder); OutputPlugin *op = get_current_output_plugin(); int writeoffs; if (postproc_flow == NULL) { postproc_flow = flow_new(); + flow_link_element(postproc_flow, iir_flow); flow_link_element(postproc_flow, effect_flow); flow_link_element(postproc_flow, vis_flow); flow_link_element(postproc_flow, volumecontrol_flow); @@ -485,26 +471,6 @@ } #endif - if (!caneq && cfg.equalizer_active) { /* wrong byte order */ - byteswap(length, ptr); /* so convert */ - ++swapped; - ++caneq; - } /* can eq now, mark swapd */ - else if (caneq && !cfg.equalizer_active) /* right order but no eq */ - caneq = 0; /* so don't eq */ - - if (caneq) { /* if eq enab */ - if (!init) { /* if first run */ - init_iir(); /* then init eq */ - ++init; - } - - iir(&ptr, length, nch); - - if (swapped) /* if was swapped */ - byteswap(length, ptr); /* swap back for output */ - } - flow_execute(postproc_flow, time, ptr, length, op_state.fmt, op_state.rate, op_state.nch); writeoffs = 0;