summaryrefslogtreecommitdiff
path: root/apps/codecs
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-08-28 07:45:35 +0000
commit7ad2cad173ffa094bb285112582afee1c9aea4e5 (patch)
treece23e816cfdffb1767ebe44f4f960c304d8a5fb9 /apps/codecs
parent463b3ed8b2630d1b9d656dd2a52bbcbd429b4c08 (diff)
downloadrockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.tar.gz
rockbox-7ad2cad173ffa094bb285112582afee1c9aea4e5.zip
Commit work started in FS#12153 to put timing/position information in PCM
buffer chunks. * Samples and position indication is closely associated with audio data instead of compensating by a latency constant. Alleviates problems with using the elapsed as a track indicator where it could be off by several steps. * Timing is accurate throughout track even if resampling for pitch shift, whereas before it updated during transition latency at the normal 1:1 rate. * Simpler PCM buffer with a constant chunk size, no linked lists. In converting crossfade, a minor change was made to not change the WPS until the fade-in of the incoming track, whereas before it would change upon the start of the fade-out of the outgoing track possibly having the WPS change with far too much lead time. Codec changes are to set elapsed times *before* writing next PCM frame because time and position data last set are saved in the next committed PCM chunk. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30366 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/codecs')
-rw-r--r--apps/codecs/a52.c2
-rw-r--r--apps/codecs/a52_rm.c1
-rw-r--r--apps/codecs/aac.c5
-rw-r--r--apps/codecs/adx.c7
-rw-r--r--apps/codecs/aiff.c2
-rw-r--r--apps/codecs/alac.c2
-rw-r--r--apps/codecs/ape.c3
-rw-r--r--apps/codecs/au.c2
-rw-r--r--apps/codecs/cook.c4
-rw-r--r--apps/codecs/flac.c4
-rw-r--r--apps/codecs/mod.c3
-rw-r--r--apps/codecs/mpa.c12
-rw-r--r--apps/codecs/mpc.c4
-rw-r--r--apps/codecs/shorten.c3
-rw-r--r--apps/codecs/sid.c2
-rw-r--r--apps/codecs/smaf.c2
-rw-r--r--apps/codecs/spc.c2
-rw-r--r--apps/codecs/speex.c1
-rw-r--r--apps/codecs/tta.c2
-rw-r--r--apps/codecs/vorbis.c3
-rw-r--r--apps/codecs/vox.c2
-rw-r--r--apps/codecs/wav.c2
-rw-r--r--apps/codecs/wav64.c2
-rw-r--r--apps/codecs/wavpack.c2
-rw-r--r--apps/codecs/wma.c3
-rw-r--r--apps/codecs/wmapro.c1
-rw-r--r--apps/codecs/wmavoice.c2
27 files changed, 63 insertions, 17 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index 4cd293e37f..641e2d05da 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -158,7 +158,7 @@ enum codec_status codec_run(void)
158 } 158 }
159 else { 159 else {
160 ci->seek_buffer(ci->id3->first_frame_offset); 160 ci->seek_buffer(ci->id3->first_frame_offset);
161 samplesdone = 0; 161 ci->set_elapsed(0);
162 } 162 }
163 163
164 while (1) { 164 while (1) {
diff --git a/apps/codecs/a52_rm.c b/apps/codecs/a52_rm.c
index c1930aa7b4..0aa3edca3a 100644
--- a/apps/codecs/a52_rm.c
+++ b/apps/codecs/a52_rm.c
@@ -178,6 +178,7 @@ enum codec_status codec_run(void)
178 } 178 }
179 else { 179 else {
180 /* Seek to the first packet */ 180 /* Seek to the first packet */
181 ci->set_elapsed(0);
181 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE ); 182 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE );
182 } 183 }
183 184
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index 52e08c7b56..f1e81bad81 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -134,8 +134,6 @@ enum codec_status codec_run(void)
134 if (m4a_seek_raw(&demux_res, &input_stream, file_offset, 134 if (m4a_seek_raw(&demux_res, &input_stream, file_offset,
135 &sound_samples_done, (int*) &i)) { 135 &sound_samples_done, (int*) &i)) {
136 sound_samples_done *= sbr_fac; 136 sound_samples_done *= sbr_fac;
137 elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
138 ci->set_elapsed(elapsed_time);
139 } else { 137 } else {
140 sound_samples_done = 0; 138 sound_samples_done = 0;
141 } 139 }
@@ -143,6 +141,9 @@ enum codec_status codec_run(void)
143 } else { 141 } else {
144 sound_samples_done = 0; 142 sound_samples_done = 0;
145 } 143 }
144
145 elapsed_time = (sound_samples_done * 10) / (ci->id3->frequency / 100);
146 ci->set_elapsed(elapsed_time);
146 147
147 if (i == 0) 148 if (i == 0)
148 { 149 {
diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c
index e75e7dca1e..8144d5f468 100644
--- a/apps/codecs/adx.c
+++ b/apps/codecs/adx.c
@@ -209,7 +209,7 @@ enum codec_status codec_run(void)
209 209
210 /* get in position */ 210 /* get in position */
211 ci->seek_buffer(bufoff); 211 ci->seek_buffer(bufoff);
212 212 ci->set_elapsed(0);
213 213
214 /* setup pcm buffer format */ 214 /* setup pcm buffer format */
215 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 215 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
@@ -276,6 +276,11 @@ enum codec_status codec_run(void)
276 loop_count++; 276 loop_count++;
277 } 277 }
278 ci->seek_buffer(bufoff); 278 ci->seek_buffer(bufoff);
279
280 ci->set_elapsed(
281 ((end_adr-start_adr)*loop_count + bufoff-chanstart)*
282 1000LL/avgbytespersec);
283
279 ci->seek_complete(); 284 ci->seek_complete();
280 } 285 }
281 286
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c
index a8185b4910..333bcd0455 100644
--- a/apps/codecs/aiff.c
+++ b/apps/codecs/aiff.c
@@ -288,6 +288,8 @@ enum codec_status codec_run(void)
288 bytesdone = 0; 288 bytesdone = 0;
289 } 289 }
290 290
291 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
292
291 /* The main decoder loop */ 293 /* The main decoder loop */
292 endofstream = 0; 294 endofstream = 0;
293 295
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index b6852f5b3f..144d796e5f 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -97,6 +97,8 @@ enum codec_status codec_run(void)
97 } 97 }
98 } 98 }
99 99
100 ci->set_elapsed(elapsedtime);
101
100 /* The main decoding loop */ 102 /* The main decoding loop */
101 while (i < demux_res.num_sample_byte_sizes) { 103 while (i < demux_res.num_sample_byte_sizes) {
102 enum codec_command_action action = ci->get_command(&param); 104 enum codec_command_action action = ci->get_command(&param);
diff --git a/apps/codecs/ape.c b/apps/codecs/ape.c
index 8f95a01ec7..ed6ea21685 100644
--- a/apps/codecs/ape.c
+++ b/apps/codecs/ape.c
@@ -220,6 +220,9 @@ enum codec_status codec_run(void)
220 firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */ 220 firstbyte = 3; /* Take account of the little-endian 32-bit byte ordering */
221 } 221 }
222 222
223 elapsedtime = (samplesdone*10)/(ape_ctx.samplerate/100);
224 ci->set_elapsed(elapsedtime);
225
223 /* Initialise the buffer */ 226 /* Initialise the buffer */
224 inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); 227 inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE);
225 228
diff --git a/apps/codecs/au.c b/apps/codecs/au.c
index ef308358f4..cb75c7423d 100644
--- a/apps/codecs/au.c
+++ b/apps/codecs/au.c
@@ -253,6 +253,8 @@ enum codec_status codec_run(void)
253 bytesdone = 0; 253 bytesdone = 0;
254 } 254 }
255 255
256 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
257
256 /* The main decoder loop */ 258 /* The main decoder loop */
257 endofstream = 0; 259 endofstream = 0;
258 260
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c
index 4a47e74f60..55188aad36 100644
--- a/apps/codecs/cook.c
+++ b/apps/codecs/cook.c
@@ -105,8 +105,10 @@ enum codec_status codec_run(void)
105 param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate); 105 param = (int)resume_offset * ((sps * 8 * 1000)/rmctx.bit_rate);
106 action = CODEC_ACTION_SEEK_TIME; 106 action = CODEC_ACTION_SEEK_TIME;
107 } 107 }
108 else {
109 ci->set_elapsed(0);
110 }
108 111
109 ci->set_elapsed(0);
110 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE); 112 ci->advance_buffer(rmctx.data_offset + DATA_HEADER_SIZE);
111 113
112 /* The main decoder loop */ 114 /* The main decoder loop */
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c
index a5521b584f..c91a173f4a 100644
--- a/apps/codecs/flac.c
+++ b/apps/codecs/flac.c
@@ -460,7 +460,9 @@ enum codec_status codec_run(void)
460 codec_set_replaygain(ci->id3); 460 codec_set_replaygain(ci->id3);
461 461
462 flac_seek_offset(&fc, samplesdone); 462 flac_seek_offset(&fc, samplesdone);
463 samplesdone=0; 463 samplesdone=fc.samplenumber+fc.blocksize;
464 elapsedtime=(samplesdone*10)/(ci->id3->frequency/100);
465 ci->set_elapsed(elapsedtime);
464 466
465 /* The main decoding loop */ 467 /* The main decoding loop */
466 frame=0; 468 frame=0;
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c
index 3703ecd304..5bd64994f1 100644
--- a/apps/codecs/mod.c
+++ b/apps/codecs/mod.c
@@ -1333,12 +1333,11 @@ enum codec_status codec_run(void)
1333 /* New time is ready in param */ 1333 /* New time is ready in param */
1334 modplayer.patterntableposition = param/1000; 1334 modplayer.patterntableposition = param/1000;
1335 modplayer.currentline = 0; 1335 modplayer.currentline = 0;
1336 ci->set_elapsed(modplayer.patterntableposition*1000+500);
1337 ci->seek_complete(); 1336 ci->seek_complete();
1338 } 1337 }
1339 1338
1340 if(old_patterntableposition != modplayer.patterntableposition) { 1339 if(old_patterntableposition != modplayer.patterntableposition) {
1341 ci->set_elapsed(modplayer.patterntableposition*1000+500); 1340 ci->set_elapsed(modplayer.patterntableposition*1000);
1342 old_patterntableposition=modplayer.patterntableposition; 1341 old_patterntableposition=modplayer.patterntableposition;
1343 } 1342 }
1344 1343
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index c9e2131450..ac81f06cab 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -144,6 +144,7 @@ static void set_elapsed(struct mp3entry* id3)
144{ 144{
145 unsigned long offset = id3->offset > id3->first_frame_offset ? 145 unsigned long offset = id3->offset > id3->first_frame_offset ?
146 id3->offset - id3->first_frame_offset : 0; 146 id3->offset - id3->first_frame_offset : 0;
147 unsigned long elapsed = id3->elapsed;
147 148
148 if ( id3->vbr ) { 149 if ( id3->vbr ) {
149 if ( id3->has_toc ) { 150 if ( id3->has_toc ) {
@@ -172,27 +173,28 @@ static void set_elapsed(struct mp3entry* id3)
172 /* set time for this percent (divide before multiply to prevent 173 /* set time for this percent (divide before multiply to prevent
173 overflow on long files. loss of precision is negligible on 174 overflow on long files. loss of precision is negligible on
174 short files) */ 175 short files) */
175 id3->elapsed = i * (id3->length / 100); 176 elapsed = i * (id3->length / 100);
176 177
177 /* calculate remainder time */ 178 /* calculate remainder time */
178 plen = (nextpos - relpos) * (id3->filesize / 256); 179 plen = (nextpos - relpos) * (id3->filesize / 256);
179 id3->elapsed += (((remainder * 100) / plen) * 180 elapsed += (((remainder * 100) / plen) * (id3->length / 10000));
180 (id3->length / 10000));
181 } 181 }
182 else { 182 else {
183 /* no TOC exists. set a rough estimate using average bitrate */ 183 /* no TOC exists. set a rough estimate using average bitrate */
184 int tpk = id3->length / 184 int tpk = id3->length /
185 ((id3->filesize - id3->first_frame_offset - id3->id3v1len) / 185 ((id3->filesize - id3->first_frame_offset - id3->id3v1len) /
186 1024); 186 1024);
187 id3->elapsed = offset / 1024 * tpk; 187 elapsed = offset / 1024 * tpk;
188 } 188 }
189 } 189 }
190 else 190 else
191 { 191 {
192 /* constant bitrate, use exact calculation */ 192 /* constant bitrate, use exact calculation */
193 if (id3->bitrate != 0) 193 if (id3->bitrate != 0)
194 id3->elapsed = offset / (id3->bitrate / 8); 194 elapsed = offset / (id3->bitrate / 8);
195 } 195 }
196
197 ci->set_elapsed(elapsed);
196} 198}
197 199
198#ifdef MPA_SYNTH_ON_COP 200#ifdef MPA_SYNTH_ON_COP
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c
index 7388799ee8..a405c72f79 100644
--- a/apps/codecs/mpc.c
+++ b/apps/codecs/mpc.c
@@ -123,6 +123,8 @@ enum codec_status codec_run(void)
123 codec_set_replaygain(ci->id3); 123 codec_set_replaygain(ci->id3);
124 124
125 /* Resume to saved sample offset. */ 125 /* Resume to saved sample offset. */
126 elapsed_time = 0;
127
126 if (samplesdone > 0) 128 if (samplesdone > 0)
127 { 129 {
128 if (mpc_demux_seek_sample(demux, samplesdone) == MPC_STATUS_OK) 130 if (mpc_demux_seek_sample(demux, samplesdone) == MPC_STATUS_OK)
@@ -136,6 +138,8 @@ enum codec_status codec_run(void)
136 } 138 }
137 } 139 }
138 140
141 ci->set_elapsed(elapsed_time);
142
139 /* This is the decoding loop. */ 143 /* This is the decoding loop. */
140 do 144 do
141 { 145 {
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c
index db66991679..a8ab3f30a0 100644
--- a/apps/codecs/shorten.c
+++ b/apps/codecs/shorten.c
@@ -99,6 +99,8 @@ enum codec_status codec_run(void)
99 sc.bitindex = sc.gb.index - 8*consumed; 99 sc.bitindex = sc.gb.index - 8*consumed;
100 100
101seek_start: 101seek_start:
102 ci->set_elapsed(0);
103
102 /* The main decoding loop */ 104 /* The main decoding loop */
103 ci->memset(&decoded0, 0, sizeof(int32_t)*MAX_DECODE_SIZE); 105 ci->memset(&decoded0, 0, sizeof(int32_t)*MAX_DECODE_SIZE);
104 ci->memset(&decoded1, 0, sizeof(int32_t)*MAX_DECODE_SIZE); 106 ci->memset(&decoded1, 0, sizeof(int32_t)*MAX_DECODE_SIZE);
@@ -118,7 +120,6 @@ seek_start:
118 if (param == 0 && 120 if (param == 0 &&
119 ci->seek_buffer(sc.header_bits/8 + ci->id3->first_frame_offset)) { 121 ci->seek_buffer(sc.header_bits/8 + ci->id3->first_frame_offset)) {
120 sc.bitindex = sc.header_bits - 8*(sc.header_bits/8); 122 sc.bitindex = sc.header_bits - 8*(sc.header_bits/8);
121 ci->set_elapsed(0);
122 ci->seek_complete(); 123 ci->seek_complete();
123 goto seek_start; 124 goto seek_start;
124 } 125 }
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c
index fed1e8acaa..9b19a20ba7 100644
--- a/apps/codecs/sid.c
+++ b/apps/codecs/sid.c
@@ -1299,8 +1299,8 @@ enum codec_status codec_run(void)
1299 nSamplesToRender = 0; /* Start the rendering from scratch */ 1299 nSamplesToRender = 0; /* Start the rendering from scratch */
1300 1300
1301 /* Set the elapsed time to the current subsong (in seconds) */ 1301 /* Set the elapsed time to the current subsong (in seconds) */
1302 ci->seek_complete();
1303 ci->set_elapsed(subSong*1000); 1302 ci->set_elapsed(subSong*1000);
1303 ci->seek_complete();
1304 } 1304 }
1305 1305
1306 nSamplesRendered = 0; 1306 nSamplesRendered = 0;
diff --git a/apps/codecs/smaf.c b/apps/codecs/smaf.c
index 9211daa9aa..0203d1b4e3 100644
--- a/apps/codecs/smaf.c
+++ b/apps/codecs/smaf.c
@@ -429,6 +429,8 @@ enum codec_status codec_run(void)
429 bytesdone = 0; 429 bytesdone = 0;
430 } 430 }
431 431
432 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
433
432 /* The main decoder loop */ 434 /* The main decoder loop */
433 endofstream = 0; 435 endofstream = 0;
434 436
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c
index 6b21f9ad19..3b007471a9 100644
--- a/apps/codecs/spc.c
+++ b/apps/codecs/spc.c
@@ -560,6 +560,8 @@ enum codec_status codec_run(void)
560 return CODEC_ERROR; 560 return CODEC_ERROR;
561 561
562 DEBUGF("SPC: read size = 0x%lx\n",(unsigned long)buffersize); 562 DEBUGF("SPC: read size = 0x%lx\n",(unsigned long)buffersize);
563 ci->set_elapsed(0);
564
563 do 565 do
564 { 566 {
565 if (load_spc_buffer(buffer, buffersize)) { 567 if (load_spc_buffer(buffer, buffersize)) {
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c
index c01bcfdf9c..3d82ce7ad0 100644
--- a/apps/codecs/speex.c
+++ b/apps/codecs/speex.c
@@ -417,6 +417,7 @@ enum codec_status codec_run(void)
417 } 417 }
418 418
419 ci->seek_buffer(0); 419 ci->seek_buffer(0);
420 ci->set_elapsed(0);
420 421
421 stereo = speex_stereo_state_init(); 422 stereo = speex_stereo_state_init();
422 spx_ogg_sync_init(&oy); 423 spx_ogg_sync_init(&oy);
diff --git a/apps/codecs/tta.c b/apps/codecs/tta.c
index c75f2b0a57..dda33b3f5e 100644
--- a/apps/codecs/tta.c
+++ b/apps/codecs/tta.c
@@ -90,6 +90,8 @@ enum codec_status codec_run(void)
90 decodedsamples = new_pos; 90 decodedsamples = new_pos;
91 } 91 }
92 92
93 ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH);
94
93 while (!endofstream) 95 while (!endofstream)
94 { 96 {
95 enum codec_command_action action = ci->get_command(&param); 97 enum codec_command_action action = ci->get_command(&param);
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c
index e02d459262..fb1c9d7f7c 100644
--- a/apps/codecs/vorbis.c
+++ b/apps/codecs/vorbis.c
@@ -196,6 +196,9 @@ enum codec_status codec_run(void)
196 ci->set_elapsed(ov_time_tell(&vf)); 196 ci->set_elapsed(ov_time_tell(&vf));
197 ci->set_offset(ov_raw_tell(&vf)); 197 ci->set_offset(ov_raw_tell(&vf));
198 } 198 }
199 else {
200 ci->set_elapsed(0);
201 }
199 202
200 previous_section = -1; 203 previous_section = -1;
201 eof = 0; 204 eof = 0;
diff --git a/apps/codecs/vox.c b/apps/codecs/vox.c
index bf274c6917..279d003162 100644
--- a/apps/codecs/vox.c
+++ b/apps/codecs/vox.c
@@ -141,6 +141,8 @@ enum codec_status codec_run(void)
141 bytesdone = 0; 141 bytesdone = 0;
142 } 142 }
143 143
144 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
145
144 /* The main decoder loop */ 146 /* The main decoder loop */
145 endofstream = 0; 147 endofstream = 0;
146 148
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index f6f83b174d..d20331bc6c 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -378,6 +378,8 @@ enum codec_status codec_run(void)
378 bytesdone = 0; 378 bytesdone = 0;
379 } 379 }
380 380
381 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
382
381 /* The main decoder loop */ 383 /* The main decoder loop */
382 endofstream = 0; 384 endofstream = 0;
383 385
diff --git a/apps/codecs/wav64.c b/apps/codecs/wav64.c
index c763e6f7f0..184f39bf18 100644
--- a/apps/codecs/wav64.c
+++ b/apps/codecs/wav64.c
@@ -381,6 +381,8 @@ enum codec_status codec_run(void)
381 bytesdone = 0; 381 bytesdone = 0;
382 } 382 }
383 383
384 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
385
384 /* The main decoder loop */ 386 /* The main decoder loop */
385 endofstream = 0; 387 endofstream = 0;
386 388
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index 32f09d53e4..4d42391fc1 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -75,7 +75,7 @@ enum codec_status codec_run(void)
75 ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO); 75 ci->configure(DSP_SET_STEREO_MODE, nchans == 2 ? STEREO_INTERLEAVED : STEREO_MONO);
76 sr_100 = ci->id3->frequency / 100; 76 sr_100 = ci->id3->frequency / 100;
77 77
78 ci->set_elapsed (0); 78 ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10);
79 79
80 /* The main decoder loop */ 80 /* The main decoder loop */
81 81
diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c
index c327fafb5a..8986531744 100644
--- a/apps/codecs/wma.c
+++ b/apps/codecs/wma.c
@@ -84,7 +84,6 @@ restart_track:
84 % wfx.packet_size; 84 % wfx.packet_size;
85 ci->seek_buffer(resume_offset - packet_offset); 85 ci->seek_buffer(resume_offset - packet_offset);
86 elapsedtime = asf_get_timestamp(&i); 86 elapsedtime = asf_get_timestamp(&i);
87 ci->set_elapsed(elapsedtime);
88 } 87 }
89 else 88 else
90 { 89 {
@@ -93,6 +92,8 @@ restart_track:
93 elapsedtime = 0; 92 elapsedtime = 0;
94 } 93 }
95 94
95 ci->set_elapsed(elapsedtime);
96
96 resume_offset = 0; 97 resume_offset = 0;
97 ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate); 98 ci->configure(DSP_SWITCH_FREQUENCY, wfx.rate);
98 ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ? 99 ci->configure(DSP_SET_STEREO_MODE, wfx.channels == 1 ?
diff --git a/apps/codecs/wmapro.c b/apps/codecs/wmapro.c
index 17e311c5c0..bab3b5a027 100644
--- a/apps/codecs/wmapro.c
+++ b/apps/codecs/wmapro.c
@@ -79,6 +79,7 @@ restart_track:
79 ci->seek_buffer(ci->id3->first_frame_offset); 79 ci->seek_buffer(ci->id3->first_frame_offset);
80 80
81 elapsedtime = 0; 81 elapsedtime = 0;
82 ci->set_elapsed(0);
82 83
83 /* The main decoding loop */ 84 /* The main decoding loop */
84 85
diff --git a/apps/codecs/wmavoice.c b/apps/codecs/wmavoice.c
index 64c8cd1692..9cf5a49f1a 100644
--- a/apps/codecs/wmavoice.c
+++ b/apps/codecs/wmavoice.c
@@ -109,6 +109,8 @@ restart_track:
109 ci->seek_buffer(ci->id3->first_frame_offset); 109 ci->seek_buffer(ci->id3->first_frame_offset);
110 110
111 elapsedtime = 0; 111 elapsedtime = 0;
112 ci->set_elapsed(0);
113
112 resume_offset = 0; 114 resume_offset = 0;
113 115
114 /* The main decoding loop */ 116 /* The main decoding loop */