forked from len0rd/rockbox
Fixed ff/rew new position calculation to handle large seek positions and files. This should remove any restrictions on CBR files. VBR files can now seek to ~12 hours (TODO: remove this limit). Also fixed small bug in elapsed time calculation after resume.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2073 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
87f53249b2
commit
98cb63629b
1 changed files with 8 additions and 8 deletions
|
|
@ -286,7 +286,7 @@ static void set_elapsed(struct mp3entry* id3)
|
||||||
|
|
||||||
/* calculate remainder time */
|
/* calculate remainder time */
|
||||||
plen = (nextpos - relpos) * (id3->filesize / 256);
|
plen = (nextpos - relpos) * (id3->filesize / 256);
|
||||||
id3->elapsed += remainder * 1000 / plen ;
|
id3->elapsed += (((remainder * 100) / plen) * id3->length) / 10000;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* no TOC exists. set a rough estimate using average bitrate */
|
/* no TOC exists. set a rough estimate using average bitrate */
|
||||||
|
|
@ -921,9 +921,9 @@ static void mpeg_thread(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
case MPEG_FF_REWIND: {
|
case MPEG_FF_REWIND: {
|
||||||
struct mp3entry *id3 = mpeg_current_track();
|
struct mp3entry *id3 = mpeg_current_track();
|
||||||
int oldtime = id3->elapsed;
|
unsigned int oldtime = id3->elapsed;
|
||||||
int newtime = oldtime + (int)ev.data;
|
unsigned int newtime = oldtime + (int)ev.data;
|
||||||
int curpos, newpos, diffpos;
|
int curpos, newpos, diffpos;
|
||||||
DEBUGF("MPEG_FF_REWIND\n");
|
DEBUGF("MPEG_FF_REWIND\n");
|
||||||
|
|
||||||
|
|
@ -933,7 +933,7 @@ static void mpeg_thread(void)
|
||||||
{
|
{
|
||||||
/* Use the TOC to find the new position */
|
/* Use the TOC to find the new position */
|
||||||
unsigned int percent, remainder;
|
unsigned int percent, remainder;
|
||||||
int curtoc, nexttoc, nextpos;
|
int curtoc, nexttoc, plen;
|
||||||
|
|
||||||
percent = (newtime*100)/id3->length;
|
percent = (newtime*100)/id3->length;
|
||||||
if (percent > 99)
|
if (percent > 99)
|
||||||
|
|
@ -951,11 +951,11 @@ static void mpeg_thread(void)
|
||||||
/* Use the remainder to get a more accurate position */
|
/* Use the remainder to get a more accurate position */
|
||||||
remainder = (newtime*100)%id3->length;
|
remainder = (newtime*100)%id3->length;
|
||||||
remainder = (remainder*100)/id3->length;
|
remainder = (remainder*100)/id3->length;
|
||||||
nextpos = (id3->filesize/256)*nexttoc;
|
plen = (nexttoc - curtoc)*(id3->filesize/256);
|
||||||
newpos += ((nextpos-newpos)*remainder)/100;
|
newpos += (plen/100)*remainder;
|
||||||
}
|
}
|
||||||
else if (id3->bpf && id3->tpf)
|
else if (id3->bpf && id3->tpf)
|
||||||
newpos = (newtime*id3->bpf)/id3->tpf;
|
newpos = (newtime/id3->tpf)*id3->bpf;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Not enough information to FF/Rewind */
|
/* Not enough information to FF/Rewind */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue