diff options
| author | Linus Nielsen Feltzing <linus@haxx.se> | 2002-10-09 09:15:28 +0000 |
|---|---|---|
| committer | Linus Nielsen Feltzing <linus@haxx.se> | 2002-10-09 09:15:28 +0000 |
| commit | 26e7ec47870f6287d7efbecd0499034b9073381e (patch) | |
| tree | 19d65c8576fd4d1652bc257a231e6683d6f1aaee | |
| parent | 746501f552b2aebe113ba2116f5beb03494ae9cb (diff) | |
| download | rockbox-26e7ec47870f6287d7efbecd0499034b9073381e.zip rockbox-26e7ec47870f6287d7efbecd0499034b9073381e.tar.gz rockbox-26e7ec47870f6287d7efbecd0499034b9073381e.tar.bz2 rockbox-26e7ec47870f6287d7efbecd0499034b9073381e.tar.xz | |
Buffer underrun handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2544 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/mpeg.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 05cf79c..884ba87 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c @@ -54,6 +54,7 @@ extern void bitswap(unsigned char *data, int length); #define MPEG_NEED_DATA 100 #define MPEG_SWAP_DATA 101 #define MPEG_TRACK_CHANGE 102 +#define MPEG_DMA_UNDERRUN 103 extern char* playlist_peek(int steps); extern int playlist_next(int steps); @@ -440,7 +441,7 @@ static void mas_poll_start(int interval_in_ms) { unsigned int count; - count = FREQ / 1000 / 8 * interval_in_ms; + count = (FREQ * interval_in_ms) / 1000 / 8; if(count > 0xffff) { @@ -639,10 +640,17 @@ void DEI3(void) else { DEBUGF("No more MP3 data. Stopping.\n"); - queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0); - CHCR3 = 0; /* Stop DMA interrupt */ - playing = false; - is_playing = false; + + /* Check if the end of data is because of a hard disk error */ + if(filling) + queue_post(&mpeg_queue, MPEG_DMA_UNDERRUN, 0); + else + { + queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0); + playing = false; + is_playing = false; + } + CHCR3 &= ~0x0001; /* Disable the DMA interrupt */ } } @@ -1357,6 +1365,10 @@ static void mpeg_thread(void) track_change(); break; + case MPEG_DMA_UNDERRUN: + CHCR3 |= 0x0001; /* Enable the DMA interrupt */ + break; + case SYS_USB_CONNECTED: stop_playing(); #ifndef SIMULATOR |