From c49129cacdf81e86bd613b5baee4acefadcc83d1 Mon Sep 17 00:00:00 2001 From: Jörg Hohensohn Date: Tue, 20 Apr 2004 22:11:20 +0000 Subject: minor improvement to make the clip switch safer git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4528 a1c6a512-1295-4272-9138-f99709370657 --- apps/talk.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'apps') 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) && (search[1] & 0x30) == (curr_hd[1] & 0x30)) /* sample rate */ { search--; /* back to the sync byte */ - break; /* From looking at it, this is a header. */ - /* This is not a sufficient condition to find header, may - give "false alert" (end too early), but a good start. */ + break; /* From looking at it, this is our header. */ } } - queue_write = queue_read + 1; /* reset the queue */ - if (queue_write >= QUEUE_SIZE) - queue_write = 0; - queue[queue_read].len = 0; - - /* play old data until the frame end, to keep the MAS in sync */ + if (search-pos) - { + { /* play old data until the frame end, to keep the MAS in sync */ DTCR3 = search-pos; + + queue_write = queue_read + 1; /* will be empty after next callback */ + if (queue_write >= QUEUE_SIZE) + queue_write = 0; + queue[queue_read].len = 0; /* current one ends now */ + CHCR3 |= 0x0001; /* re-enable DMA */ } + else + { /* by chance we have played to a frame boundary */ + queue_write = queue_read; /* reset the queue */ + is_playing = false; + mp3_play_stop(); + } return 0; } -- cgit v1.2.3