diff options
-rw-r--r-- | apps/wps.c | 8 | ||||
-rw-r--r-- | firmware/mpeg.c | 22 |
2 files changed, 24 insertions, 6 deletions
diff --git a/apps/wps.c b/apps/wps.c index 7f54d1afa7..37f849de91 100644 --- a/apps/wps.c +++ b/apps/wps.c | |||
@@ -722,7 +722,8 @@ int wps_show(void) | |||
722 | if(mpeg_is_playing()) | 722 | if(mpeg_is_playing()) |
723 | { | 723 | { |
724 | id3 = mpeg_current_track(); | 724 | id3 = mpeg_current_track(); |
725 | draw_screen(id3); | 725 | // draw_screen(id3); |
726 | restore = true; | ||
726 | } | 727 | } |
727 | 728 | ||
728 | while ( 1 ) | 729 | while ( 1 ) |
@@ -1216,7 +1217,10 @@ int wps_show(void) | |||
1216 | } | 1217 | } |
1217 | #endif | 1218 | #endif |
1218 | case BUTTON_NONE: /* Timeout */ | 1219 | case BUTTON_NONE: /* Timeout */ |
1219 | if (mpeg_is_playing() && id3) | 1220 | if(!mpeg_is_playing()) |
1221 | restore = true; | ||
1222 | |||
1223 | if (id3) | ||
1220 | display_file_time(id3->elapsed, id3->length); | 1224 | display_file_time(id3->elapsed, id3->length); |
1221 | 1225 | ||
1222 | /* save resume data */ | 1226 | /* save resume data */ |
diff --git a/firmware/mpeg.c b/firmware/mpeg.c index 2505b38561..8700745a53 100644 --- a/firmware/mpeg.c +++ b/firmware/mpeg.c | |||
@@ -54,7 +54,8 @@ extern void bitswap(unsigned short *data, int length); | |||
54 | #define MPEG_SWAP_DATA 101 | 54 | #define MPEG_SWAP_DATA 101 |
55 | #define MPEG_TRACK_CHANGE 102 | 55 | #define MPEG_TRACK_CHANGE 102 |
56 | 56 | ||
57 | extern char* playlist_next(int steps, int* id); | 57 | extern char* playlist_peek(int steps); |
58 | extern int playlist_next(int steps); | ||
58 | extern void update_file_pos( int id, int pos ); | 59 | extern void update_file_pos( int id, int pos ); |
59 | 60 | ||
60 | static char *units[] = | 61 | static char *units[] = |
@@ -418,6 +419,7 @@ static int last_dma_chunk_size; | |||
418 | static bool dma_on; /* The DMA is active */ | 419 | static bool dma_on; /* The DMA is active */ |
419 | static bool playing; /* We are playing an MP3 stream */ | 420 | static bool playing; /* We are playing an MP3 stream */ |
420 | static bool play_pending; /* We are about to start playing */ | 421 | static bool play_pending; /* We are about to start playing */ |
422 | static bool is_playing; /* We are (attempting to) playing MP3 files */ | ||
421 | static bool filling; /* We are filling the buffer with data from disk */ | 423 | static bool filling; /* We are filling the buffer with data from disk */ |
422 | 424 | ||
423 | static int mpeg_file; | 425 | static int mpeg_file; |
@@ -599,6 +601,7 @@ void DEI3(void) | |||
599 | queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0); | 601 | queue_post(&mpeg_queue, MPEG_TRACK_CHANGE, 0); |
600 | CHCR3 = 0; /* Stop DMA interrupt */ | 602 | CHCR3 = 0; /* Stop DMA interrupt */ |
601 | playing = false; | 603 | playing = false; |
604 | is_playing = false; | ||
602 | } | 605 | } |
603 | } | 606 | } |
604 | 607 | ||
@@ -652,7 +655,7 @@ static int new_file(int steps) | |||
652 | char *trackname; | 655 | char *trackname; |
653 | int index; | 656 | int index; |
654 | 657 | ||
655 | trackname = playlist_next( steps, &index ); | 658 | trackname = playlist_peek( steps ); |
656 | if ( !trackname ) | 659 | if ( !trackname ) |
657 | return -1; | 660 | return -1; |
658 | 661 | ||
@@ -661,10 +664,14 @@ static int new_file(int steps) | |||
661 | mpeg_file = open(trackname, O_RDONLY); | 664 | mpeg_file = open(trackname, O_RDONLY); |
662 | if(mpeg_file < 0) { | 665 | if(mpeg_file < 0) { |
663 | DEBUGF("Couldn't open file: %s\n",trackname); | 666 | DEBUGF("Couldn't open file: %s\n",trackname); |
667 | steps++; | ||
664 | } | 668 | } |
665 | else | 669 | else |
666 | { | 670 | { |
667 | int new_tag_idx = tag_write_idx; | 671 | int new_tag_idx = tag_write_idx; |
672 | |||
673 | index = playlist_next(steps); | ||
674 | |||
668 | add_track_to_tag_list(trackname); | 675 | add_track_to_tag_list(trackname); |
669 | /* skip past id3v2 tag (to an even byte) */ | 676 | /* skip past id3v2 tag (to an even byte) */ |
670 | lseek(mpeg_file, | 677 | lseek(mpeg_file, |
@@ -716,6 +723,7 @@ static void mpeg_thread(void) | |||
716 | int t1, t2; | 723 | int t1, t2; |
717 | int start_offset; | 724 | int start_offset; |
718 | 725 | ||
726 | is_playing = false; | ||
719 | play_pending = false; | 727 | play_pending = false; |
720 | playing = false; | 728 | playing = false; |
721 | mpeg_file = -1; | 729 | mpeg_file = -1; |
@@ -742,7 +750,10 @@ static void mpeg_thread(void) | |||
742 | close(mpeg_file); | 750 | close(mpeg_file); |
743 | 751 | ||
744 | if ( new_file(0) == -1 ) | 752 | if ( new_file(0) == -1 ) |
745 | return; | 753 | { |
754 | is_playing = false; | ||
755 | break; | ||
756 | } | ||
746 | 757 | ||
747 | start_offset = (int)ev.data; | 758 | start_offset = (int)ev.data; |
748 | 759 | ||
@@ -775,6 +786,7 @@ static void mpeg_thread(void) | |||
775 | 786 | ||
776 | case MPEG_STOP: | 787 | case MPEG_STOP: |
777 | DEBUGF("MPEG_STOP\n"); | 788 | DEBUGF("MPEG_STOP\n"); |
789 | is_playing = false; | ||
778 | stop_playing(); | 790 | stop_playing(); |
779 | break; | 791 | break; |
780 | 792 | ||
@@ -1284,6 +1296,8 @@ bool mpeg_has_changed_track(void) | |||
1284 | 1296 | ||
1285 | void mpeg_play(int offset) | 1297 | void mpeg_play(int offset) |
1286 | { | 1298 | { |
1299 | is_playing = true; | ||
1300 | |||
1287 | #ifdef SIMULATOR | 1301 | #ifdef SIMULATOR |
1288 | char* trackname; | 1302 | char* trackname; |
1289 | int steps=0; | 1303 | int steps=0; |
@@ -1397,7 +1411,7 @@ void mpeg_ff_rewind(int change) | |||
1397 | 1411 | ||
1398 | bool mpeg_is_playing(void) | 1412 | bool mpeg_is_playing(void) |
1399 | { | 1413 | { |
1400 | return playing || play_pending || paused; | 1414 | return is_playing; |
1401 | } | 1415 | } |
1402 | 1416 | ||
1403 | #ifndef SIMULATOR | 1417 | #ifndef SIMULATOR |