summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2004-03-23 11:49:09 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2004-03-23 11:49:09 +0000
commit1c92b6bd0907bbd19b8b40152bd9950470f1be92 (patch)
treeed0fbc3c37cdd5c2da634264e13196cb8d3f9514 /apps
parent3a7d397f20a6f5a3b7c5c47ae91312339acbf8c5 (diff)
downloadrockbox-1c92b6bd0907bbd19b8b40152bd9950470f1be92.tar.gz
rockbox-1c92b6bd0907bbd19b8b40152bd9950470f1be92.tar.bz2
rockbox-1c92b6bd0907bbd19b8b40152bd9950470f1be92.zip
Slightly better method of finding the next frame
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4435 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/talk.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/apps/talk.c b/apps/talk.c
index 906563e23a..3849f0e847 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -31,6 +31,7 @@
#include "lang.h"
#include "talk.h"
#include "screens.h" /* test hack */
+#include "kernel.h"
extern void bitswap(unsigned char *data, int length); /* no header for this */
/***************** Constants *****************/
@@ -160,13 +161,20 @@ static void mp3_callback(unsigned char** start, int* size)
}
}
-
/* stop the playback and the pending clips, but at frame boundary */
static int shutup(void)
{
unsigned char* pos;
unsigned char* search;
unsigned char* end;
+ unsigned char frame1, frame3;
+ unsigned char *firstclip = mp3buf + p_voicefont->index[0].offset;
+
+ /* We use the first frame in the thumbnail buffer as a template
+ for finding headers, assuming that all thumbnails are encoded
+ with the same parameters */
+ frame1 = firstclip[1]; /* second byte of the first mp3 header */
+ frame3 = firstclip[3]; /* last byte of the first mp3 header */
mp3_play_pause(false); /* pause */
@@ -177,22 +185,14 @@ static int shutup(void)
pos = search = mp3_get_pos();
end = queue[queue_read].buf + queue[queue_read].len;
+ /* Find the next frame boundary */
while (search < end) /* search the remaining data */
{
- if (*search++ != 0xFF) /* search for frame sync byte */
- {
- continue;
- }
-
- /* look at the (bitswapped) 2nd byte of header candidate */
- if ((*search & 0x07) == 0x07 /* rest of frame sync */
- && (*search & 0x18) != 0x10 /* version != reserved */
- && (*search & 0x60) != 0x00) /* layer != reserved */
+ if(search[0] == 0xff && search[1] == frame1 && search[3] == frame3)
{
- break; /* From looking at the first 2 bytes, this is a header. */
- /* this is not a sufficient condition to find header,
- may give "false alert" (end too early), but a start */
+ break;
}
+ search++;
}
queue_write = queue_read; /* reset the queue */