summaryrefslogtreecommitdiff
path: root/apps/codecs/atrac3_rm.c
diff options
context:
space:
mode:
authorMohamed Tarek <mt@rockbox.org>2009-11-18 00:41:46 +0000
committerMohamed Tarek <mt@rockbox.org>2009-11-18 00:41:46 +0000
commit9669bbc135f3026858f8359555c1c3221d970f7f (patch)
tree0b52a67baa9e7538d8b96606740d1b5531d2e030 /apps/codecs/atrac3_rm.c
parent9ccccce65505541548bfba6dcf5b280f3ebc785e (diff)
Handle mid-track resumes in RM.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23659 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs/atrac3_rm.c')
-rw-r--r--apps/codecs/atrac3_rm.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/apps/codecs/atrac3_rm.c b/apps/codecs/atrac3_rm.c
index 75c0d1581b..d3e00c0e6f 100644
--- a/apps/codecs/atrac3_rm.c
+++ b/apps/codecs/atrac3_rm.c
@@ -45,6 +45,7 @@ enum codec_status codec_main(void)
uint32_t packet_count;
int scrambling_unit_size, num_units, elapsed = 0;
int playback_on = -1;
+ size_t resume_offset = ci->id3->offset;
next_track:
if (codec_init()) {
@@ -80,6 +81,15 @@ next_track:
return CODEC_ERROR;
}
+ /* check for a mid-track resume and force a seek time accordingly */
+ if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) {
+ resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE;
+ num_units = (int)resume_offset / scrambling_unit_size;
+ /* put number of subpackets to skip in resume_offset */
+ resume_offset /= (sps + PACKET_HEADER_SIZE);
+ ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate);
+ }
+
ci->set_elapsed(0);
ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
@@ -98,7 +108,7 @@ seek_start :
else
goto done;
}
-
+
for(i = 0; i < rmctx.audio_pkt_cnt*(fs/sps) ; i++)
{
ci->yield();