summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorAndree Buschmann <AndreeBuschmann@t-online.de>2010-03-14 16:05:12 +0000
committerAndree Buschmann <AndreeBuschmann@t-online.de>2010-03-14 16:05:12 +0000
commitc18e80e1276f3d54d97ff79564f5bfc09fe20957 (patch)
treef826e1db4c789951c3371c1819f1c24c62f2c205 /apps/codecs
parent5de615132dd634a3ee7a7bdfa2a06ca0515b2771 (diff)
Implement resume for alac codec.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25169 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/alac.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index fdc6748a95..1de127db28 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -63,6 +63,10 @@ enum codec_status codec_main(void)
stream_create(&input_stream,ci);
+ /* Read from ci->id3->offset before calling qtmovie_read. */
+ samplesdone = (uint32_t)(((uint64_t)(ci->id3->offset) * ci->id3->frequency) /
+ (ci->id3->bitrate*128));
+
/* if qtmovie_read returns successfully, the stream is up to
* the movie data, which can be used directly by the decoder */
if (!qtmovie_read(&input_stream, &demux_res)) {
@@ -74,9 +78,19 @@ enum codec_status codec_main(void)
/* initialise the sound converter */
create_alac(demux_res.sound_sample_size, demux_res.num_channels,&alac);
alac_set_info(&alac, demux_res.codecdata);
-
+
+ /* Set i for first frame, seek to desired sample position for resuming. */
i=0;
- samplesdone=0;
+ if (samplesdone > 0) {
+ if (alac_seek(&demux_res, &input_stream, samplesdone,
+ &samplesdone, (int*) &i)) {
+ elapsedtime = (samplesdone * 10) / (ci->id3->frequency / 100);
+ ci->set_elapsed(elapsedtime);
+ } else {
+ samplesdone = 0;
+ }
+ }
+
/* The main decoding loop */
while (i < demux_res.num_sample_byte_sizes) {
ci->yield();
@@ -127,9 +141,6 @@ enum codec_status codec_main(void)
elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
ci->set_elapsed(elapsedtime);
- /* Keep track of current position - for resuming */
- ci->set_offset(elapsedtime);
-
i++;
}
retval = CODEC_OK;