diff options
| author | Michael Sevakis <jethead71@rockbox.org> | 2012-12-19 17:34:57 -0500 |
|---|---|---|
| committer | Michael Sevakis <jethead71@rockbox.org> | 2013-05-04 13:43:33 -0400 |
| commit | 78a45b47dede5ddf35dfc53e965b486a79177b18 (patch) | |
| tree | edb3ad7c101e600a7cc3be4b40380430cbeb3e55 /lib/rbcodec/dsp/dsp_sample_output.c | |
| parent | cdb71c707bb434f44368b72f2db3becc37b7a46c (diff) | |
| download | rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.zip rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.tar.gz rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.tar.bz2 rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.tar.xz | |
Cleanup and simplify latest DSP code incarnation.
Some things can just be a bit simpler in handling the list of stages
and some things, especially format change handling, can be simplified
for each stage implementation. Format changes are sent through the
configure() callback.
Hide some internal details and variables from processing stages and
let the core deal with it.
Do some miscellaneous cleanup and keep things a bit better factored.
Change-Id: I19dd8ce1d0b792ba914d426013088a49a52ecb7e
Diffstat (limited to 'lib/rbcodec/dsp/dsp_sample_output.c')
| -rw-r--r-- | lib/rbcodec/dsp/dsp_sample_output.c | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/lib/rbcodec/dsp/dsp_sample_output.c b/lib/rbcodec/dsp/dsp_sample_output.c index 4a8050b..d57d236 100644 --- a/lib/rbcodec/dsp/dsp_sample_output.c +++ b/lib/rbcodec/dsp/dsp_sample_output.c @@ -23,6 +23,7 @@ #include "system.h" #include "dsp_core.h" #include "dsp_sample_io.h" +#include "dsp_proc_entry.h" #include "dsp-util.h" #include <string.h> @@ -159,9 +160,8 @@ void sample_output_dithered(struct sample_io_data *this, } /* Initialize the output function for settings and format */ -static void dsp_sample_output_format_change(struct sample_io_data *this, - struct dsp_buffer *src, - struct dsp_buffer *dst) +void dsp_sample_output_format_change(struct sample_io_data *this, + struct sample_format *format) { static const sample_output_fn_type fns[2][2] = { @@ -171,25 +171,20 @@ static void dsp_sample_output_format_change(struct sample_io_data *this, sample_output_dithered }, }; - struct sample_format *format = &src->format; bool dither = dsp_get_id((void *)this) == CODEC_IDX_AUDIO && dither_data.enabled; int channels = format->num_channels; - DSP_PRINT_FORMAT(DSP Output, -1, *format); + DSP_PRINT_FORMAT(DSP Output, *format); - this->output_samples[0] = fns[dither ? 1 : 0][channels - 1]; - format_change_ack(format); /* always ack, we're last */ - - /* The real function mustn't be called with no data */ - if (this->outcount > 0) - this->output_samples[0](this, src, dst); + this->output_samples = fns[dither ? 1 : 0][channels - 1]; + this->output_version = format->version; } -void dsp_sample_output_init(struct sample_io_data *this) +void INIT_ATTR dsp_sample_output_init(struct sample_io_data *this) { - this->output_samples[0] = sample_output_stereo; - this->output_samples[1] = dsp_sample_output_format_change; + this->output_version = 0; + this->output_samples = sample_output_stereo; } /* Flush the dither history */ @@ -199,6 +194,7 @@ void dsp_sample_output_flush(struct sample_io_data *this) memset(dither_data.state, 0, sizeof (dither_data.state)); } + /** Output settings **/ /* Set the tri-pdf dithered output */ @@ -207,8 +203,11 @@ void dsp_dither_enable(bool enable) if (enable == dither_data.enabled) return; - struct sample_io_data *data = (void *)dsp_get_config(CODEC_IDX_AUDIO); - dsp_sample_output_flush(data); dither_data.enabled = enable; - data->output_samples[0] = dsp_sample_output_format_change; + struct sample_io_data *data = (void *)dsp_get_config(CODEC_IDX_AUDIO); + + if (enable) + dsp_sample_output_flush(data); + + data->output_version = 0; /* Force format update */ } |