summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2012-05-17 11:16:20 -0400
committerMichael Sevakis <jethead71@rockbox.org>2012-05-17 11:16:20 -0400
commit8bbd4d91a0d7a2933b3bec4cb74da50016e8dd1e (patch)
tree1c65dc044cc002588fd467e95c2555fc0cc83918
parent7909bf039f6e5984b5a037d3de69128f02408223 (diff)
downloadrockbox-8bbd4d91a0d7a2933b3bec4cb74da50016e8dd1e.tar.gz
rockbox-8bbd4d91a0d7a2933b3bec4cb74da50016e8dd1e.zip
Zero out voice buffer memory immediately after allocation.
Can't wait for the voice thread to initialize it since it concievably could be moved before the voice thread actually does so and the move callback accesses data that must be first set up in the voice thread function. Change-Id: Ia0d09539854db85e132e09d26cb129f02f5d93ff
-rw-r--r--apps/voice_thread.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/apps/voice_thread.c b/apps/voice_thread.c
index 1a86dc7cfa..c9520e6165 100644
--- a/apps/voice_thread.c
+++ b/apps/voice_thread.c
@@ -161,11 +161,18 @@ static int move_callback(int handle, void *current, void *new)
161 /* Have to adjust the pointers that point into things in voice_buf */ 161 /* Have to adjust the pointers that point into things in voice_buf */
162 off_t diff = new - current; 162 off_t diff = new - current;
163 struct voice_thread_data *td = voice_buf->td; 163 struct voice_thread_data *td = voice_buf->td;
164 td->src.p32[0] = SKIPBYTES(td->src.p32[0], diff); 164
165 td->src.p32[1] = SKIPBYTES(td->src.p32[1], diff); 165 if (td != NULL)
166 if (td->dst != NULL) /* Only when calling dsp_process */ 166 {
167 td->dst->p16out = SKIPBYTES(td->dst->p16out, diff); 167 td->src.p32[0] = SKIPBYTES(td->src.p32[0], diff);
168 mixer_adjust_channel_address(PCM_MIXER_CHAN_VOICE, diff); 168 td->src.p32[1] = SKIPBYTES(td->src.p32[1], diff);
169
170 if (td->dst != NULL) /* Only when calling dsp_process */
171 td->dst->p16out = SKIPBYTES(td->dst->p16out, diff);
172
173 mixer_adjust_channel_address(PCM_MIXER_CHAN_VOICE, diff);
174 }
175
169 voice_buf = new; 176 voice_buf = new;
170 177
171 return BUFLIB_CB_OK; 178 return BUFLIB_CB_OK;
@@ -322,10 +329,7 @@ static void voice_data_init(struct voice_thread_data *td)
322 dsp_configure(td->dsp, DSP_SET_STEREO_MODE, STEREO_MONO); 329 dsp_configure(td->dsp, DSP_SET_STEREO_MODE, STEREO_MONO);
323 330
324 mixer_channel_set_amplitude(PCM_MIXER_CHAN_VOICE, MIX_AMP_UNITY); 331 mixer_channel_set_amplitude(PCM_MIXER_CHAN_VOICE, MIX_AMP_UNITY);
325
326 voice_buf->frame_in = voice_buf->frame_out = 0;
327 voice_buf->td = td; 332 voice_buf->td = td;
328 td->dst = NULL;
329} 333}
330 334
331/* Voice thread message processing */ 335/* Voice thread message processing */
@@ -536,6 +540,8 @@ void voice_thread_init(void)
536 return; 540 return;
537 } 541 }
538 542
543 memset(voice_buf, 0, sizeof (*voice_buf));
544
539 logf("Starting voice thread"); 545 logf("Starting voice thread");
540 queue_init(&voice_queue, false); 546 queue_init(&voice_queue, false);
541 547