diff options
author | Michael Sevakis <jethead71@rockbox.org> | 2013-07-14 07:59:39 -0400 |
---|---|---|
committer | Michael Sevakis <jethead71@rockbox.org> | 2014-03-10 04:12:30 +0100 |
commit | 31b712286721dd606940c7b557d03e3f714b9604 (patch) | |
tree | 8c4a4cc32e9000ea721ebb23aa3c0129ca97bf53 /lib/rbcodec/codecs/cook.c | |
parent | dda54b85daa83b7803b4fb189ab45859f96ff3f9 (diff) | |
download | rockbox-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/cook.c')
-rw-r--r-- | lib/rbcodec/codecs/cook.c | 13 |
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 { |