summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/a52_rm.c
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2013-07-14 07:59:39 -0400
committerMichael Sevakis <jethead71@rockbox.org>2014-03-10 04:12:30 +0100
commit31b712286721dd606940c7b557d03e3f714b9604 (patch)
tree8c4a4cc32e9000ea721ebb23aa3c0129ca97bf53 /lib/rbcodec/codecs/a52_rm.c
parentdda54b85daa83b7803b4fb189ab45859f96ff3f9 (diff)
downloadrockbox-31b712286721dd606940c7b557d03e3f714b9604.tar.gz
rockbox-31b712286721dd606940c7b557d03e3f714b9604.zip
Implement time-based resume and playback start.
This complements offset-based resume and playback start funcionality. The implementation is global on both HWCODEC and SWCODEC. Basically, if either the specified elapsed or offset are non-zero, it indicates a mid-track resume. To resume by time only, set elapsed to nonzero and offset to zero. To resume by offset only, set offset to nonzero and elapsed to zero. Which one the codec uses and which has priority is up to the codec; however, using an elapsed time covers more cases: * Codecs not able to use an offset such as VGM or other atomic formats * Starting playback at a nonzero elapsed time from a source that contains no offset, such as a cuesheet The change re-versions pretty much everything from tagcache to nvram. Change-Id: Ic7aebb24e99a03ae99585c5e236eba960d163f38 Reviewed-on: http://gerrit.rockbox.org/516 Reviewed-by: Michael Sevakis <jethead71@rockbox.org> Tested: Michael Sevakis <jethead71@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/a52_rm.c')
-rw-r--r--lib/rbcodec/codecs/a52_rm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rbcodec/codecs/a52_rm.c b/lib/rbcodec/codecs/a52_rm.c
index 42868437d8..3f07a43ce9 100644
--- a/lib/rbcodec/codecs/a52_rm.c
+++ b/lib/rbcodec/codecs/a52_rm.c
@@ -148,13 +148,15 @@ enum codec_status codec_run(void)
148 int consumed, packet_offset; 148 int consumed, packet_offset;
149 int playback_on = -1; 149 int playback_on = -1;
150 size_t resume_offset; 150 size_t resume_offset;
151 enum codec_command_action action;
151 intptr_t param; 152 intptr_t param;
152 enum codec_command_action action = CODEC_ACTION_NULL;
153 153
154 if (codec_init()) { 154 if (codec_init()) {
155 return CODEC_ERROR; 155 return CODEC_ERROR;
156 } 156 }
157 157
158 action = CODEC_ACTION_NULL;
159 param = ci->id3->elapsed;
158 resume_offset = ci->id3->offset; 160 resume_offset = ci->id3->offset;
159 161
160 ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); 162 ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency);
@@ -171,11 +173,14 @@ enum codec_status codec_run(void)
171 samplesdone = 0; 173 samplesdone = 0;
172 174
173 /* check for a mid-track resume and force a seek time accordingly */ 175 /* check for a mid-track resume and force a seek time accordingly */
174 if(resume_offset > rmctx.data_offset + DATA_HEADER_SIZE) { 176 if (resume_offset) {
175 resume_offset -= rmctx.data_offset + DATA_HEADER_SIZE; 177 resume_offset -= MIN(resume_offset, rmctx.data_offset + DATA_HEADER_SIZE);
176 /* put number of subpackets to skip in resume_offset */ 178 /* put number of subpackets to skip in resume_offset */
177 resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE); 179 resume_offset /= (rmctx.block_align + PACKET_HEADER_SIZE);
178 param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate); 180 param = (int)resume_offset * ((rmctx.block_align * 8 * 1000)/rmctx.bit_rate);
181 }
182
183 if (param > 0) {
179 action = CODEC_ACTION_SEEK_TIME; 184 action = CODEC_ACTION_SEEK_TIME;
180 } 185 }
181 else { 186 else {