summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-04-12 23:35:47 -0400
committerMichael Sevakis <jethead71@rockbox.org>2013-04-15 12:02:05 -0400
commit0c7b7873984e04941c9f21fa272638018fdb9a16 (patch)
treefb6afca45d2bef0a2c91732a39ffc0b965f5c557 /lib
parentfd9e2568908f91b5bcf7378dc28f6ec070d6027a (diff)
Straighten out the mad twisted state of sound.c and related areas.
This is going right in since it's long overdue. If anything is goofed, drop me a line or just tweak it yourself if you know what's wrong. :-) Make HW/SW codec interface more uniform when emulating HW functionality on SWCODEC for functions such as "audiohw_set_pitch". The firmware-to- DSP plumbing is in firmware/drivers/audiohw-swcodec.c. "sound_XXX" APIs are all in sound.c with none in DSP code any longer. Reduce number of settings definitions needed by each codec by providing defaults for common ones like balance, channels and SW tone controls. Remove need for separate SIM code and tables and add virtual codec header for hosted targets. Change-Id: I3f23702bca054fc9bda40f49824ce681bb7f777b
Diffstat (limited to 'lib')
-rw-r--r--lib/rbcodec/dsp/dsp_misc.c83
-rw-r--r--lib/rbcodec/dsp/dsp_misc.h16
-rw-r--r--lib/rbcodec/test/warble.c2
3 files changed, 57 insertions, 44 deletions
diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c
index a8c9423cfb..672212b267 100644
--- a/lib/rbcodec/dsp/dsp_misc.c
+++ b/lib/rbcodec/dsp/dsp_misc.c
@@ -35,38 +35,6 @@
#endif
#include <string.h>
-/** Firmware callback interface **/
-
-/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/
- * code directly. */
-int dsp_callback(int msg, intptr_t param)
-{
- switch (msg)
- {
-#ifdef HAVE_SW_TONE_CONTROLS
- case DSP_CALLBACK_SET_PRESCALE:
- tone_set_prescale(param);
- break;
- case DSP_CALLBACK_SET_BASS:
- tone_set_bass(param);
- break;
- case DSP_CALLBACK_SET_TREBLE:
- tone_set_treble(param);
- break;
-#endif /* HAVE_SW_TONE_CONTROLS */
- case DSP_CALLBACK_SET_CHANNEL_CONFIG:
- channel_mode_set_config(param);
- break;
- case DSP_CALLBACK_SET_STEREO_WIDTH:
- channel_mode_custom_set_width(param);
- break;
- default:
- break;
- }
-
- return 0;
-}
-
/** Replaygain settings **/
static struct replaygain_settings current_settings;
static struct dsp_replay_gains current_gains;
@@ -153,12 +121,7 @@ static void dsp_pitch_update(struct dsp_config *dsp)
(int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100;
}
-int32_t sound_get_pitch(void)
-{
- return pitch_ratio;
-}
-
-void sound_set_pitch(int32_t percent)
+static void dsp_set_pitch(int32_t percent)
{
pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100;
struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO);
@@ -167,6 +130,50 @@ void sound_set_pitch(int32_t percent)
}
#endif /* HAVE_PITCHCONTROL */
+
+/** Firmware callback interface **/
+
+/* Hook back from firmware/ part of audio, which can't/shouldn't call apps/
+ * code directly. */
+int dsp_callback(int msg, intptr_t param)
+{
+ int retval = 0;
+
+ switch (msg)
+ {
+#ifdef HAVE_SW_TONE_CONTROLS
+ case DSP_CALLBACK_SET_PRESCALE:
+ tone_set_prescale(param);
+ break;
+ case DSP_CALLBACK_SET_BASS:
+ tone_set_bass(param);
+ break;
+ case DSP_CALLBACK_SET_TREBLE:
+ tone_set_treble(param);
+ break;
+#endif /* HAVE_SW_TONE_CONTROLS */
+ case DSP_CALLBACK_SET_CHANNEL_CONFIG:
+ channel_mode_set_config(param);
+ break;
+ case DSP_CALLBACK_SET_STEREO_WIDTH:
+ channel_mode_custom_set_width(param);
+ break;
+#ifdef HAVE_PITCHCONTROL
+ case DSP_CALLBACK_SET_PITCH:
+ dsp_set_pitch(param);
+ break;
+ case DSP_CALLBACK_GET_PITCH:
+ retval = pitch_ratio;
+ break;
+#endif /* HAVE_PITCHCONTROL */
+ default:
+ break;
+ }
+
+ return retval;
+}
+
+
/* This is a null-processing stage that monitors as an enabled stage but never
* becomes active in processing samples. It only hooks messages. */
diff --git a/lib/rbcodec/dsp/dsp_misc.h b/lib/rbcodec/dsp/dsp_misc.h
index d658374eaf..2583f495c3 100644
--- a/lib/rbcodec/dsp/dsp_misc.h
+++ b/lib/rbcodec/dsp/dsp_misc.h
@@ -54,12 +54,18 @@ struct dsp_replay_gains
void dsp_replaygain_set_settings(const struct replaygain_settings *settings);
-#ifdef HAVE_PITCHCONTROL
-void sound_set_pitch(int32_t ratio);
-int32_t sound_get_pitch(void);
-#endif /* HAVE_PITCHCONTROL */
-
/* Callback for firmware layers to interface */
+enum
+{
+ DSP_CALLBACK_SET_PRESCALE = 0,
+ DSP_CALLBACK_SET_BASS,
+ DSP_CALLBACK_SET_TREBLE,
+ DSP_CALLBACK_SET_CHANNEL_CONFIG,
+ DSP_CALLBACK_SET_STEREO_WIDTH,
+ DSP_CALLBACK_SET_PITCH,
+ DSP_CALLBACK_GET_PITCH,
+};
+
int dsp_callback(int msg, intptr_t param);
#endif /* DSP_MISC_H */
diff --git a/lib/rbcodec/test/warble.c b/lib/rbcodec/test/warble.c
index d5bc1c5aea..cd73a75542 100644
--- a/lib/rbcodec/test/warble.c
+++ b/lib/rbcodec/test/warble.c
@@ -354,7 +354,7 @@ static void perform_config(void)
} else if (!strncmp(name, "offset=", 7)) {
ci.id3->offset = atoi(val);
} else if (!strncmp(name, "rate=", 5)) {
- sound_set_pitch(atof(val) * PITCH_SPEED_100);
+ dsp_callback(DSP_CALLBACK_SET_PITCH, atof(val) * PITCH_SPEED_100);
} else if (!strncmp(name, "seek=", 5)) {
codec_action = CODEC_ACTION_SEEK_TIME;
codec_action_param = atoi(val);