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/aac.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/aac.c')
-rw-r--r-- | lib/rbcodec/codecs/aac.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/rbcodec/codecs/aac.c b/lib/rbcodec/codecs/aac.c index c9cf737b48..015e332be2 100644 --- a/lib/rbcodec/codecs/aac.c +++ b/lib/rbcodec/codecs/aac.c | |||
@@ -72,6 +72,7 @@ enum codec_status codec_run(void) | |||
72 | uint32_t sbr_fac = 1; | 72 | uint32_t sbr_fac = 1; |
73 | unsigned char c = 0; | 73 | unsigned char c = 0; |
74 | void *ret; | 74 | void *ret; |
75 | enum codec_command_action action; | ||
75 | intptr_t param; | 76 | intptr_t param; |
76 | bool empty_first_frame = false; | 77 | bool empty_first_frame = false; |
77 | 78 | ||
@@ -82,6 +83,8 @@ enum codec_status codec_run(void) | |||
82 | return CODEC_ERROR; | 83 | return CODEC_ERROR; |
83 | } | 84 | } |
84 | 85 | ||
86 | action = CODEC_ACTION_NULL; | ||
87 | param = ci->id3->elapsed; | ||
85 | file_offset = ci->id3->offset; | 88 | file_offset = ci->id3->offset; |
86 | 89 | ||
87 | ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); | 90 | ci->configure(DSP_SET_FREQUENCY, ci->id3->frequency); |
@@ -138,11 +141,16 @@ enum codec_status codec_run(void) | |||
138 | sound_samples_done = 0; | 141 | sound_samples_done = 0; |
139 | } | 142 | } |
140 | NeAACDecPostSeekReset(decoder, i); | 143 | NeAACDecPostSeekReset(decoder, i); |
144 | elapsed_time = (sound_samples_done * 10) / | ||
145 | (ci->id3->frequency / 100); | ||
146 | } else if (param) { | ||
147 | elapsed_time = param; | ||
148 | action = CODEC_ACTION_SEEK_TIME; | ||
141 | } else { | 149 | } else { |
150 | elapsed_time = 0; | ||
142 | sound_samples_done = 0; | 151 | sound_samples_done = 0; |
143 | } | 152 | } |
144 | 153 | ||
145 | elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100); | ||
146 | ci->set_elapsed(elapsed_time); | 154 | ci->set_elapsed(elapsed_time); |
147 | 155 | ||
148 | if (i == 0) | 156 | if (i == 0) |
@@ -152,7 +160,8 @@ enum codec_status codec_run(void) | |||
152 | 160 | ||
153 | /* The main decoding loop */ | 161 | /* The main decoding loop */ |
154 | while (i < demux_res.num_sample_byte_sizes) { | 162 | while (i < demux_res.num_sample_byte_sizes) { |
155 | enum codec_command_action action = ci->get_command(¶m); | 163 | if (action == CODEC_ACTION_NULL) |
164 | action = ci->get_command(¶m); | ||
156 | 165 | ||
157 | if (action == CODEC_ACTION_HALT) | 166 | if (action == CODEC_ACTION_HALT) |
158 | break; | 167 | break; |
@@ -180,6 +189,8 @@ enum codec_status codec_run(void) | |||
180 | ci->seek_complete(); | 189 | ci->seek_complete(); |
181 | } | 190 | } |
182 | 191 | ||
192 | action = CODEC_ACTION_NULL; | ||
193 | |||
183 | /* There can be gaps between chunks, so skip ahead if needed. It | 194 | /* There can be gaps between chunks, so skip ahead if needed. It |
184 | * doesn't seem to happen much, but it probably means that a | 195 | * doesn't seem to happen much, but it probably means that a |
185 | * "proper" file can have chunks out of order. Why one would want | 196 | * "proper" file can have chunks out of order. Why one would want |