summaryrefslogtreecommitdiff
path: root/firmware/mpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/mpeg.c')
-rw-r--r--firmware/mpeg.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/firmware/mpeg.c b/firmware/mpeg.c
index 75a8b56468..fa482593b8 100644
--- a/firmware/mpeg.c
+++ b/firmware/mpeg.c
@@ -815,6 +815,7 @@ static void mpeg_thread(void)
815 paused = false; 815 paused = false;
816 816
817 current_track_counter++; 817 current_track_counter++;
818 update_playlist();
818 break; 819 break;
819 820
820 case MPEG_STOP: 821 case MPEG_STOP:
@@ -954,30 +955,38 @@ static void mpeg_thread(void)
954 955
955 id3->elapsed = newtime; 956 id3->elapsed = newtime;
956 957
957 if (id3->vbr && (id3->vbrflags & VBR_TOC_FLAG)) 958 if (id3->vbr)
958 { 959 {
959 /* Use the TOC to find the new position */ 960 if (id3->vbrflags & VBR_TOC_FLAG)
960 unsigned int percent, remainder; 961 {
961 int curtoc, nexttoc, plen; 962 /* Use the TOC to find the new position */
962 963 unsigned int percent, remainder;
963 percent = (newtime*100)/id3->length; 964 int curtoc, nexttoc, plen;
964 if (percent > 99) 965
965 percent = 99; 966 percent = (newtime*100)/id3->length;
966 967 if (percent > 99)
967 curtoc = id3->toc[percent]; 968 percent = 99;
968 969
969 if (percent < 99) 970 curtoc = id3->toc[percent];
970 nexttoc = id3->toc[percent+1]; 971
972 if (percent < 99)
973 nexttoc = id3->toc[percent+1];
974 else
975 nexttoc = 256;
976
977 newpos = (id3->filesize/256)*curtoc;
978
979 /* Use the remainder to get a more accurate position */
980 remainder = (newtime*100)%id3->length;
981 remainder = (remainder*100)/id3->length;
982 plen = (nexttoc - curtoc)*(id3->filesize/256);
983 newpos += (plen/100)*remainder;
984 }
971 else 985 else
972 nexttoc = 256; 986 {
973 987 /* No TOC exists, estimate the new position */
974 newpos = (id3->filesize/256)*curtoc; 988 newpos = (id3->filesize/id3->length)*newtime;
975 989 }
976 /* Use the remainder to get a more accurate position */
977 remainder = (newtime*100)%id3->length;
978 remainder = (remainder*100)/id3->length;
979 plen = (nexttoc - curtoc)*(id3->filesize/256);
980 newpos += (plen/100)*remainder;
981 } 990 }
982 else if (id3->bpf && id3->tpf) 991 else if (id3->bpf && id3->tpf)
983 newpos = (newtime/id3->tpf)*id3->bpf; 992 newpos = (newtime/id3->tpf)*id3->bpf;