summaryrefslogtreecommitdiff
path: root/lib/rbcodec/dsp/dsp_sample_output.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-12-19 17:34:57 -0500
committerMichael Sevakis <jethead71@rockbox.org>2013-05-04 13:43:33 -0400
commit78a45b47dede5ddf35dfc53e965b486a79177b18 (patch)
treeedb3ad7c101e600a7cc3be4b40380430cbeb3e55 /lib/rbcodec/dsp/dsp_sample_output.c
parentcdb71c707bb434f44368b72f2db3becc37b7a46c (diff)
downloadrockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.tar.gz
rockbox-78a45b47dede5ddf35dfc53e965b486a79177b18.zip
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.c33
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 4a8050b082..d57d236cbb 100644
--- a/lib/rbcodec/dsp/dsp_sample_output.c
+++ b/lib/rbcodec/dsp/dsp_sample_output.c
@@ -23,6 +23,7 @@
23#include "system.h" 23#include "system.h"
24#include "dsp_core.h" 24#include "dsp_core.h"
25#include "dsp_sample_io.h" 25#include "dsp_sample_io.h"
26#include "dsp_proc_entry.h"
26#include "dsp-util.h" 27#include "dsp-util.h"
27#include <string.h> 28#include <string.h>
28 29
@@ -159,9 +160,8 @@ void sample_output_dithered(struct sample_io_data *this,
159} 160}
160 161
161/* Initialize the output function for settings and format */ 162/* Initialize the output function for settings and format */
162static void dsp_sample_output_format_change(struct sample_io_data *this, 163void dsp_sample_output_format_change(struct sample_io_data *this,
163 struct dsp_buffer *src, 164 struct sample_format *format)
164 struct dsp_buffer *dst)
165{ 165{
166 static const sample_output_fn_type fns[2][2] = 166 static const sample_output_fn_type fns[2][2] =
167 { 167 {
@@ -171,25 +171,20 @@ static void dsp_sample_output_format_change(struct sample_io_data *this,
171 sample_output_dithered }, 171 sample_output_dithered },
172 }; 172 };
173 173
174 struct sample_format *format = &src->format;
175 bool dither = dsp_get_id((void *)this) == CODEC_IDX_AUDIO && 174 bool dither = dsp_get_id((void *)this) == CODEC_IDX_AUDIO &&
176 dither_data.enabled; 175 dither_data.enabled;
177 int channels = format->num_channels; 176 int channels = format->num_channels;
178 177
179 DSP_PRINT_FORMAT(DSP Output, -1, *format); 178 DSP_PRINT_FORMAT(DSP Output, *format);
180 179
181 this->output_samples[0] = fns[dither ? 1 : 0][channels - 1]; 180 this->output_samples = fns[dither ? 1 : 0][channels - 1];
182 format_change_ack(format); /* always ack, we're last */ 181 this->output_version = format->version;
183
184 /* The real function mustn't be called with no data */
185 if (this->outcount > 0)
186 this->output_samples[0](this, src, dst);
187} 182}
188 183
189void dsp_sample_output_init(struct sample_io_data *this) 184void INIT_ATTR dsp_sample_output_init(struct sample_io_data *this)
190{ 185{
191 this->output_samples[0] = sample_output_stereo; 186 this->output_version = 0;
192 this->output_samples[1] = dsp_sample_output_format_change; 187 this->output_samples = sample_output_stereo;
193} 188}
194 189
195/* Flush the dither history */ 190/* Flush the dither history */
@@ -199,6 +194,7 @@ void dsp_sample_output_flush(struct sample_io_data *this)
199 memset(dither_data.state, 0, sizeof (dither_data.state)); 194 memset(dither_data.state, 0, sizeof (dither_data.state));
200} 195}
201 196
197
202/** Output settings **/ 198/** Output settings **/
203 199
204/* Set the tri-pdf dithered output */ 200/* Set the tri-pdf dithered output */
@@ -207,8 +203,11 @@ void dsp_dither_enable(bool enable)
207 if (enable == dither_data.enabled) 203 if (enable == dither_data.enabled)
208 return; 204 return;
209 205
210 struct sample_io_data *data = (void *)dsp_get_config(CODEC_IDX_AUDIO);
211 dsp_sample_output_flush(data);
212 dither_data.enabled = enable; 206 dither_data.enabled = enable;
213 data->output_samples[0] = dsp_sample_output_format_change; 207 struct sample_io_data *data = (void *)dsp_get_config(CODEC_IDX_AUDIO);
208
209 if (enable)
210 dsp_sample_output_flush(data);
211
212 data->output_version = 0; /* Force format update */
214} 213}