summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/cook.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/cook.c')
-rw-r--r--lib/rbcodec/codecs/cook.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/rbcodec/codecs/cook.c b/lib/rbcodec/codecs/cook.c
index 55188aad36..402d1d3fa6 100644
--- a/lib/rbcodec/codecs/cook.c
+++ b/lib/rbcodec/codecs/cook.c
@@ -56,14 +56,16 @@ enum codec_status codec_run(void)
56 uint32_t packet_count; 56 uint32_t packet_count;
57 int scrambling_unit_size, num_units; 57 int scrambling_unit_size, num_units;
58 size_t resume_offset; 58 size_t resume_offset;
59 intptr_t param = 0; 59 intptr_t param;
60 enum codec_command_action action = CODEC_ACTION_NULL; 60 enum codec_command_action action;
61 61
62 if (codec_init()) { 62 if (codec_init()) {
63 DEBUGF("codec init failed\n"); 63 DEBUGF("codec init failed\n");
64 return CODEC_ERROR; 64 return CODEC_ERROR;
65 } 65 }
66 66
67 action = CODEC_ACTION_NULL;
68 param = ci->id3->elapsed;
67 resume_offset = ci->id3->offset; 69 resume_offset = ci->id3->offset;
68 70
69 codec_set_replaygain(ci->id3); 71 codec_set_replaygain(ci->id3);
@@ -97,12 +99,15 @@ enum codec_status codec_run(void)
97 } 99 }
98 100
99 /* check for a mid-track resume and force a seek time accordingly */ 101 /* check for a mid-track resume and force a seek time accordingly */
100 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { 102 if(resume_offset) {
101 resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; 103 resume_offset -= MIN(resume_offset, rmctx.data_offset + DATA_HEADER_SIZE);
102 num_units = (int)resume_offset / scrambling_unit_size; 104 num_units = (int)resume_offset / scrambling_unit_size;
103 /* put number of subpackets to skip in resume_offset */ 105 /* put number of subpackets to skip in resume_offset */
104 resume_offset /= (sps + PACKET_HEADER_SIZE); 106 resume_offset /= (sps + PACKET_HEADER_SIZE);
105 param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); 107 param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate);
108 }
109
110 if (param) {
106 action = CODEC_ACTION_SEEK_TIME; 111 action = CODEC_ACTION_SEEK_TIME;
107 } 112 }
108 else { 113 else {