diff options
-rw-r--r-- | apps/debug_menu.c | 13 | ||||
-rw-r--r-- | firmware/mpeg.c | 17 | ||||
-rw-r--r-- | firmware/mpeg.h | 9 |
3 files changed, 31 insertions, 8 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 9f71d14156..af8853d93c 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c | |||
@@ -38,6 +38,7 @@ | |||
38 | #include "font.h" | 38 | #include "font.h" |
39 | #include "disk.h" | 39 | #include "disk.h" |
40 | #include "mpeg.h" | 40 | #include "mpeg.h" |
41 | #include "widgets.h" | ||
41 | 42 | ||
42 | /*---------------------------------------------------*/ | 43 | /*---------------------------------------------------*/ |
43 | /* SPECIAL DEBUG STUFF */ | 44 | /* SPECIAL DEBUG STUFF */ |
@@ -137,8 +138,11 @@ bool dbg_mpeg_thread(void) | |||
137 | { | 138 | { |
138 | char buf[32]; | 139 | char buf[32]; |
139 | int button; | 140 | int button; |
141 | int percent; | ||
140 | struct mpeg_debug d; | 142 | struct mpeg_debug d; |
141 | 143 | ||
144 | lcd_setmargins(0, 0); | ||
145 | |||
142 | while(1) | 146 | while(1) |
143 | { | 147 | { |
144 | button = button_get_w_tmo(HZ/5); | 148 | button = button_get_w_tmo(HZ/5); |
@@ -164,6 +168,15 @@ bool dbg_mpeg_thread(void) | |||
164 | lcd_puts(0, 4, buf); | 168 | lcd_puts(0, 4, buf); |
165 | snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space); | 169 | snprintf(buf, sizeof(buf), "unswapped: %x", d.unswapped_space); |
166 | lcd_puts(0, 5, buf); | 170 | lcd_puts(0, 5, buf); |
171 | |||
172 | percent = d.unplayed_space * 100 / d.mp3buflen; | ||
173 | progressbar(0, 6*8, 112, 4, percent, Grow_Right); | ||
174 | |||
175 | percent = MPEG_LOW_WATER * 100 / d.mp3buflen; | ||
176 | progressbar(0, 6*8+4, 112, 4, percent, Grow_Right); | ||
177 | |||
178 | snprintf(buf, sizeof(buf), "lowest: %x", d.lowest_watermark_level); | ||
179 | lcd_puts(0, 7, buf); | ||
167 | 180 | ||
168 | lcd_update(); | 181 | lcd_update(); |
169 | } | 182 | } |
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index d7e7acbf92..9937c3be47 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -40,13 +40,6 @@ extern void bitswap(unsigned char *data, int length); | |||
40 | static int get_unplayed_space(void); | 40 | static int get_unplayed_space(void); |
41 | static int get_unswapped_space(void); | 41 | static int get_unswapped_space(void); |
42 | 42 | ||
43 | #define MPEG_SWAP_CHUNKSIZE 0x2000 | ||
44 | #define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we | ||
45 | wouldn't be able to see the difference between | ||
46 | an empty buffer and a full one. */ | ||
47 | #define MPEG_LOW_WATER 0x40000 | ||
48 | #define MPEG_LOW_WATER_CHUNKSIZE 0x40000 | ||
49 | |||
50 | #define MPEG_PLAY 1 | 43 | #define MPEG_PLAY 1 |
51 | #define MPEG_STOP 2 | 44 | #define MPEG_STOP 2 |
52 | #define MPEG_PAUSE 3 | 45 | #define MPEG_PAUSE 3 |
@@ -439,7 +432,8 @@ static bool is_playing; /* We are (attempting to) playing MP3 files */ | |||
439 | static bool filling; /* We are filling the buffer with data from disk */ | 432 | static bool filling; /* We are filling the buffer with data from disk */ |
440 | static bool dma_underrun; /* True when the DMA has stopped because of | 433 | static bool dma_underrun; /* True when the DMA has stopped because of |
441 | slow disk reading (read error, shaking) */ | 434 | slow disk reading (read error, shaking) */ |
442 | 435 | static int lowest_watermark_level; /* Debug value to observe the buffer | |
436 | usage */ | ||
443 | static int mpeg_file; | 437 | static int mpeg_file; |
444 | 438 | ||
445 | void mpeg_get_debugdata(struct mpeg_debug *dbgdata) | 439 | void mpeg_get_debugdata(struct mpeg_debug *dbgdata) |
@@ -460,6 +454,8 @@ void mpeg_get_debugdata(struct mpeg_debug *dbgdata) | |||
460 | 454 | ||
461 | dbgdata->unplayed_space = get_unplayed_space(); | 455 | dbgdata->unplayed_space = get_unplayed_space(); |
462 | dbgdata->unswapped_space = get_unswapped_space(); | 456 | dbgdata->unswapped_space = get_unswapped_space(); |
457 | |||
458 | dbgdata->lowest_watermark_level = lowest_watermark_level; | ||
463 | } | 459 | } |
464 | 460 | ||
465 | static void mas_poll_start(int interval_in_ms) | 461 | static void mas_poll_start(int interval_in_ms) |
@@ -598,6 +594,7 @@ static void reset_mp3_buffer(void) | |||
598 | mp3buf_read = 0; | 594 | mp3buf_read = 0; |
599 | mp3buf_write = 0; | 595 | mp3buf_write = 0; |
600 | mp3buf_swapwrite = 0; | 596 | mp3buf_swapwrite = 0; |
597 | lowest_watermark_level = mp3buflen; | ||
601 | } | 598 | } |
602 | 599 | ||
603 | #pragma interrupt | 600 | #pragma interrupt |
@@ -662,6 +659,10 @@ void DEI3(void) | |||
662 | DTCR3 = last_dma_chunk_size & 0xffff; | 659 | DTCR3 = last_dma_chunk_size & 0xffff; |
663 | SAR3 = (unsigned int)mp3buf + mp3buf_read; | 660 | SAR3 = (unsigned int)mp3buf + mp3buf_read; |
664 | id3tags[tag_read_idx]->id3.offset += last_dma_chunk_size; | 661 | id3tags[tag_read_idx]->id3.offset += last_dma_chunk_size; |
662 | |||
663 | /* Update the watermark debug level */ | ||
664 | if(unplayed_space_left < lowest_watermark_level) | ||
665 | lowest_watermark_level = unplayed_space_left; | ||
665 | } | 666 | } |
666 | else | 667 | else |
667 | { | 668 | { |
diff --git a/firmware/mpeg.h b/firmware/mpeg.h index 97a1b36c1a..02c5e814a2 100644 --- a/firmware/mpeg.h +++ b/firmware/mpeg.h | |||
@@ -21,6 +21,13 @@ | |||
21 | 21 | ||
22 | #include <stdbool.h> | 22 | #include <stdbool.h> |
23 | 23 | ||
24 | #define MPEG_SWAP_CHUNKSIZE 0x2000 | ||
25 | #define MPEG_HIGH_WATER 2 /* We leave 2 bytes empty because otherwise we | ||
26 | wouldn't be able to see the difference between | ||
27 | an empty buffer and a full one. */ | ||
28 | #define MPEG_LOW_WATER 0x40000 | ||
29 | #define MPEG_LOW_WATER_CHUNKSIZE 0x40000 | ||
30 | |||
24 | struct mpeg_debug | 31 | struct mpeg_debug |
25 | { | 32 | { |
26 | int mp3buflen; | 33 | int mp3buflen; |
@@ -39,6 +46,8 @@ struct mpeg_debug | |||
39 | 46 | ||
40 | int unplayed_space; | 47 | int unplayed_space; |
41 | int unswapped_space; | 48 | int unswapped_space; |
49 | |||
50 | int lowest_watermark_level; | ||
42 | }; | 51 | }; |
43 | 52 | ||
44 | void mpeg_init(int volume, int bass, int treble, int balance, | 53 | void mpeg_init(int volume, int bass, int treble, int balance, |