summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-08-15 16:48:34 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-08-15 16:48:34 +0000
commit749d87bb20dd3a7a26e33636b0f7a99055f2a68a (patch)
tree0d645b63ba88c3353e10077fb157c6231f3b286d /firmware/mpeg.c
parentcb6bafd1f259d7a0e440993aa168b13c985f0503 (diff)
Correction for fast-forward/rewind
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1769 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 784c9010c0..92ef55983b 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -451,7 +451,28 @@ static int get_unplayed_space(void)
{
int space = mp3buf_write - mp3buf_read;
if (space < 0)
- space = mp3buflen + space;
+ space += mp3buflen;
+ return space;
+}
+
+static int get_unplayed_space_current_song(void)
+{
+ int space;
+
+ if (num_tracks_in_memory() > 1)
+ {
+ int track_offset = (tag_read_idx+1) & MAX_ID3_TAGS_MASK;
+
+ space = id3tags[track_offset]->mempos - mp3buf_read;
+ }
+ else
+ {
+ space = mp3buf_write - mp3buf_read;
+ }
+
+ if (space < 0)
+ space += mp3buflen;
+
return space;
}
@@ -461,7 +482,7 @@ static void init_dma(void)
DAR3 = 0x5FFFEC3;
CHCR3 &= ~0x0002; /* Clear interrupt */
CHCR3 = 0x1504; /* Single address destination, TXI0, IE=1 */
- last_dma_chunk_size = MIN(65536, get_unplayed_space());
+ last_dma_chunk_size = MIN(65536, get_unplayed_space_current_song());
DTCR3 = last_dma_chunk_size & 0xffff;
DMAOR = 0x0001; /* Enable DMA */
CHCR3 |= 0x0001; /* Enable DMA IRQ */