From 0e159f13cf4562cf17d0a2edd16bfd3b665c8473 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Fri, 20 Jan 2006 22:02:44 +0000 Subject: Fixed a few iriver playback quirks and issues with previous fixes. Also fixed "TST.." bug when seeking and possible an enhancement to mp3 gapless playback also. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8402 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/mpa.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) (limited to 'apps/codecs') diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 3ee2b352f1..2c946f3f0d 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c @@ -101,6 +101,12 @@ enum codec_status codec_start(struct codec_api *api) ci->configure(DSP_SET_CLIP_MAX, (int *)(MAD_F_ONE - 1)); ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (int *)(1024*16)); + /** This label might need to be moved above all the init code, but I don't + * think reiniting the codec is necessary for MPEG. It might even be unwanted + * for gapless playback. + * Reinitializing seems to be necessary to avoid playback quircks when seeking. */ + next_track: + ci->memset(&stream, 0, sizeof(struct mad_stream)); ci->memset(&frame, 0, sizeof(struct mad_frame)); ci->memset(&synth, 0, sizeof(struct mad_synth)); @@ -114,10 +120,6 @@ enum codec_status codec_start(struct codec_api *api) frame.overlap = &mad_frame_overlap; stream.main_data = &mad_main_data; - /* This label might need to be moved above all the init code, but I don't - think reiniting the codec is necessary for MPEG. It might even be unwanted - for gapless playback */ -next_track: file_end = 0; while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); @@ -156,14 +158,21 @@ next_track: samplesdone = ((int64_t) (ci->seek_time - 1)) * current_frequency / 1000; - newpos = ci->mp3_get_filepos(ci->seek_time-1) + - ci->id3->first_frame_offset; + + if (ci->seek_time-1 == 0) + newpos = 0; + else + newpos = ci->mp3_get_filepos(ci->seek_time-1) + + ci->id3->first_frame_offset; if (!ci->seek_buffer(newpos)) goto next_track; - if (newpos == 0) - samples_to_skip = start_skip; ci->seek_complete(); + if (newpos == 0) + { + ci->id3->elapsed = 0; + goto next_track; + } } /* Lock buffers */ -- cgit v1.2.3