summaryrefslogtreecommitdiff
path: root/apps/codecs/mpc.c
diff options
context:
space:
mode:
authorAdam Boot <rotator@gmail.com>2007-04-06 21:48:17 +0000
committerAdam Boot <rotator@gmail.com>2007-04-06 21:48:17 +0000
commita5d7309d96cca974e1524dc746482ab2a26d7395 (patch)
tree8d835f98b75c7abd46f1c0b430b390b4c269f10f /apps/codecs/mpc.c
parent8527ce82b651b20f2f3406a9b95c4948e8c7dddf (diff)
Support resume for Musepack
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13049 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/mpc.c')
-rw-r--r--apps/codecs/mpc.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c
index fe22c8cccb..122cb22025 100644
--- a/apps/codecs/mpc.c
+++ b/apps/codecs/mpc.c
@@ -100,6 +100,8 @@ next_track:
goto exit;
}
+ samplesdone = ci->id3->offset;
+
/* read file's streaminfo data */
mpc_streaminfo_init(&info);
if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) {
@@ -128,9 +130,21 @@ next_track:
retval = CODEC_ERROR;
goto done;
}
+
+ /* Resume to saved sample offset. */
+ if(samplesdone > 0) {
+ /* hack to improve seek time if filebuf goes empty */
+ ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, 1024*512);
+ if (mpc_decoder_seek_sample(&decoder, samplesdone)) {
+ ci->set_elapsed(samplesdone/frequency);
+ } else {
+ samplesdone = 0;
+ }
+ /* reset chunksize */
+ ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, 1024*16);
+ }
/* This is the decoding loop. */
- samplesdone = 0;
do {
#if 1
/* Complete seek handler. */
@@ -173,6 +187,7 @@ next_track:
status);
samplesdone += status;
ci->set_elapsed(samplesdone/frequency);
+ ci->set_offset(samplesdone);
}
} while (status != 0);
retval = CODEC_OK;