summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-22 12:32:28 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2008-05-22 12:32:28 +0000
commit5670ca18bbe4e98b5560b2504e0fa56b92be5ab4 (patch)
tree1c843e4434b4a844e98f94df80afb853a9e04049 /apps
parente1e0bc267549e098c5a1ce9383e3390a954a3c5c (diff)
downloadrockbox-5670ca18bbe4e98b5560b2504e0fa56b92be5ab4.tar.gz
rockbox-5670ca18bbe4e98b5560b2504e0fa56b92be5ab4.zip
Fixes backward seeking on resumed files and backward seeking to positions to which formerly was seeked forward to (sounds complicated and it is).
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17606 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r--apps/codecs/libmusepack/mpc_decoder.c20
1 files changed, 13 insertions, 7 deletions
diff --git a/apps/codecs/libmusepack/mpc_decoder.c b/apps/codecs/libmusepack/mpc_decoder.c
index f6aab66494..08a491ea3e 100644
--- a/apps/codecs/libmusepack/mpc_decoder.c
+++ b/apps/codecs/libmusepack/mpc_decoder.c
@@ -1609,18 +1609,15 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample)
// seek to the first frame
mpc_decoder_seek_to(d, fpos);
- // reset number of decoded frames
- d->DecodedFrames = 0;
-
// jump to the last frame via parsing, updating seek table
d->SeekTable[0] = (mpc_uint32_t)fpos;
- d->SeekTableCounter = d->SeekTable[0];
- for (d->DecodedFrames = 1; d->DecodedFrames < lastFrame; d->DecodedFrames++)
+ d->SeekTableCounter = 0;
+ for (d->DecodedFrames = 0; d->DecodedFrames < lastFrame; d->DecodedFrames++)
{
d->SeekTableCounter += mpc_decoder_jump_frame(d);
- if (0 == (d->DecodedFrames % d->SeekTable_Step))
+ if (0 == ((d->DecodedFrames+1) % d->SeekTable_Step))
{
- d->SeekTable[d->DecodedFrames/d->SeekTable_Step] = d->SeekTableCounter;
+ d->SeekTable[(d->DecodedFrames+1)/d->SeekTable_Step] = d->SeekTableCounter;
d->MaxDecodedFrames = d->DecodedFrames;
d->SeekTableCounter = 0;
}
@@ -1702,6 +1699,15 @@ mpc_bool_t mpc_decoder_seek_sample(mpc_decoder *d, mpc_int64_t destsample)
else if (FrameBitCnt != d->FwdJumpInfo )
// Bug in perform_jump;
return FALSE;
+
+ // update seek table, if there new entries to fill
+ d->SeekTableCounter += d->FwdJumpInfo + 20;
+ if (0 == (d->DecodedFrames+1) % d->SeekTable_Step)
+ {
+ d->SeekTable[(d->DecodedFrames+1)/d->SeekTable_Step] = d->SeekTableCounter;
+ d->MaxDecodedFrames = d->DecodedFrames;
+ d->SeekTableCounter = 0;
+ }
// update buffer
mpc_decoder_update_buffer(d);