summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/atrac3_rm.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/atrac3_rm.c')
-rw-r--r--lib/rbcodec/codecs/atrac3_rm.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/rbcodec/codecs/atrac3_rm.c b/lib/rbcodec/codecs/atrac3_rm.c
index 997507425e..4b528c0a8d 100644
--- a/lib/rbcodec/codecs/atrac3_rm.c
+++ b/lib/rbcodec/codecs/atrac3_rm.c
@@ -57,17 +57,19 @@ enum codec_status codec_run(void)
57 uint8_t *bit_buffer; 57 uint8_t *bit_buffer;
58 uint16_t fs,sps,h; 58 uint16_t fs,sps,h;
59 uint32_t packet_count; 59 uint32_t packet_count;
60 int scrambling_unit_size, num_units, elapsed = 0; 60 int scrambling_unit_size, num_units, elapsed;
61 int playback_on = -1; 61 int playback_on = -1;
62 size_t resume_offset; 62 size_t resume_offset;
63 intptr_t param; 63 intptr_t param;
64 enum codec_command_action action = CODEC_ACTION_NULL; 64 enum codec_command_action action;
65 65
66 if (codec_init()) { 66 if (codec_init()) {
67 DEBUGF("codec init failed\n"); 67 DEBUGF("codec init failed\n");
68 return CODEC_ERROR; 68 return CODEC_ERROR;
69 } 69 }
70 70
71 action = CODEC_ACTION_NULL;
72 elapsed = ci->id3->elapsed;
71 resume_offset = ci->id3->offset; 73 resume_offset = ci->id3->offset;
72 74
73 codec_set_replaygain(ci->id3); 75 codec_set_replaygain(ci->id3);
@@ -98,15 +100,20 @@ enum codec_status codec_run(void)
98 } 100 }
99 101
100 /* check for a mid-track resume and force a seek time accordingly */ 102 /* check for a mid-track resume and force a seek time accordingly */
101 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { 103 if(resume_offset) {
102 resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; 104 resume_offset -= MIN(resume_offset, rmctx.data_offset + DATA_HEADER_SIZE);
103 num_units = (int)resume_offset / scrambling_unit_size; 105 num_units = (int)resume_offset / scrambling_unit_size;
104 /* put number of subpackets to skip in resume_offset */ 106 /* put number of subpackets to skip in resume_offset */
105 resume_offset /= (sps + PACKET_HEADER_SIZE); 107 resume_offset /= (sps + PACKET_HEADER_SIZE);
106 param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); 108 elapsed = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate);
109 }
110
111 if (elapsed > 0) {
112 param = elapsed;
107 action = CODEC_ACTION_SEEK_TIME; 113 action = CODEC_ACTION_SEEK_TIME;
108 } 114 }
109 else { 115 else {
116 elapsed = 0;
110 ci->set_elapsed(0); 117 ci->set_elapsed(0);
111 } 118 }
112 119
@@ -151,6 +158,7 @@ seek_start :
151 158
152 /* Seek to the start of the track */ 159 /* Seek to the start of the track */
153 if (param == 0) { 160 if (param == 0) {
161 elapsed = 0;
154 ci->set_elapsed(0); 162 ci->set_elapsed(0);
155 ci->seek_complete(); 163 ci->seek_complete();
156 action = CODEC_ACTION_NULL; 164 action = CODEC_ACTION_NULL;