diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2013-05-23 13:58:51 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2013-07-06 04:22:04 +0200 |
commit | d37bf24d9011addbfbd40942a4e9bbf26de7df00 (patch) | |
tree | dafb7eaeb494081668a4841d490fce2bfbb2438d /lib/rbcodec/dsp/dsp_sample_input.c | |
parent | 00faabef5e902008172e08d3bcd77683cbafef51 (diff) | |
download | rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.tar.gz rockbox-d37bf24d9011addbfbd40942a4e9bbf26de7df00.zip |
Enable setting of global output samplerate on certain targets.
Replaces the NATIVE_FREQUENCY constant with a configurable frequency.
The user may select 48000Hz if the hardware supports it. The default is
still 44100Hz and the minimum is 44100Hz. The setting is located in the
playback settings, under "Frequency".
"Frequency" was duplicated in english.lang for now to avoid having to
fix every .lang file for the moment and throwing everything out of sync
because of the new play_frequency feature in features.txt. The next
cleanup should combine it with the one included for recording and
generalize the ID label.
If the hardware doesn't support 48000Hz, no setting will be available.
On particular hardware where very high rates are practical and desireable,
the upper bound can be extended by patching.
The PCM mixer can be configured to play at the full hardware frequency
range. The DSP core can configure to the hardware minimum up to the
maximum playback setting (some buffers must be reserved according to
the maximum rate).
If only 44100Hz is supported or possible on a given target for playback,
using the DSP and mixer at other samperates is possible if the hardware
offers them.
Change-Id: I6023cf0c0baa8bc6292b6919b4dd3618a6a25622
Reviewed-on: http://gerrit.rockbox.org/479
Reviewed-by: Michael Sevakis <jethead71@rockbox.org>
Tested-by: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'lib/rbcodec/dsp/dsp_sample_input.c')
-rw-r--r-- | lib/rbcodec/dsp/dsp_sample_input.c | 30 |
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, | |||
286 | static void INIT_ATTR dsp_sample_io_init(struct sample_io_data *this, | 286 | static 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 | ||
293 | void dsp_sample_io_configure(struct sample_io_data *this, | 294 | bool 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 | } |