diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-10-28 00:00:07 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-10-28 00:00:07 +0000 |
| commit | c5e29938c4c7dfcb1b888bbb3440f8688eb1d165 (patch) | |
| tree | 52b242a5266797e2d0632de36ace0517553a91bf | |
| parent | a12eb3d89239c2933bd3679cffd7d82be305dd42 (diff) | |
| download | rockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.zip rockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.tar.gz rockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.tar.bz2 rockbox-c5e29938c4c7dfcb1b888bbb3440f8688eb1d165.tar.xz | |
Fast forward near the end of the last song in a playlist didn't activate the DMA if the remaining amount to play was below the watermark
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2754 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/mpeg.c | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index e8fd1ac..206e67d 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -841,7 +841,35 @@ void hexdump(unsigned char *buf, int len) } #endif -static void swap_one_chunk(void) +static void start_playback_if_ready(void) +{ + /* See if we have started playing yet. If not, do it. */ + if(play_pending || dma_underrun) + { + /* If the filling has stopped, and we still haven't reached + the watermark, the file must be smaller than the + watermark. We must still play it. */ + if(((mp3buf_swapwrite - mp3buf_read) >= MPEG_LOW_WATER) || + !filling) + { + DEBUGF("P\n"); + play_pending = false; + playing = true; + + init_dma(); + if (!paused) + { + last_dma_tick = current_tick; + start_dma(); + } + + /* Tell ourselves that we need more data */ + queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); + } + } +} + +static bool swap_one_chunk(void) { int free_space_left; int amount_to_swap; @@ -849,7 +877,7 @@ static void swap_one_chunk(void) free_space_left = get_unswapped_space(); if(free_space_left == 0 && !play_pending) - return; + return false; /* Swap in larger chunks when the user is waiting for the playback to start */ @@ -873,31 +901,7 @@ static void swap_one_chunk(void) mp3buf_swapwrite = 0; } - /* And while we're at it, see if we have started - playing yet. If not, do it. */ - if(play_pending || dma_underrun) - { - /* If the filling has stopped, and we still haven't reached - the watermark, the file must be smaller than the - watermark. We must still play it. */ - if(((mp3buf_swapwrite - mp3buf_read) >= MPEG_LOW_WATER) || - !filling) - { - DEBUGF("P\n"); - play_pending = false; - playing = true; - - init_dma(); - if (!paused) - { - last_dma_tick = current_tick; - start_dma(); - } - - /* Tell ourselves that we need more data */ - queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); - } - } + return true; } static void mpeg_thread(void) @@ -922,9 +926,8 @@ static void mpeg_thread(void) yield(); /* Swap if necessary, and don't block on the queue_wait() */ - if(get_unswapped_space()) + if(swap_one_chunk()) { - swap_one_chunk(); queue_wait_w_tmo(&mpeg_queue, &ev, 0); } else @@ -933,6 +936,8 @@ static void mpeg_thread(void) mp3buf_read, mp3buf_write, mp3buf_swapwrite); queue_wait(&mpeg_queue, &ev); } + + start_playback_if_ready(); switch(ev.id) { |