forked from len0rd/rockbox
Another fix for bug #835158, now handles multiple splits
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@4007 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
532eb411ac
commit
51d962f99b
1 changed files with 56 additions and 41 deletions
|
|
@ -1286,6 +1286,7 @@ static void mpeg_thread(void)
|
|||
int startpos;
|
||||
int rc;
|
||||
int offset;
|
||||
int countdown;
|
||||
#endif
|
||||
|
||||
is_playing = false;
|
||||
|
|
@ -1964,14 +1965,19 @@ static void mpeg_thread(void)
|
|||
|
||||
case MPEG_NEW_FILE:
|
||||
/* Make sure we have at least one complete frame
|
||||
in the buffer */
|
||||
in the buffer. If we haven't recorded a single
|
||||
frame within 200ms, the MAS is probably not recording
|
||||
anything, and we bail out. */
|
||||
countdown = 20;
|
||||
amount_to_save = get_unsaved_space();
|
||||
while(amount_to_save < 1800)
|
||||
while(countdown-- && amount_to_save < 1800)
|
||||
{
|
||||
sleep(HZ/10);
|
||||
amount_to_save = get_unsaved_space();
|
||||
}
|
||||
|
||||
if(amount_to_save >= 1800)
|
||||
{
|
||||
/* Now find a frame boundary to split at */
|
||||
startpos = mp3buf_write - 1800;
|
||||
if(startpos < 0)
|
||||
|
|
@ -2002,6 +2008,12 @@ static void mpeg_thread(void)
|
|||
/* No header found. Let's save the whole buffer. */
|
||||
startpos = mp3buf_write;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Too few bytes recorded, timeout */
|
||||
startpos = mp3buf_write;
|
||||
}
|
||||
|
||||
amount_to_save = startpos - mp3buf_read;
|
||||
if(amount_to_save < 0)
|
||||
|
|
@ -2011,6 +2023,8 @@ static void mpeg_thread(void)
|
|||
writelen = MIN(amount_to_save,
|
||||
mp3buflen - mp3buf_read);
|
||||
|
||||
if(writelen)
|
||||
{
|
||||
rc = write(mpeg_file, mp3buf + mp3buf_read, writelen);
|
||||
if(rc < 0)
|
||||
{
|
||||
|
|
@ -2024,7 +2038,8 @@ static void mpeg_thread(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
panicf("rec wrt: %d", rc);
|
||||
panicf("spt wrt: %d", rc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue