summaryrefslogtreecommitdiffstats
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)
int frame_skip; /* samples to skip current frame */
int samples_to_skip; /* samples to skip in total for this file (at start) */
char *inputbuffer;
+ /* If we know the position isn't exact (i.e., we have seeked to a
+ * position that isn't the start of the file), we can't reliably do
+ * end-of-file trimming for gapless playback.
+ */
+ bool exact_position = true;
ci = api;
@@ -147,6 +152,7 @@ enum codec_status codec_start(struct codec_api *api)
}
samplesdone = ((int64_t)ci->id3->elapsed) * current_frequency / 1000;
+ exact_position = samplesdone == 0;
samples_to_skip = start_skip;
recalc_samplecount();
@@ -163,12 +169,12 @@ enum codec_status codec_start(struct codec_api *api)
samplesdone = ((int64_t) (ci->seek_time - 1))
* current_frequency / 1000;
+ exact_position = samplesdone == 0;
if (ci->seek_time-1 == 0)
- newpos = 0;
+ newpos = ci->id3->first_frame_offset;
else
- newpos = ci->mp3_get_filepos(ci->seek_time-1) +
- ci->id3->first_frame_offset;
+ newpos = ci->mp3_get_filepos(ci->seek_time-1);
if (!ci->seek_buffer(newpos))
break;
@@ -230,7 +236,7 @@ enum codec_status codec_start(struct codec_api *api)
framelength = synth.pcm.length - frame_skip;
- if (stop_skip > 0) {
+ if (exact_position && (stop_skip > 0)) {
int64_t max = samplecount - samplesdone;
if (max < 0) max = 0;