summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHardeep Sidhu <dyp@pobox.com>2002-08-22 23:01:25 +0000
committerHardeep Sidhu <dyp@pobox.com>2002-08-22 23:01:25 +0000
commit754651efdda04556a605f0db62cd1d92bdfbd46b (patch)
treeb479359bb32974956213aeeed684c1c0e0d2c1ef
parent634551ffeb2734b863cc1b3db20302c57c155c2d (diff)
downloadrockbox-754651efdda04556a605f0db62cd1d92bdfbd46b.tar.gz
rockbox-754651efdda04556a605f0db62cd1d92bdfbd46b.zip
Reset mp3buf_swapwrite when selecting next track that is already in buffer. This should fix the track silence bug. Also, when seeking to end of file, leave some bytes at the end so that the transition to the next track is done correctly. This should fix the few seconds repeat at beginning of next song.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@1934 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/mpeg.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 2e3080f47d..17d92c25fb 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -794,23 +794,33 @@ static void mpeg_thread(void)
794 794
795 /* is next track in ram? */ 795 /* is next track in ram? */
796 if ( num_tracks_in_memory() > 1 ) { 796 if ( num_tracks_in_memory() > 1 ) {
797 int track_offset = (tag_read_idx+1) & MAX_ID3_TAGS_MASK; 797 int unplayed_space_left, unswapped_space_left;
798 mp3buf_read = id3tags[track_offset]->mempos; 798
799 track_change();
800 mp3buf_read = id3tags[tag_read_idx]->mempos;
799 init_dma(); 801 init_dma();
800 last_dma_tick = current_tick; 802 last_dma_tick = current_tick;
801 803
804 unplayed_space_left = get_unplayed_space();
805 unswapped_space_left = mp3buf_write - mp3buf_swapwrite;
806 if (unswapped_space_left < 0)
807 unswapped_space_left += mp3buflen;
808
802 /* should we start reading more data? */ 809 /* should we start reading more data? */
803 if(!filling && (get_unplayed_space() < MPEG_LOW_WATER)) { 810 if(!filling && (unplayed_space_left < MPEG_LOW_WATER)) {
804 filling = true; 811 filling = true;
805 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0); 812 queue_post(&mpeg_queue, MPEG_NEED_DATA, 0);
806 play_pending = true; 813 play_pending = true;
814 } else if(unswapped_space_left &&
815 unswapped_space_left > unplayed_space_left) {
816 /* Stop swapping the data from the previous file */
817 mp3buf_swapwrite = mp3buf_read;
818 play_pending = true;
807 } else { 819 } else {
808 playing = true; 820 playing = true;
809 if (!paused) 821 if (!paused)
810 start_dma(); 822 start_dma();
811 } 823 }
812
813 track_change();
814 } 824 }
815 else { 825 else {
816 reset_mp3_buffer(); 826 reset_mp3_buffer();
@@ -904,6 +914,11 @@ static void mpeg_thread(void)
904 /* Not enough information to FF/Rewind */ 914 /* Not enough information to FF/Rewind */
905 break; 915 break;
906 916
917 /* Don't seek right to the end of the file so that we can
918 transition properly to the next song */
919 if (newpos >= (int)(id3->filesize - id3->id3v1len))
920 newpos = id3->filesize - id3->id3v1len - 1;
921
907 newpos = newpos & ~1; 922 newpos = newpos & ~1;
908 curpos = lseek(mpeg_file, 0, SEEK_CUR); 923 curpos = lseek(mpeg_file, 0, SEEK_CUR);
909 924