summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2003-04-12 09:38:33 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2003-04-12 09:38:33 +0000
commit35c417f1d4cfa303fc1ab97718a5a47a7378f095 (patch)
treeb46c300e7542acfa8da90c36aac7e1e4c2d57ebd /firmware/mpeg.c
parent434b7d90ede78443db1c7e3ecb07067b9e2b842b (diff)
Fixed the dreaded 'silent play' bug
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3541 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 7e63bf21e3..30530ed85b 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -1239,7 +1239,7 @@ static bool swap_one_chunk(void)
else
amount_to_swap = MIN(mp3buf_write - mp3buf_swapwrite,
amount_to_swap);
-
+
bitswap(mp3buf + mp3buf_swapwrite, amount_to_swap);
mp3buf_swapwrite += amount_to_swap;
@@ -1583,7 +1583,7 @@ static void mpeg_thread(void)
int unplayed_space_left, unswapped_space_left;
/* We are changing to a position that's already in
- memory */
+ memory, so we just move the DMA read pointer. */
mp3buf_read = mp3buf_write - diffpos;
if (mp3buf_read < 0)
{
@@ -1593,6 +1593,19 @@ static void mpeg_thread(void)
unplayed_space_left = get_unplayed_space();
unswapped_space_left = get_unswapped_space();
+ /* If unswapped_space_left is larger than
+ unplayed_space_left, it means that the swapwrite pointer
+ hasn't yet advanced up to the new location of the read
+ pointer. We just move it, there is no need to swap
+ data that won't be played anyway. */
+
+ if (unswapped_space_left > unplayed_space_left)
+ {
+ DEBUGF("Moved swapwrite\n");
+ mp3buf_swapwrite = mp3buf_read;
+ play_pending = true;
+ }
+
if (mpeg_file>=0 && unplayed_space_left < low_watermark)
{
/* We need to load more data before starting */
@@ -1600,11 +1613,6 @@ static void mpeg_thread(void)
queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
play_pending = true;
}
- else if (unswapped_space_left > unplayed_space_left)
- {
- mp3buf_swapwrite = mp3buf_read;
- play_pending = true;
- }
else
{
/* resume will start at new position */