summaryrefslogtreecommitdiff
path: root/apps/codecs/cook.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/cook.c')
-rw-r--r--apps/codecs/cook.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c
index c9039a480c..5f91d244ff 100644
--- a/apps/codecs/cook.c
+++ b/apps/codecs/cook.c
@@ -45,6 +45,7 @@ enum codec_status codec_main(void)
45 uint16_t fs,sps,h; 45 uint16_t fs,sps,h;
46 uint32_t packet_count; 46 uint32_t packet_count;
47 int scrambling_unit_size, num_units; 47 int scrambling_unit_size, num_units;
48 size_t resume_offset = ci->id3->offset;
48 49
49next_track: 50next_track:
50 if (codec_init()) { 51 if (codec_init()) {
@@ -79,6 +80,15 @@ next_track:
79 DEBUGF("failed to initialize cook decoder\n"); 80 DEBUGF("failed to initialize cook decoder\n");
80 return CODEC_ERROR; 81 return CODEC_ERROR;
81 } 82 }
83
84 /* check for a mid-track resume and force a seek time accordingly */
85 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) {
86 resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE;
87 num_units = (int)resume_offset / scrambling_unit_size;
88 /* put number of subpackets to skip in resume_offset */
89 resume_offset /= (sps + PACKET_HEADER_SIZE);
90 ci->seek_time = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate);
91 }
82 92
83 ci->set_elapsed(0); 93 ci->set_elapsed(0);
84 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); 94 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE);