Implement resume for alac codec.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@25169 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Andree Buschmann 2010-03-14 16:05:12 +00:00
parent 5de615132d
commit c18e80e127
2 changed files with 17 additions and 5 deletions

View file

@ -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;

View file

@ -1370,6 +1370,7 @@ static void audio_finish_load_track(void)
case AFMT_PCM_WAV:
case AFMT_A52:
case AFMT_MP4_AAC:
case AFMT_MP4_ALAC:
case AFMT_MPC:
case AFMT_APE:
case AFMT_WMA: