summaryrefslogtreecommitdiff
path: root/lib/rbcodec/dsp/dsp_sample_input.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/dsp/dsp_sample_input.c')
-rw-r--r--lib/rbcodec/dsp/dsp_sample_input.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/rbcodec/dsp/dsp_sample_input.c b/lib/rbcodec/dsp/dsp_sample_input.c
index 561cb36d9e..537a659b73 100644
--- a/lib/rbcodec/dsp/dsp_sample_input.c
+++ b/lib/rbcodec/dsp/dsp_sample_input.c
@@ -286,14 +286,17 @@ static void INIT_ATTR dsp_sample_input_init(struct sample_io_data *this,
286static void INIT_ATTR dsp_sample_io_init(struct sample_io_data *this, 286static void INIT_ATTR dsp_sample_io_init(struct sample_io_data *this,
287 enum dsp_ids dsp_id) 287 enum dsp_ids dsp_id)
288{ 288{
289 this->output_sampr = DSP_OUT_DEFAULT_HZ;
289 dsp_sample_input_init(this, dsp_id); 290 dsp_sample_input_init(this, dsp_id);
290 dsp_sample_output_init(this); 291 dsp_sample_output_init(this);
291} 292}
292 293
293void dsp_sample_io_configure(struct sample_io_data *this, 294bool dsp_sample_io_configure(struct sample_io_data *this,
294 unsigned int setting, 295 unsigned int setting,
295 intptr_t value) 296 intptr_t *value_p)
296{ 297{
298 intptr_t value = *value_p;
299
297 switch (setting) 300 switch (setting)
298 { 301 {
299 case DSP_INIT: 302 case DSP_INIT:
@@ -306,15 +309,15 @@ void dsp_sample_io_configure(struct sample_io_data *this,
306 this->format.num_channels = 2; 309 this->format.num_channels = 2;
307 this->format.frac_bits = WORD_FRACBITS; 310 this->format.frac_bits = WORD_FRACBITS;
308 this->format.output_scale = WORD_FRACBITS + 1 - NATIVE_DEPTH; 311 this->format.output_scale = WORD_FRACBITS + 1 - NATIVE_DEPTH;
309 this->format.frequency = NATIVE_FREQUENCY; 312 this->format.frequency = this->output_sampr;
310 this->format.codec_frequency = NATIVE_FREQUENCY; 313 this->format.codec_frequency = this->output_sampr;
311 this->sample_depth = NATIVE_DEPTH; 314 this->sample_depth = NATIVE_DEPTH;
312 this->stereo_mode = STEREO_NONINTERLEAVED; 315 this->stereo_mode = STEREO_NONINTERLEAVED;
313 break; 316 break;
314 317
315 case DSP_SET_FREQUENCY: 318 case DSP_SET_FREQUENCY:
316 format_change_set(this); 319 format_change_set(this);
317 value = value > 0 ? value : NATIVE_FREQUENCY; 320 value = value > 0 ? (unsigned int)value : this->output_sampr;
318 this->format.frequency = value; 321 this->format.frequency = value;
319 this->format.codec_frequency = value; 322 this->format.codec_frequency = value;
320 break; 323 break;
@@ -345,5 +348,22 @@ void dsp_sample_io_configure(struct sample_io_data *this,
345 this->format.frequency = 348 this->format.frequency =
346 fp_mul(value, this->format.codec_frequency, 16); 349 fp_mul(value, this->format.codec_frequency, 16);
347 break; 350 break;
351
352 case DSP_SET_OUT_FREQUENCY:
353 value = value > 0 ? value : DSP_OUT_DEFAULT_HZ;
354 value = MIN(DSP_OUT_MAX_HZ, MAX(DSP_OUT_MIN_HZ, value));
355 *value_p = value;
356
357 if ((unsigned int)value == this->output_sampr)
358 return true; /* No change; don't broadcast */
359
360 this->output_sampr = value;
361 break;
362
363 case DSP_GET_OUT_FREQUENCY:
364 *value_p = this->output_sampr;
365 return true; /* Only I/O handles it */
348 } 366 }
367
368 return false;
349} 369}