diff options
-rw-r--r-- | firmware/mpeg.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index b61b5ee30b..69bc7d2ace 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -274,6 +274,7 @@ static int last_dma_chunk_size; | |||
274 | 274 | ||
275 | static bool dma_on; /* The DMA is active */ | 275 | static bool dma_on; /* The DMA is active */ |
276 | static bool playing; /* We are playing an MP3 stream */ | 276 | static bool playing; /* We are playing an MP3 stream */ |
277 | static bool play_pending; /* We are about to start playing */ | ||
277 | static bool filling; /* We are filling the buffer with data from disk */ | 278 | static bool filling; /* We are filling the buffer with data from disk */ |
278 | 279 | ||
279 | static int mpeg_file; | 280 | static int mpeg_file; |
@@ -346,17 +347,17 @@ static void stop_dma(void) | |||
346 | 347 | ||
347 | static void dma_tick(void) | 348 | static void dma_tick(void) |
348 | { | 349 | { |
349 | /* Start DMA if it isn't running */ | 350 | if(playing) |
350 | if(playing && !dma_on) | ||
351 | { | 351 | { |
352 | if(PBDR & 0x4000) | 352 | /* Start DMA if it is disabled and the DEMAND pin is high */ |
353 | if(!dma_on && (PBDR & 0x4000)) | ||
353 | { | 354 | { |
354 | if(!(SCR0 & 0x80)) | 355 | if(!(SCR0 & 0x80)) |
355 | start_dma(); | 356 | start_dma(); |
356 | } | 357 | } |
358 | id3tags[0].id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ; | ||
359 | last_dma_tick = current_tick; | ||
357 | } | 360 | } |
358 | id3tags[0].id3.elapsed += (current_tick - last_dma_tick) * 1000 / HZ; | ||
359 | last_dma_tick = current_tick; | ||
360 | } | 361 | } |
361 | 362 | ||
362 | static void bitswap(unsigned short *data, int length) | 363 | static void bitswap(unsigned short *data, int length) |
@@ -429,6 +430,7 @@ void DEI3(void) | |||
429 | { | 430 | { |
430 | DEBUGF("No more MP3 data. Stopping.\n"); | 431 | DEBUGF("No more MP3 data. Stopping.\n"); |
431 | CHCR3 = 0; /* Stop DMA interrupt */ | 432 | CHCR3 = 0; /* Stop DMA interrupt */ |
433 | playing = false; | ||
432 | } | 434 | } |
433 | } | 435 | } |
434 | 436 | ||
@@ -486,7 +488,6 @@ static void mpeg_thread(void) | |||
486 | int len; | 488 | int len; |
487 | int free_space_left; | 489 | int free_space_left; |
488 | int amount_to_read; | 490 | int amount_to_read; |
489 | bool play_pending; | ||
490 | 491 | ||
491 | play_pending = false; | 492 | play_pending = false; |
492 | playing = false; | 493 | playing = false; |
@@ -653,6 +654,7 @@ static void mpeg_thread(void) | |||
653 | play_pending = false; | 654 | play_pending = false; |
654 | playing = true; | 655 | playing = true; |
655 | 656 | ||
657 | last_dma_tick = current_tick; | ||
656 | init_dma(); | 658 | init_dma(); |
657 | start_dma(); | 659 | start_dma(); |
658 | } | 660 | } |
@@ -794,6 +796,11 @@ void mpeg_prev(void) | |||
794 | #endif | 796 | #endif |
795 | } | 797 | } |
796 | 798 | ||
799 | bool mpeg_is_playing(void) | ||
800 | { | ||
801 | return playing || play_pending; | ||
802 | } | ||
803 | |||
797 | #ifndef SIMULATOR | 804 | #ifndef SIMULATOR |
798 | #ifndef ARCHOS_RECORDER | 805 | #ifndef ARCHOS_RECORDER |
799 | int current_volume=0; /* all values in tenth of dB */ | 806 | int current_volume=0; /* all values in tenth of dB */ |