From 6d6ca6b6a5641a0ab3657e60a1770a440cc52493 Mon Sep 17 00:00:00 2001 From: Miika Pekkarinen Date: Sun, 22 Jan 2006 10:25:07 +0000 Subject: Muting trick to prevent tiny pops and glitchless mp3 seeking. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8416 a1c6a512-1295-4272-9138-f99709370657 --- apps/codecs/mpa.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'apps/codecs/mpa.c') diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 2c946f3f0d..1be6222ccf 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c @@ -72,6 +72,22 @@ void recalc_samplecount(void) samplecount -= start_skip + stop_skip; } +void init_mad(void) +{ + ci->memset(&stream, 0, sizeof(struct mad_stream)); + ci->memset(&frame, 0, sizeof(struct mad_frame)); + ci->memset(&synth, 0, sizeof(struct mad_synth)); + + mad_stream_init(&stream); + mad_frame_init(&frame); + mad_synth_init(&synth); + + /* We do this so libmad doesn't try to call codec_calloc() */ + ci->memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap)); + frame.overlap = &mad_frame_overlap; + stream.main_data = &mad_main_data; +} + /* this is the codec entry point */ enum codec_status codec_start(struct codec_api *api) { @@ -107,18 +123,7 @@ enum codec_status codec_start(struct codec_api *api) * 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)); - - mad_stream_init(&stream); - mad_frame_init(&frame); - mad_synth_init(&synth); - - /* We do this so libmad doesn't try to call codec_calloc() */ - ci->memset(mad_frame_overlap, 0, sizeof(mad_frame_overlap)); - frame.overlap = &mad_frame_overlap; - stream.main_data = &mad_main_data; + init_mad(); file_end = 0; while (!*ci->taginfo_ready && !ci->stop_codec) @@ -168,11 +173,7 @@ enum codec_status codec_start(struct codec_api *api) if (!ci->seek_buffer(newpos)) goto next_track; ci->seek_complete(); - if (newpos == 0) - { - ci->id3->elapsed = 0; - goto next_track; - } + init_mad(); } /* Lock buffers */ -- cgit v1.2.3