summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-10-09 09:15:28 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-10-09 09:15:28 +0000
commit26e7ec47870f6287d7efbecd0499034b9073381e (patch)
tree19d65c8576fd4d1652bc257a231e6683d6f1aaee
parent746501f552b2aebe113ba2116f5beb03494ae9cb (diff)
downloadrockbox-26e7ec47870f6287d7efbecd0499034b9073381e.tar.gz
rockbox-26e7ec47870f6287d7efbecd0499034b9073381e.zip
Buffer underrun handling
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2544 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/mpeg.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 05cf79ca79..884ba87a71 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -54,6 +54,7 @@ extern void bitswap(unsigned char *data, int length);
54#define MPEG_NEED_DATA 100 54#define MPEG_NEED_DATA 100
55#define MPEG_SWAP_DATA 101 55#define MPEG_SWAP_DATA 101
56#define MPEG_TRACK_CHANGE 102 56#define MPEG_TRACK_CHANGE 102
57#define MPEG_DMA_UNDERRUN 103
57 58
58extern char* playlist_peek(int steps); 59extern char* playlist_peek(int steps);
59extern int playlist_next(int steps); 60extern int playlist_next(int steps);
@@ -440,7 +441,7 @@ static void mas_poll_start(int interval_in_ms)
440{ 441{
441 unsigned int count; 442 unsigned int count;
442 443
443 count = FREQ / 1000 / 8 * interval_in_ms; 444 count = (FREQ * interval_in_ms) / 1000 / 8;
444 445
445 if(count > 0xffff) 446 if(count > 0xffff)
446 { 447 {
@@ -639,10 +640,17 @@ void DEI3(void)
639 else 640 else
640 { 641 {
641 DEBUGF("No more MP3 data. Stopping.\n"); 642 DEBUGF("No more MP3 data. Stopping.\n");
642 queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0); 643
643 CHCR3 = 0; /* Stop DMA interrupt */ 644 /* Check if the end of data is because of a hard disk error */
644 playing = false; 645 if(filling)
645 is_playing = false; 646 queue_post(&mpeg_queue, MPEG_DMA_UNDERRUN, 0);
647 else
648 {
649 queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0);
650 playing = false;
651 is_playing = false;
652 }
653 CHCR3 &= ~0x0001; /* Disable the DMA interrupt */
646 } 654 }
647 } 655 }
648 656
@@ -1357,6 +1365,10 @@ static void mpeg_thread(void)
1357 track_change(); 1365 track_change();
1358 break; 1366 break;
1359 1367
1368 case MPEG_DMA_UNDERRUN:
1369 CHCR3 |= 0x0001; /* Enable the DMA interrupt */
1370 break;
1371
1360 case SYS_USB_CONNECTED: 1372 case SYS_USB_CONNECTED:
1361 stop_playing(); 1373 stop_playing();
1362#ifndef SIMULATOR 1374#ifndef SIMULATOR