summaryrefslogtreecommitdiffstats
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.tar.bz2
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)
/* Have to adjust the pointers that point into things in voice_buf */
off_t diff = new - current;
struct voice_thread_data *td = voice_buf->td;
- td->src.p32[0] = SKIPBYTES(td->src.p32[0], diff);
- td->src.p32[1] = SKIPBYTES(td->src.p32[1], diff);
- if (td->dst != NULL) /* Only when calling dsp_process */
- td->dst->p16out = SKIPBYTES(td->dst->p16out, diff);
- mixer_adjust_channel_address(PCM_MIXER_CHAN_VOICE, diff);
+
+ if (td != NULL)
+ {
+ td->src.p32[0] = SKIPBYTES(td->src.p32[0], diff);
+ td->src.p32[1] = SKIPBYTES(td->src.p32[1], diff);
+
+ if (td->dst != NULL) /* Only when calling dsp_process */
+ td->dst->p16out = SKIPBYTES(td->dst->p16out, diff);
+
+ mixer_adjust_channel_address(PCM_MIXER_CHAN_VOICE, diff);
+ }
+
voice_buf = new;
return BUFLIB_CB_OK;
@@ -322,10 +329,7 @@ static void voice_data_init(struct voice_thread_data *td)
dsp_configure(td->dsp, DSP_SET_STEREO_MODE, STEREO_MONO);
mixer_channel_set_amplitude(PCM_MIXER_CHAN_VOICE, MIX_AMP_UNITY);
-
- voice_buf->frame_in = voice_buf->frame_out = 0;
voice_buf->td = td;
- td->dst = NULL;
}
/* Voice thread message processing */
@@ -536,6 +540,8 @@ void voice_thread_init(void)
return;
}
+ memset(voice_buf, 0, sizeof (*voice_buf));
+
logf("Starting voice thread");
queue_init(&voice_queue, false);