summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/talk.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 47c3e6db58..df5c6ef438 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -214,22 +214,27 @@ static int shutup(void)
214 && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */ 214 && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */
215 { 215 {
216 search--; /* back to the sync byte */ 216 search--; /* back to the sync byte */
217 break; /* From looking at it, this is a header. */ 217 break; /* From looking at it, this is our header. */
218 /* This is not a sufficient condition to find header, may
219 give "false alert" (end too early), but a good start. */
220 } 218 }
221 } 219 }
222 queue_write = queue_read + 1; /* reset the queue */ 220
223 if (queue_write >= QUEUE_SIZE)
224 queue_write = 0;
225 queue[queue_read].len = 0;
226
227 /* play old data until the frame end, to keep the MAS in sync */
228 if (search-pos) 221 if (search-pos)
229 { 222 { /* play old data until the frame end, to keep the MAS in sync */
230 DTCR3 = search-pos; 223 DTCR3 = search-pos;
224
225 queue_write = queue_read + 1; /* will be empty after next callback */
226 if (queue_write >= QUEUE_SIZE)
227 queue_write = 0;
228 queue[queue_read].len = 0; /* current one ends now */
229
231 CHCR3 |= 0x0001; /* re-enable DMA */ 230 CHCR3 |= 0x0001; /* re-enable DMA */
232 } 231 }
232 else
233 { /* by chance we have played to a frame boundary */
234 queue_write = queue_read; /* reset the queue */
235 is_playing = false;
236 mp3_play_stop();
237 }
233 238
234 return 0; 239 return 0;
235} 240}