diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2012-05-30 12:55:26 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2012-05-30 12:55:26 -0400 |
commit | 77220147b5678dfc148171263aafe07dfde51b67 (patch) | |
tree | d60895a4ecdb836c71e191b6c222de6083c1a515 /apps/voice_thread.c | |
parent | 7a009276bc136ca8889f561b7002e7d94c2a9885 (diff) | |
download | rockbox-77220147b5678dfc148171263aafe07dfde51b67.tar.gz rockbox-77220147b5678dfc148171263aafe07dfde51b67.zip |
Get voice PCM queue indexes updating in right order...
...from the compiled code standpoint anyway. frame_out was being
incremented before updating size...sometimes...depending on what
GCC was up to. This seems to help.
Change-Id: Ie4ee3337a2937bd2c26f0a9c4a1a00467954821b
Diffstat (limited to 'apps/voice_thread.c')
-rw-r--r-- | apps/voice_thread.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/apps/voice_thread.c b/apps/voice_thread.c index c9520e6165..87e4eee9cb 100644 --- a/apps/voice_thread.c +++ b/apps/voice_thread.c | |||
@@ -143,7 +143,8 @@ static struct voice_buf | |||
143 | /* Buffer for decoded samples */ | 143 | /* Buffer for decoded samples */ |
144 | spx_int16_t spx_outbuf[VOICE_FRAME_COUNT]; | 144 | spx_int16_t spx_outbuf[VOICE_FRAME_COUNT]; |
145 | /* Queue frame indexes */ | 145 | /* Queue frame indexes */ |
146 | unsigned int frame_in, frame_out; | 146 | unsigned int volatile frame_in; |
147 | unsigned int volatile frame_out; | ||
147 | /* For PCM pointer adjustment */ | 148 | /* For PCM pointer adjustment */ |
148 | struct voice_thread_data *td; | 149 | struct voice_thread_data *td; |
149 | /* Buffers for mixing voice */ | 150 | /* Buffers for mixing voice */ |
@@ -197,7 +198,7 @@ static struct buflib_callbacks ops = | |||
197 | }; | 198 | }; |
198 | 199 | ||
199 | /* Number of frames in queue */ | 200 | /* Number of frames in queue */ |
200 | static inline int voice_unplayed_frames(void) | 201 | static unsigned int voice_unplayed_frames(void) |
201 | { | 202 | { |
202 | return voice_buf->frame_in - voice_buf->frame_out; | 203 | return voice_buf->frame_in - voice_buf->frame_out; |
203 | } | 204 | } |
@@ -205,11 +206,13 @@ static inline int voice_unplayed_frames(void) | |||
205 | /* Mixer channel callback */ | 206 | /* Mixer channel callback */ |
206 | static void voice_pcm_callback(const void **start, size_t *size) | 207 | static void voice_pcm_callback(const void **start, size_t *size) |
207 | { | 208 | { |
209 | unsigned int frame_out = ++voice_buf->frame_out; | ||
210 | |||
208 | if (voice_unplayed_frames() == 0) | 211 | if (voice_unplayed_frames() == 0) |
209 | return; /* Done! */ | 212 | return; /* Done! */ |
210 | 213 | ||
211 | struct voice_pcm_frame *frame = | 214 | struct voice_pcm_frame *frame = |
212 | &voice_buf->frames[++voice_buf->frame_out % VOICE_FRAMES]; | 215 | &voice_buf->frames[frame_out % VOICE_FRAMES]; |
213 | 216 | ||
214 | *start = frame->pcm; | 217 | *start = frame->pcm; |
215 | *size = frame->size; | 218 | *size = frame->size; |
@@ -219,7 +222,7 @@ static void voice_pcm_callback(const void **start, size_t *size) | |||
219 | static void voice_start_playback(void) | 222 | static void voice_start_playback(void) |
220 | { | 223 | { |
221 | if (mixer_channel_status(PCM_MIXER_CHAN_VOICE) != CHANNEL_STOPPED || | 224 | if (mixer_channel_status(PCM_MIXER_CHAN_VOICE) != CHANNEL_STOPPED || |
222 | voice_unplayed_frames() <= 0) | 225 | voice_unplayed_frames() == 0) |
223 | return; | 226 | return; |
224 | 227 | ||
225 | struct voice_pcm_frame *frame = | 228 | struct voice_pcm_frame *frame = |
@@ -254,8 +257,10 @@ static void voice_buf_commit(int count) | |||
254 | { | 257 | { |
255 | if (count > 0) | 258 | if (count > 0) |
256 | { | 259 | { |
257 | voice_buf->frames[voice_buf->frame_in++ % VOICE_FRAMES].size = | 260 | unsigned int frame_in = voice_buf->frame_in; |
261 | voice_buf->frames[frame_in % VOICE_FRAMES].size = | ||
258 | count * 2 * sizeof (int16_t); | 262 | count * 2 * sizeof (int16_t); |
263 | voice_buf->frame_in = frame_in + 1; | ||
259 | } | 264 | } |
260 | } | 265 | } |
261 | 266 | ||