summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-12-05 14:11:48 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-12-05 14:11:48 +0000
commitd29248d992b65e71976bd46b9c4697a89d1bec4d (patch)
treef163666e7f177f6e0047f6566dec3286d7298eb8
parent49d2190bd0fa6def5f0c131f48db610e8c6533dd (diff)
More fine-tuned buffer handling, and better debug info
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2948 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/debug_menu.c4
-rw-r--r--firmware/mpeg.c34
-rw-r--r--firmware/mpeg.h2
3 files changed, 26 insertions, 14 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 76c8662d92..4c1c9893cb 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -166,12 +166,12 @@ bool dbg_mpeg_thread(void)
lcd_puts(0, 2, buf);
snprintf(buf, sizeof(buf), "playing: %d", d.playing);
lcd_puts(0, 3, buf);
- snprintf(buf, sizeof(buf), "unplayed: %x", d.unplayed_space);
+ snprintf(buf, sizeof(buf), "playable: %x", d.playable_space);
lcd_puts(0, 4, buf);
snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space);
lcd_puts(0, 5, buf);
- percent = d.unplayed_space * 100 / d.mp3buflen;
+ percent = d.playable_space * 100 / d.mp3buflen;
progressbar(0, 6*8, 112, 4, percent, Grow_Right);
percent = d.low_watermark_level * 100 / d.mp3buflen;
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 400a702c33..c95a8c3510 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -47,6 +47,7 @@ static void stop_recording(void);
#ifndef SIMULATOR
static int get_unplayed_space(void);
+static int get_playable_space(void);
static int get_unswapped_space(void);
#endif
@@ -493,7 +494,7 @@ static void recalculate_watermark(int bitrate)
{
if(ata_spinup_time)
{
- low_watermark = (low_watermark_margin + ata_spinup_time * 3 / HZ) *
+ low_watermark = (low_watermark_margin + ata_spinup_time * 2 / HZ) *
bitrate*1000 / 8;
}
else
@@ -524,6 +525,7 @@ void mpeg_get_debugdata(struct mpeg_debug *dbgdata)
dbgdata->dma_underrun = dma_underrun;
dbgdata->unplayed_space = get_unplayed_space();
+ dbgdata->playable_space = get_playable_space();
dbgdata->unswapped_space = get_unswapped_space();
dbgdata->low_watermark_level = low_watermark;
@@ -593,6 +595,14 @@ static int get_unplayed_space(void)
return space;
}
+static int get_playable_space(void)
+{
+ int space = mp3buf_swapwrite - mp3buf_read;
+ if (space < 0)
+ space += mp3buflen;
+ return space;
+}
+
static int get_unplayed_space_current_song(void)
{
int space;
@@ -861,6 +871,10 @@ void DEI3(void)
DTCR3 = last_dma_chunk_size & 0xffff;
SAR3 = (unsigned int)mp3buf + mp3buf_read;
id3tags[tag_read_idx]->id3.offset += last_dma_chunk_size;
+
+ /* Update the watermark debug level */
+ if(unplayed_space_left < lowest_watermark_level)
+ lowest_watermark_level = unplayed_space_left;
}
else
{
@@ -870,6 +884,11 @@ void DEI3(void)
closed. */
if(mpeg_file >= 0)
{
+
+ /* Update the watermark debug level */
+ if(unplayed_space_left < lowest_watermark_level)
+ lowest_watermark_level = unplayed_space_left;
+
DEBUGF("DMA underrun.\n");
dma_underrun = true;
}
@@ -883,10 +902,6 @@ void DEI3(void)
}
CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
}
-
- /* Update the watermark debug level */
- if(unplayed_space_left < lowest_watermark_level)
- lowest_watermark_level = unplayed_space_left;
}
CHCR3 &= ~0x0002; /* Clear DMA interrupt */
@@ -1128,12 +1143,7 @@ static bool swap_one_chunk(void)
{
int free_space_left;
int amount_to_swap;
- int playable_space;
- playable_space = mp3buf_swapwrite - mp3buf_read;
- if(playable_space < 0)
- playable_space += mp3buflen;
-
free_space_left = get_unswapped_space();
if(free_space_left == 0 && !play_pending)
@@ -1141,8 +1151,8 @@ static bool swap_one_chunk(void)
/* Swap in larger chunks when the user is waiting for the playback
to start, or when there is dangerously little playable data left */
- if(play_pending || playable_space < MPEG_LOW_WATER_CHUNKSIZE)
- amount_to_swap = MIN(MPEG_LOW_WATER_CHUNKSIZE, free_space_left);
+ if(play_pending || get_playable_space() < MPEG_LOW_WATER_SWAP_CHUNKSIZE)
+ amount_to_swap = MIN(MPEG_LOW_WATER_SWAP_CHUNKSIZE, free_space_left);
else
amount_to_swap = MIN(MPEG_SWAP_CHUNKSIZE, free_space_left);
diff --git a/firmware/mpeg.h b/firmware/mpeg.h
index 5b3c32819a..2494ae629d 100644
--- a/firmware/mpeg.h
+++ b/firmware/mpeg.h
@@ -27,6 +27,7 @@
an empty buffer and a full one. */
#define MPEG_LOW_WATER 0x60000
#define MPEG_LOW_WATER_CHUNKSIZE 0x40000
+#define MPEG_LOW_WATER_SWAP_CHUNKSIZE 0x10000
struct mpeg_debug
{
@@ -45,6 +46,7 @@ struct mpeg_debug
bool dma_underrun;
int unplayed_space;
+ int playable_space;
int unswapped_space;
int low_watermark_level;