From bc41926b8f1b77127dd471fc530e9990624d0e36 Mon Sep 17 00:00:00 2001 From: Michael Giacomelli Date: Tue, 3 Apr 2012 20:15:16 -0400 Subject: More completely flush WMA decoder state on seek to prevent artifact. Each MDCT depends on the previous frame for reconstruction. Previosly these were not zeroed out when seeking, resulting in a few milliseconds of the previous frame playing with the current one. Fix that. Additionally, since the codec treats seeks to the start of a track as a "reset", flush the entire codec state in this event to ensure that everything is reset. Change-Id: If593621a2922b0bbfa34f926f9bff31bee6b8c6a --- apps/codecs/wma.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) mode change 100644 => 100755 apps/codecs/wma.c diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c old mode 100644 new mode 100755 index 361fee6175..f9501ffad3 --- a/apps/codecs/wma.c +++ b/apps/codecs/wma.c @@ -54,14 +54,15 @@ enum codec_status codec_run(void) int errcount = 0; intptr_t param; - /* Proper reset of the decoder context. */ - memset(&wmadec, 0, sizeof(wmadec)); - /* Remember the resume position - when the codec is opened, the playback engine will reset it. */ resume_offset = ci->id3->offset; restart_track: + + /* Proper reset of the decoder context. */ + memset(&wmadec, 0, sizeof(wmadec)); + if (codec_init()) { LOGF("WMA: Error initialising codec\n"); return CODEC_ERROR; @@ -111,6 +112,15 @@ restart_track: /* Deal with any pending seek requests */ if (action == CODEC_ACTION_SEEK_TIME) { + /*flush the wma decoder state*/ + wmadec.last_superframe_len = 0; + wmadec.last_bitoffset = 0; + + /*zero the frame out buffer so we don't overlap with a + stale samples*/ + memset((*(wmadec.frame_out)), 0, + sizeof(fixed32) * MAX_CHANNELS * BLOCK_MAX_SIZE * 2); + if (param == 0) { ci->set_elapsed(0); ci->seek_complete(); @@ -125,10 +135,6 @@ restart_track: } /*DEBUGF("Seek returned %d\n", (int)elapsedtime);*/ - /*flush the wma decoder state*/ - wmadec.last_superframe_len = 0; - wmadec.last_bitoffset = 0; - ci->set_elapsed(elapsedtime); ci->seek_complete(); } -- cgit v1.2.3