summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2002-08-28 10:21:32 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2002-08-28 10:21:32 +0000
commitccfef0480b4e99e910703867e70d6c8a5a00389f (patch)
treea63ac7965cf3e73c65645b40f2a5a004085b6feb /firmware
parent7bf657a7db4dfb0ace9ed0722c864516c3cfab45 (diff)
downloadrockbox-ccfef0480b4e99e910703867e70d6c8a5a00389f.tar.gz
rockbox-ccfef0480b4e99e910703867e70d6c8a5a00389f.zip
First attempt to use the new playlist API
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2024 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware')
-rw-r--r--firmware/mpeg.c22
1 files changed, 18 insertions, 4 deletions
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
57extern char* playlist_next(int steps, int* id); 57extern char* playlist_peek(int steps);
58extern int playlist_next(int steps);
58extern void update_file_pos( int id, int pos ); 59extern void update_file_pos( int id, int pos );
59 60
60static char *units[] = 61static char *units[] =
@@ -418,6 +419,7 @@ static int last_dma_chunk_size;
418static bool dma_on; /* The DMA is active */ 419static bool dma_on; /* The DMA is active */
419static bool playing; /* We are playing an MP3 stream */ 420static bool playing; /* We are playing an MP3 stream */
420static bool play_pending; /* We are about to start playing */ 421static bool play_pending; /* We are about to start playing */
422static bool is_playing; /* We are (attempting to) playing MP3 files */
421static bool filling; /* We are filling the buffer with data from disk */ 423static bool filling; /* We are filling the buffer with data from disk */
422 424
423static int mpeg_file; 425static 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
1285void mpeg_play(int offset) 1297void 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
1398bool mpeg_is_playing(void) 1412bool 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