From 1521a1c38a4e5bb2791a5a625f242e025225d9ea Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Wed, 13 Nov 2002 23:22:40 +0000 Subject: Slightly more correct saving when recording git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2845 a1c6a512-1295-4272-9138-f99709370657 --- firmware/mpeg.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 329b6abc0d..83f9a38246 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -1036,6 +1036,7 @@ static void mpeg_thread(void) int start_offset; #ifdef HAVE_MAS3587F int amount_to_save; + int writelen; #endif is_playing = false; @@ -1622,9 +1623,9 @@ static void mpeg_thread(void) wrapped */ if(amount_to_save < 0) { - amount_to_save = mp3buflen - mp3buf_read; + amount_to_save += mp3buflen; } - + /* Save data only if the buffer is getting full, or if we should stop recording */ if(amount_to_save) @@ -1632,8 +1633,12 @@ static void mpeg_thread(void) if(mp3buflen - amount_to_save < MPEG_LOW_WATER || stop_pending) { + /* Only save up to the end of the buffer */ + writelen = MIN(amount_to_save, + mp3buflen - mp3buf_read); + write(mpeg_file, mp3buf + mp3buf_read, - amount_to_save); + writelen); mp3buf_read += amount_to_save; if(mp3buf_read >= mp3buflen) -- cgit v1.2.3