summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Holmgren <magnushol@gmail.com>2006-05-01 11:54:04 +0000
committerMagnus Holmgren <magnushol@gmail.com>2006-05-01 11:54:04 +0000
commitd5e1157cf7a59f98c23ed9116b32e660b8111550 (patch)
tree505247b7f6d87429638f487fa14d087c5cd75c40
parentb4f0efc1dd2810f68e5fe7e10c49a425505e6840 (diff)
downloadrockbox-d5e1157cf7a59f98c23ed9116b32e660b8111550.tar.gz
rockbox-d5e1157cf7a59f98c23ed9116b32e660b8111550.zip
Tweak MP3 seeking a little, and don't do gapless trim if a seek has been done.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9848 a1c6a512-1295-4272-9138-f99709370657
-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;