diff options
Diffstat (limited to 'lib/rbcodec/dsp/dsp_misc.c')
-rw-r--r-- | lib/rbcodec/dsp/dsp_misc.c | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/lib/rbcodec/dsp/dsp_misc.c b/lib/rbcodec/dsp/dsp_misc.c index 672212b267..a19ef52883 100644 --- a/lib/rbcodec/dsp/dsp_misc.c +++ b/lib/rbcodec/dsp/dsp_misc.c | |||
@@ -26,7 +26,6 @@ | |||
26 | #include "fixedpoint.h" | 26 | #include "fixedpoint.h" |
27 | #include "replaygain.h" | 27 | #include "replaygain.h" |
28 | #include "dsp_proc_entry.h" | 28 | #include "dsp_proc_entry.h" |
29 | #include "dsp_sample_io.h" | ||
30 | #include "dsp_misc.h" | 29 | #include "dsp_misc.h" |
31 | #include "pga.h" | 30 | #include "pga.h" |
32 | #include "channel_mode.h" | 31 | #include "channel_mode.h" |
@@ -113,20 +112,21 @@ static int32_t pitch_ratio = PITCH_SPEED_100; | |||
113 | 112 | ||
114 | static void dsp_pitch_update(struct dsp_config *dsp) | 113 | static void dsp_pitch_update(struct dsp_config *dsp) |
115 | { | 114 | { |
116 | /* Account for playback speed adjustment when setting dsp->frequency | 115 | dsp_configure(dsp, DSP_SET_PITCH, |
117 | if we're called from the main audio thread. Voice playback thread | 116 | fp_div(pitch_ratio, PITCH_SPEED_100, 16)); |
118 | does not support this feature. */ | ||
119 | struct sample_io_data *data = (void *)dsp; | ||
120 | data->format.frequency = | ||
121 | (int64_t)pitch_ratio * data->format.codec_frequency / PITCH_SPEED_100; | ||
122 | } | 117 | } |
123 | 118 | ||
124 | static void dsp_set_pitch(int32_t percent) | 119 | static void dsp_set_pitch(int32_t percent) |
125 | { | 120 | { |
126 | pitch_ratio = percent > 0 ? percent : PITCH_SPEED_100; | 121 | if (percent <= 0) |
127 | struct dsp_config *dsp = dsp_get_config(CODEC_IDX_AUDIO); | 122 | percent = PITCH_SPEED_100; |
128 | struct sample_io_data *data = (void *)dsp; | 123 | |
129 | dsp_configure(dsp, DSP_SWITCH_FREQUENCY, data->format.codec_frequency); | 124 | if (percent == pitch_ratio) |
125 | return; | ||
126 | |||
127 | pitch_ratio = percent; | ||
128 | |||
129 | dsp_pitch_update(dsp_get_config(CODEC_IDX_AUDIO)); | ||
130 | } | 130 | } |
131 | #endif /* HAVE_PITCHCONTROL */ | 131 | #endif /* HAVE_PITCHCONTROL */ |
132 | 132 | ||
@@ -173,6 +173,13 @@ int dsp_callback(int msg, intptr_t param) | |||
173 | return retval; | 173 | return retval; |
174 | } | 174 | } |
175 | 175 | ||
176 | static void INIT_ATTR misc_dsp_init(struct dsp_config *dsp, | ||
177 | enum dsp_ids dsp_id) | ||
178 | { | ||
179 | /* Enable us for the audio DSP at startup */ | ||
180 | if (dsp_id == CODEC_IDX_AUDIO) | ||
181 | dsp_proc_enable(dsp, DSP_PROC_MISC_HANDLER, true); | ||
182 | } | ||
176 | 183 | ||
177 | /* This is a null-processing stage that monitors as an enabled stage but never | 184 | /* This is a null-processing stage that monitors as an enabled stage but never |
178 | * becomes active in processing samples. It only hooks messages. */ | 185 | * becomes active in processing samples. It only hooks messages. */ |
@@ -186,9 +193,7 @@ static intptr_t misc_handler_configure(struct dsp_proc_entry *this, | |||
186 | switch (setting) | 193 | switch (setting) |
187 | { | 194 | { |
188 | case DSP_INIT: | 195 | case DSP_INIT: |
189 | /* Enable us for the audio DSP at startup */ | 196 | misc_dsp_init(dsp, (enum dsp_ids)value); |
190 | if (value == CODEC_IDX_AUDIO) | ||
191 | dsp_proc_enable(dsp, DSP_PROC_MISC_HANDLER, true); | ||
192 | break; | 197 | break; |
193 | 198 | ||
194 | case DSP_PROC_CLOSE: | 199 | case DSP_PROC_CLOSE: |
@@ -212,7 +217,7 @@ static intptr_t misc_handler_configure(struct dsp_proc_entry *this, | |||
212 | #endif | 217 | #endif |
213 | } | 218 | } |
214 | 219 | ||
215 | return 1; | 220 | return 0; |
216 | (void)this; | 221 | (void)this; |
217 | } | 222 | } |
218 | 223 | ||