summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/mpa.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index fa5dab6543..4c3784a5f7 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -97,6 +97,11 @@ enum codec_status codec_start(struct codec_api *api)
97 int frame_skip; /* samples to skip current frame */ 97 int frame_skip; /* samples to skip current frame */
98 int samples_to_skip; /* samples to skip in total for this file (at start) */ 98 int samples_to_skip; /* samples to skip in total for this file (at start) */
99 char *inputbuffer; 99 char *inputbuffer;
100 /* If we know the position isn't exact (i.e., we have seeked to a
101 * position that isn't the start of the file), we can't reliably do
102 * end-of-file trimming for gapless playback.
103 */
104 bool exact_position = true;
100 105
101 ci = api; 106 ci = api;
102 107
@@ -147,6 +152,7 @@ enum codec_status codec_start(struct codec_api *api)
147 } 152 }
148 153
149 samplesdone = ((int64_t)ci->id3->elapsed) * current_frequency / 1000; 154 samplesdone = ((int64_t)ci->id3->elapsed) * current_frequency / 1000;
155 exact_position = samplesdone == 0;
150 samples_to_skip = start_skip; 156 samples_to_skip = start_skip;
151 recalc_samplecount(); 157 recalc_samplecount();
152 158
@@ -163,12 +169,12 @@ enum codec_status codec_start(struct codec_api *api)
163 169
164 samplesdone = ((int64_t) (ci->seek_time - 1)) 170 samplesdone = ((int64_t) (ci->seek_time - 1))
165 * current_frequency / 1000; 171 * current_frequency / 1000;
172 exact_position = samplesdone == 0;
166 173
167 if (ci->seek_time-1 == 0) 174 if (ci->seek_time-1 == 0)
168 newpos = 0; 175 newpos = ci->id3->first_frame_offset;
169 else 176 else
170 newpos = ci->mp3_get_filepos(ci->seek_time-1) + 177 newpos = ci->mp3_get_filepos(ci->seek_time-1);
171 ci->id3->first_frame_offset;
172 178
173 if (!ci->seek_buffer(newpos)) 179 if (!ci->seek_buffer(newpos))
174 break; 180 break;
@@ -230,7 +236,7 @@ enum codec_status codec_start(struct codec_api *api)
230 236
231 framelength = synth.pcm.length - frame_skip; 237 framelength = synth.pcm.length - frame_skip;
232 238
233 if (stop_skip > 0) { 239 if (exact_position && (stop_skip > 0)) {
234 int64_t max = samplecount - samplesdone; 240 int64_t max = samplecount - samplesdone;
235 241
236 if (max < 0) max = 0; 242 if (max < 0) max = 0;