summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/codecs/a52.c8
-rw-r--r--apps/codecs/a52_rm.c13
-rw-r--r--apps/codecs/aac.c6
-rw-r--r--apps/codecs/adx.c5
-rw-r--r--apps/codecs/aiff.c8
-rw-r--r--apps/codecs/alac.c6
-rw-r--r--apps/codecs/ape.c17
-rw-r--r--apps/codecs/asap.c5
-rw-r--r--apps/codecs/atrac3_oma.c9
-rw-r--r--apps/codecs/atrac3_rm.c9
-rw-r--r--apps/codecs/au.c9
-rw-r--r--apps/codecs/cook.c9
-rw-r--r--apps/codecs/flac.c13
-rw-r--r--apps/codecs/lib/codeclib.c13
-rw-r--r--apps/codecs/lib/codeclib.h1
-rw-r--r--apps/codecs/mod.c5
-rw-r--r--apps/codecs/mpa.c6
-rw-r--r--apps/codecs/mpc.c10
-rw-r--r--apps/codecs/nsf.c9
-rw-r--r--apps/codecs/raac.c10
-rw-r--r--apps/codecs/shorten.c5
-rw-r--r--apps/codecs/sid.c5
-rw-r--r--apps/codecs/smaf.c9
-rw-r--r--apps/codecs/spc.c4
-rw-r--r--apps/codecs/speex.c12
-rw-r--r--apps/codecs/tta.c10
-rw-r--r--apps/codecs/vorbis.c9
-rw-r--r--apps/codecs/vox.c9
-rw-r--r--apps/codecs/wav.c9
-rw-r--r--apps/codecs/wav64.c8
-rw-r--r--apps/codecs/wavpack.c8
-rw-r--r--apps/codecs/wma.c12
-rw-r--r--apps/codecs/wmapro.c13
-rw-r--r--apps/codecs/wmavoice.c12
34 files changed, 171 insertions, 125 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c
index d399e91627..00fdeea309 100644
--- a/apps/codecs/a52.c
+++ b/apps/codecs/a52.c
@@ -128,13 +128,15 @@ enum codec_status codec_main(void)
128 ci->configure(DSP_SET_SAMPLE_DEPTH, 28); 128 ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
129 129
130next_track: 130next_track:
131 retval = CODEC_OK;
132
131 if (codec_init()) { 133 if (codec_init()) {
132 retval = CODEC_ERROR; 134 retval = CODEC_ERROR;
133 goto exit; 135 goto exit;
134 } 136 }
135 137
136 while (!ci->taginfo_ready) 138 if (codec_wait_taginfo() != 0)
137 ci->yield(); 139 goto request_next_track;
138 140
139 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 141 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
140 codec_set_replaygain(ci->id3); 142 codec_set_replaygain(ci->id3);
@@ -176,8 +178,8 @@ next_track:
176 a52_decode_data(filebuf, filebuf + n); 178 a52_decode_data(filebuf, filebuf + n);
177 ci->advance_buffer(n); 179 ci->advance_buffer(n);
178 } 180 }
179 retval = CODEC_OK;
180 181
182request_next_track:
181 if (ci->request_next_track()) 183 if (ci->request_next_track())
182 goto next_track; 184 goto next_track;
183 185
diff --git a/apps/codecs/a52_rm.c b/apps/codecs/a52_rm.c
index bc6c129ad2..f5e4923292 100644
--- a/apps/codecs/a52_rm.c
+++ b/apps/codecs/a52_rm.c
@@ -132,20 +132,24 @@ enum codec_status codec_main(void)
132 uint8_t *filebuf; 132 uint8_t *filebuf;
133 int retval, consumed, packet_offset; 133 int retval, consumed, packet_offset;
134 int playback_on = -1; 134 int playback_on = -1;
135 size_t resume_offset = ci->id3->offset; 135 size_t resume_offset;
136 136
137 /* Generic codec initialisation */ 137 /* Generic codec initialisation */
138 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); 138 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
139 ci->configure(DSP_SET_SAMPLE_DEPTH, 28); 139 ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
140 140
141next_track: 141next_track:
142 retval = CODEC_OK;
143
142 if (codec_init()) { 144 if (codec_init()) {
143 retval = CODEC_ERROR; 145 retval = CODEC_ERROR;
144 goto exit; 146 goto exit;
145 } 147 }
146 148
147 while (!ci->taginfo_ready) 149 if (codec_wait_taginfo() != 0)
148 ci->yield(); 150 goto request_next_track;
151
152 resume_offset = ci->id3->offset;
149 153
150 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 154 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
151 codec_set_replaygain(ci->id3); 155 codec_set_replaygain(ci->id3);
@@ -201,8 +205,7 @@ next_track:
201 ci->advance_buffer(pkt.length); 205 ci->advance_buffer(pkt.length);
202 } 206 }
203 207
204 retval = CODEC_OK; 208request_next_track:
205
206 if (ci->request_next_track()) 209 if (ci->request_next_track())
207 goto next_track; 210 goto next_track;
208 211
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c
index 34239864d1..309c05da38 100644
--- a/apps/codecs/aac.c
+++ b/apps/codecs/aac.c
@@ -78,8 +78,8 @@ next_track:
78 goto exit; 78 goto exit;
79 } 79 }
80 80
81 while (!*ci->taginfo_ready && !ci->stop_codec) 81 if (codec_wait_taginfo() != 0)
82 ci->sleep(1); 82 goto done;
83 83
84 file_offset = ci->id3->offset; 84 file_offset = ci->id3->offset;
85 85
@@ -304,8 +304,6 @@ next_track:
304 i++; 304 i++;
305 } 305 }
306 306
307 err = CODEC_OK;
308
309done: 307done:
310 LOGF("AAC: Decoded %lu samples\n", (unsigned long)sound_samples_done); 308 LOGF("AAC: Decoded %lu samples\n", (unsigned long)sound_samples_done);
311 309
diff --git a/apps/codecs/adx.c b/apps/codecs/adx.c
index 2ef2091a66..832b94797b 100644
--- a/apps/codecs/adx.c
+++ b/apps/codecs/adx.c
@@ -78,8 +78,8 @@ next_track:
78 ch1_1=ch1_2=ch2_1=ch2_2=0; 78 ch1_1=ch1_2=ch2_1=ch2_2=0;
79 79
80 /* wait for track info to load */ 80 /* wait for track info to load */
81 while (!*ci->taginfo_ready && !ci->stop_codec) 81 if (codec_wait_taginfo() != 0)
82 ci->sleep(1); 82 goto request_next_track;
83 83
84 codec_set_replaygain(ci->id3); 84 codec_set_replaygain(ci->id3);
85 85
@@ -385,6 +385,7 @@ next_track:
385 1000LL/avgbytespersec); 385 1000LL/avgbytespersec);
386 } 386 }
387 387
388request_next_track:
388 if (ci->request_next_track()) 389 if (ci->request_next_track())
389 goto next_track; 390 goto next_track;
390 391
diff --git a/apps/codecs/aiff.c b/apps/codecs/aiff.c
index 4a127c7e0e..d4cf8660dd 100644
--- a/apps/codecs/aiff.c
+++ b/apps/codecs/aiff.c
@@ -63,7 +63,7 @@ static const struct pcm_codec *get_codec(uint32_t formattag)
63 63
64enum codec_status codec_main(void) 64enum codec_status codec_main(void)
65{ 65{
66 int status = CODEC_OK; 66 int status;
67 struct pcm_format format; 67 struct pcm_format format;
68 uint32_t bytesdone, decodedsamples; 68 uint32_t bytesdone, decodedsamples;
69 uint32_t num_sample_frames = 0; 69 uint32_t num_sample_frames = 0;
@@ -82,13 +82,15 @@ enum codec_status codec_main(void)
82 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 82 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
83 83
84next_track: 84next_track:
85 status = CODEC_OK;
86
85 if (codec_init()) { 87 if (codec_init()) {
86 status = CODEC_ERROR; 88 status = CODEC_ERROR;
87 goto exit; 89 goto exit;
88 } 90 }
89 91
90 while (!*ci->taginfo_ready && !ci->stop_codec) 92 if (codec_wait_taginfo() != 0)
91 ci->sleep(1); 93 goto done;
92 94
93 codec_set_replaygain(ci->id3); 95 codec_set_replaygain(ci->id3);
94 96
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c
index 003d222f00..3721f04f1f 100644
--- a/apps/codecs/alac.c
+++ b/apps/codecs/alac.c
@@ -48,6 +48,7 @@ enum codec_status codec_main(void)
48 ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1); 48 ci->configure(DSP_SET_SAMPLE_DEPTH, ALAC_OUTPUT_DEPTH-1);
49 49
50 next_track: 50 next_track:
51 retval = CODEC_OK;
51 52
52 /* Clean and initialize decoder structures */ 53 /* Clean and initialize decoder structures */
53 memset(&demux_res , 0, sizeof(demux_res)); 54 memset(&demux_res , 0, sizeof(demux_res));
@@ -57,8 +58,8 @@ enum codec_status codec_main(void)
57 goto exit; 58 goto exit;
58 } 59 }
59 60
60 while (!*ci->taginfo_ready && !ci->stop_codec) 61 if (codec_wait_taginfo() != 0)
61 ci->sleep(1); 62 goto done;
62 63
63 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 64 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
64 codec_set_replaygain(ci->id3); 65 codec_set_replaygain(ci->id3);
@@ -145,7 +146,6 @@ enum codec_status codec_main(void)
145 146
146 i++; 147 i++;
147 } 148 }
148 retval = CODEC_OK;
149 149
150done: 150done:
151 LOGF("ALAC: Decoded %lu samples\n",(unsigned long)samplesdone); 151 LOGF("ALAC: Decoded %lu samples\n",(unsigned long)samplesdone);
diff --git a/apps/codecs/ape.c b/apps/codecs/ape.c
index 06e8842d01..11d973ab26 100644
--- a/apps/codecs/ape.c
+++ b/apps/codecs/ape.c
@@ -149,22 +149,21 @@ enum codec_status codec_main(void)
149 /* Generic codec initialisation */ 149 /* Generic codec initialisation */
150 ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1); 150 ci->configure(DSP_SET_SAMPLE_DEPTH, APE_OUTPUT_DEPTH-1);
151 151
152 next_track: 152next_track:
153
154 retval = CODEC_OK; 153 retval = CODEC_OK;
155 154
156 /* Remember the resume position - when the codec is opened, the
157 playback engine will reset it. */
158 resume_offset = ci->id3->offset;
159
160 if (codec_init()) { 155 if (codec_init()) {
161 LOGF("APE: Error initialising codec\n"); 156 LOGF("APE: Error initialising codec\n");
162 retval = CODEC_ERROR; 157 retval = CODEC_ERROR;
163 goto exit; 158 goto exit;
164 } 159 }
165 160
166 while (!*ci->taginfo_ready && !ci->stop_codec) 161 if (codec_wait_taginfo() != 0)
167 ci->sleep(1); 162 goto done;
163
164 /* Remember the resume position - when the codec is opened, the
165 playback engine will reset it. */
166 resume_offset = ci->id3->offset;
168 167
169 inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE); 168 inbuffer = ci->request_buffer(&bytesleft, INPUT_CHUNKSIZE);
170 169
@@ -319,8 +318,6 @@ frame_start:
319 currentframe++; 318 currentframe++;
320 } 319 }
321 320
322 retval = CODEC_OK;
323
324done: 321done:
325 LOGF("APE: Decoded %lu samples\n",(unsigned long)samplesdone); 322 LOGF("APE: Decoded %lu samples\n",(unsigned long)samplesdone);
326 323
diff --git a/apps/codecs/asap.c b/apps/codecs/asap.c
index bcb47a717d..9447c738d2 100644
--- a/apps/codecs/asap.c
+++ b/apps/codecs/asap.c
@@ -44,8 +44,8 @@ next_track:
44 return CODEC_ERROR; 44 return CODEC_ERROR;
45 } 45 }
46 46
47 while (!*ci->taginfo_ready && !ci->stop_codec) 47 if (codec_wait_taginfo() != 0)
48 ci->sleep(1); 48 goto request_next_track;
49 49
50 codec_set_replaygain(ci->id3); 50 codec_set_replaygain(ci->id3);
51 51
@@ -130,6 +130,7 @@ next_track:
130 break; 130 break;
131 } 131 }
132 132
133request_next_track:
133 if (ci->request_next_track()) 134 if (ci->request_next_track())
134 goto next_track; 135 goto next_track;
135 136
diff --git a/apps/codecs/atrac3_oma.c b/apps/codecs/atrac3_oma.c
index 2085466ed5..73f3ad29fd 100644
--- a/apps/codecs/atrac3_oma.c
+++ b/apps/codecs/atrac3_oma.c
@@ -40,15 +40,18 @@ enum codec_status codec_main(void)
40 int datasize, res, frame_counter, total_frames, seek_frame_offset; 40 int datasize, res, frame_counter, total_frames, seek_frame_offset;
41 uint8_t *bit_buffer; 41 uint8_t *bit_buffer;
42 int elapsed = 0; 42 int elapsed = 0;
43 size_t resume_offset = ci->id3->offset; 43 size_t resume_offset;
44 44
45next_track: 45next_track:
46 if (codec_init()) { 46 if (codec_init()) {
47 DEBUGF("codec init failed\n"); 47 DEBUGF("codec init failed\n");
48 return CODEC_ERROR; 48 return CODEC_ERROR;
49 } 49 }
50 while (!*ci->taginfo_ready && !ci->stop_codec) 50
51 ci->sleep(1); 51 if (codec_wait_taginfo() != 0)
52 goto done;
53
54 resume_offset = ci->id3->offset;
52 55
53 codec_set_replaygain(ci->id3); 56 codec_set_replaygain(ci->id3);
54 ci->memset(&q,0,sizeof(ATRAC3Context)); 57 ci->memset(&q,0,sizeof(ATRAC3Context));
diff --git a/apps/codecs/atrac3_rm.c b/apps/codecs/atrac3_rm.c
index 6c559ec868..6a77d24283 100644
--- a/apps/codecs/atrac3_rm.c
+++ b/apps/codecs/atrac3_rm.c
@@ -51,15 +51,18 @@ enum codec_status codec_main(void)
51 uint32_t packet_count; 51 uint32_t packet_count;
52 int scrambling_unit_size, num_units, elapsed = 0; 52 int scrambling_unit_size, num_units, elapsed = 0;
53 int playback_on = -1; 53 int playback_on = -1;
54 size_t resume_offset = ci->id3->offset; 54 size_t resume_offset;
55 55
56next_track: 56next_track:
57 if (codec_init()) { 57 if (codec_init()) {
58 DEBUGF("codec init failed\n"); 58 DEBUGF("codec init failed\n");
59 return CODEC_ERROR; 59 return CODEC_ERROR;
60 } 60 }
61 while (!*ci->taginfo_ready && !ci->stop_codec) 61
62 ci->sleep(1); 62 if (codec_wait_taginfo() != 0)
63 goto done;
64
65 resume_offset = ci->id3->offset;
63 66
64 codec_set_replaygain(ci->id3); 67 codec_set_replaygain(ci->id3);
65 ci->memset(&rmctx,0,sizeof(RMContext)); 68 ci->memset(&rmctx,0,sizeof(RMContext));
diff --git a/apps/codecs/au.c b/apps/codecs/au.c
index 1e6af25924..3f9436c9e7 100644
--- a/apps/codecs/au.c
+++ b/apps/codecs/au.c
@@ -108,7 +108,7 @@ static int convert_au_format(unsigned int encoding, struct pcm_format *fmt)
108/* this is the codec entry point */ 108/* this is the codec entry point */
109enum codec_status codec_main(void) 109enum codec_status codec_main(void)
110{ 110{
111 int status = CODEC_OK; 111 int status;
112 struct pcm_format format; 112 struct pcm_format format;
113 uint32_t bytesdone, decodedsamples; 113 uint32_t bytesdone, decodedsamples;
114 size_t n; 114 size_t n;
@@ -124,14 +124,16 @@ enum codec_status codec_main(void)
124 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 124 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
125 125
126next_track: 126next_track:
127 status = CODEC_OK;
128
127 if (codec_init()) { 129 if (codec_init()) {
128 DEBUGF("codec_init() error\n"); 130 DEBUGF("codec_init() error\n");
129 status = CODEC_ERROR; 131 status = CODEC_ERROR;
130 goto exit; 132 goto exit;
131 } 133 }
132 134
133 while (!*ci->taginfo_ready && !ci->stop_codec) 135 if (codec_wait_taginfo() != 0)
134 ci->sleep(1); 136 goto done;
135 137
136 codec_set_replaygain(ci->id3); 138 codec_set_replaygain(ci->id3);
137 139
@@ -304,7 +306,6 @@ next_track:
304 endofstream = 1; 306 endofstream = 1;
305 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 307 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
306 } 308 }
307 status = CODEC_OK;
308 309
309done: 310done:
310 if (ci->request_next_track()) 311 if (ci->request_next_track())
diff --git a/apps/codecs/cook.c b/apps/codecs/cook.c
index 7e77c33e1d..015618986c 100644
--- a/apps/codecs/cook.c
+++ b/apps/codecs/cook.c
@@ -47,15 +47,18 @@ enum codec_status codec_main(void)
47 uint16_t fs,sps,h; 47 uint16_t fs,sps,h;
48 uint32_t packet_count; 48 uint32_t packet_count;
49 int scrambling_unit_size, num_units; 49 int scrambling_unit_size, num_units;
50 size_t resume_offset = ci->id3->offset; 50 size_t resume_offset;
51 51
52next_track: 52next_track:
53 if (codec_init()) { 53 if (codec_init()) {
54 DEBUGF("codec init failed\n"); 54 DEBUGF("codec init failed\n");
55 return CODEC_ERROR; 55 return CODEC_ERROR;
56 } 56 }
57 while (!*ci->taginfo_ready && !ci->stop_codec) 57
58 ci->sleep(1); 58 if (codec_wait_taginfo() != 0)
59 goto done;
60
61 resume_offset = ci->id3->offset;
59 62
60 codec_set_replaygain(ci->id3); 63 codec_set_replaygain(ci->id3);
61 ci->memset(&rmctx,0,sizeof(RMContext)); 64 ci->memset(&rmctx,0,sizeof(RMContext));
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c
index e8b7f9ad83..89d14b98a7 100644
--- a/apps/codecs/flac.c
+++ b/apps/codecs/flac.c
@@ -433,19 +433,20 @@ enum codec_status codec_main(void)
433 /* Generic codec initialisation */ 433 /* Generic codec initialisation */
434 ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1); 434 ci->configure(DSP_SET_SAMPLE_DEPTH, FLAC_OUTPUT_DEPTH-1);
435 435
436 next_track: 436next_track:
437 retval = CODEC_OK;
437 438
438 /* Need to save offset for later use (cleared indirectly by flac_init) */
439 samplesdone=ci->id3->offset;
440
441 if (codec_init()) { 439 if (codec_init()) {
442 LOGF("FLAC: Error initialising codec\n"); 440 LOGF("FLAC: Error initialising codec\n");
443 retval = CODEC_ERROR; 441 retval = CODEC_ERROR;
444 goto exit; 442 goto exit;
445 } 443 }
446 444
447 while (!*ci->taginfo_ready && !ci->stop_codec) 445 if (codec_wait_taginfo() != 0)
448 ci->sleep(1); 446 goto done;
447
448 /* Need to save offset for later use (cleared indirectly by flac_init) */
449 samplesdone = ci->id3->offset;
449 450
450 if (!flac_init(&fc,ci->id3->first_frame_offset)) { 451 if (!flac_init(&fc,ci->id3->first_frame_offset)) {
451 LOGF("FLAC: Error initialising codec\n"); 452 LOGF("FLAC: Error initialising codec\n");
diff --git a/apps/codecs/lib/codeclib.c b/apps/codecs/lib/codeclib.c
index 5af4e01fff..af0894c498 100644
--- a/apps/codecs/lib/codeclib.c
+++ b/apps/codecs/lib/codeclib.c
@@ -49,6 +49,19 @@ void codec_set_replaygain(struct mp3entry* id3)
49 ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak); 49 ci->configure(DSP_SET_ALBUM_PEAK, id3->album_peak);
50} 50}
51 51
52/* Note: codec really needs its own private metdata copy for the current
53 track being processed in order to be stable. */
54int codec_wait_taginfo(void)
55{
56 while (!*ci->taginfo_ready && !ci->stop_codec && !ci->new_track)
57 ci->sleep(0);
58 if (ci->stop_codec)
59 return -1;
60 if (ci->new_track)
61 return 1;
62 return 0;
63}
64
52/* Various "helper functions" common to all the xxx2wav decoder plugins */ 65/* Various "helper functions" common to all the xxx2wav decoder plugins */
53 66
54 67
diff --git a/apps/codecs/lib/codeclib.h b/apps/codecs/lib/codeclib.h
index b7685ebbcb..41b466ed1f 100644
--- a/apps/codecs/lib/codeclib.h
+++ b/apps/codecs/lib/codeclib.h
@@ -157,6 +157,7 @@ static inline unsigned int bs_generic(unsigned int v, int mode)
157 157
158int codec_init(void); 158int codec_init(void);
159void codec_set_replaygain(struct mp3entry* id3); 159void codec_set_replaygain(struct mp3entry* id3);
160int codec_wait_taginfo(void); /* 0 = success */
160 161
161#ifdef RB_PROFILE 162#ifdef RB_PROFILE
162void __cyg_profile_func_enter(void *this_fn, void *call_site) 163void __cyg_profile_func_enter(void *this_fn, void *call_site)
diff --git a/apps/codecs/mod.c b/apps/codecs/mod.c
index 3e2e4284de..4ace721a1e 100644
--- a/apps/codecs/mod.c
+++ b/apps/codecs/mod.c
@@ -1232,8 +1232,8 @@ next_track:
1232 return CODEC_ERROR; 1232 return CODEC_ERROR;
1233 } 1233 }
1234 1234
1235 while (!*ci->taginfo_ready && !ci->stop_codec) 1235 if (codec_wait_taginfo() != 0)
1236 ci->sleep(1); 1236 goto request_next_track;
1237 1237
1238 codec_set_replaygain(ci->id3); 1238 codec_set_replaygain(ci->id3);
1239 1239
@@ -1305,6 +1305,7 @@ next_track:
1305 1305
1306 } 1306 }
1307 1307
1308request_next_track:
1308 if (ci->request_next_track()) 1309 if (ci->request_next_track())
1309 goto next_track; 1310 goto next_track;
1310 1311
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c
index d3a09ce4fc..d3da63b430 100644
--- a/apps/codecs/mpa.c
+++ b/apps/codecs/mpa.c
@@ -325,15 +325,14 @@ enum codec_status codec_main(void)
325 return CODEC_ERROR; 325 return CODEC_ERROR;
326 326
327next_track: 327next_track:
328
329 status = CODEC_OK; 328 status = CODEC_OK;
330 329
331 /* Reinitializing seems to be necessary to avoid playback quircks when seeking. */ 330 /* Reinitializing seems to be necessary to avoid playback quircks when seeking. */
332 init_mad(); 331 init_mad();
333 332
334 file_end = 0; 333 file_end = 0;
335 while (!*ci->taginfo_ready && !ci->stop_codec) 334 if (codec_wait_taginfo() != 0)
336 ci->sleep(1); 335 goto request_next_track;
337 336
338 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency); 337 ci->configure(DSP_SWITCH_FREQUENCY, ci->id3->frequency);
339 current_frequency = ci->id3->frequency; 338 current_frequency = ci->id3->frequency;
@@ -505,6 +504,7 @@ next_track:
505 framelength - stop_skip); 504 framelength - stop_skip);
506 } 505 }
507 506
507request_next_track:
508 if (ci->request_next_track()) 508 if (ci->request_next_track())
509 goto next_track; 509 goto next_track;
510 510
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c
index 1d83449838..187c37e597 100644
--- a/apps/codecs/mpc.c
+++ b/apps/codecs/mpc.c
@@ -64,7 +64,7 @@ enum codec_status codec_main(void)
64 mpc_streaminfo info; 64 mpc_streaminfo info;
65 mpc_frame_info frame; 65 mpc_frame_info frame;
66 mpc_demux *demux = NULL; 66 mpc_demux *demux = NULL;
67 int retval = CODEC_OK; 67 int retval;
68 68
69 frame.buffer = sample_buffer; 69 frame.buffer = sample_buffer;
70 70
@@ -78,15 +78,17 @@ enum codec_status codec_main(void)
78 reader.tell = tell_impl; 78 reader.tell = tell_impl;
79 reader.get_size = get_size_impl; 79 reader.get_size = get_size_impl;
80 80
81next_track: 81next_track:
82 retval = CODEC_OK;
83
82 if (codec_init()) 84 if (codec_init())
83 { 85 {
84 retval = CODEC_ERROR; 86 retval = CODEC_ERROR;
85 goto exit; 87 goto exit;
86 } 88 }
87 89
88 while (!*ci->taginfo_ready && !ci->stop_codec) 90 if (codec_wait_taginfo() != 0)
89 ci->sleep(1); 91 goto done;
90 92
91 /* Initialize demux/decoder. */ 93 /* Initialize demux/decoder. */
92 demux = mpc_demux_init(&reader); 94 demux = mpc_demux_init(&reader);
diff --git a/apps/codecs/nsf.c b/apps/codecs/nsf.c
index f596f9dc68..2f37da81d2 100644
--- a/apps/codecs/nsf.c
+++ b/apps/codecs/nsf.c
@@ -4344,9 +4344,9 @@ next_track:
4344 4344
4345 4345
4346 /* wait for track info to load */ 4346 /* wait for track info to load */
4347 while (!*ci->taginfo_ready && !ci->stop_codec) 4347 if (codec_wait_taginfo() != 0)
4348 ci->sleep(1); 4348 goto request_next_track;
4349 4349
4350 codec_set_replaygain(ci->id3); 4350 codec_set_replaygain(ci->id3);
4351 4351
4352 /* Read the entire file */ 4352 /* Read the entire file */
@@ -4448,7 +4448,8 @@ init_nsf:
4448 } 4448 }
4449 4449
4450 print_timers(last_path,track); 4450 print_timers(last_path,track);
4451 4451
4452request_next_track:
4452 if (ci->request_next_track()) { 4453 if (ci->request_next_track()) {
4453 if (ci->global_settings->repeat_mode==REPEAT_ONE) { 4454 if (ci->global_settings->repeat_mode==REPEAT_ONE) {
4454 /* in repeat one mode just advance to the next track */ 4455 /* in repeat one mode just advance to the next track */
diff --git a/apps/codecs/raac.c b/apps/codecs/raac.c
index 3fcdca24c9..22d4b4b8b5 100644
--- a/apps/codecs/raac.c
+++ b/apps/codecs/raac.c
@@ -56,7 +56,7 @@ enum codec_status codec_main(void)
56 uint32_t s = 0; /* sample rate */ 56 uint32_t s = 0; /* sample rate */
57 unsigned char c = 0; /* channels */ 57 unsigned char c = 0; /* channels */
58 int playback_on = -1; 58 int playback_on = -1;
59 size_t resume_offset = ci->id3->offset; 59 size_t resume_offset;
60 60
61 /* Generic codec initialisation */ 61 /* Generic codec initialisation */
62 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); 62 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
@@ -70,8 +70,10 @@ next_track:
70 return CODEC_ERROR; 70 return CODEC_ERROR;
71 } 71 }
72 72
73 while (!*ci->taginfo_ready && !ci->stop_codec) 73 if (codec_wait_taginfo() != 0)
74 ci->sleep(1); 74 goto done;
75
76 resume_offset = ci->id3->offset;
75 77
76 ci->memset(&rmctx,0,sizeof(RMContext)); 78 ci->memset(&rmctx,0,sizeof(RMContext));
77 ci->memset(&pkt,0,sizeof(RMPacket)); 79 ci->memset(&pkt,0,sizeof(RMPacket));
@@ -224,8 +226,6 @@ seek_start:
224 ci->advance_buffer(pkt.length); 226 ci->advance_buffer(pkt.length);
225 } 227 }
226 228
227 err = CODEC_OK;
228
229done: 229done:
230 if (ci->request_next_track()) 230 if (ci->request_next_track())
231 goto next_track; 231 goto next_track;
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c
index 7595ca30c7..83a9c34da8 100644
--- a/apps/codecs/shorten.c
+++ b/apps/codecs/shorten.c
@@ -57,8 +57,8 @@ next_track:
57 return CODEC_ERROR; 57 return CODEC_ERROR;
58 } 58 }
59 59
60 while (!*ci->taginfo_ready) 60 if (codec_wait_taginfo() != 0)
61 ci->yield(); 61 goto request_next_track;
62 62
63 codec_set_replaygain(ci->id3); 63 codec_set_replaygain(ci->id3);
64 64
@@ -153,6 +153,7 @@ seek_start:
153 sc.bitindex = sc.gb.index - 8*consumed; 153 sc.bitindex = sc.gb.index - 8*consumed;
154 } 154 }
155 155
156request_next_track:
156 if (ci->request_next_track()) 157 if (ci->request_next_track())
157 goto next_track; 158 goto next_track;
158 159
diff --git a/apps/codecs/sid.c b/apps/codecs/sid.c
index 455bdbc28a..52c1289fff 100644
--- a/apps/codecs/sid.c
+++ b/apps/codecs/sid.c
@@ -1220,8 +1220,8 @@ next_track:
1220 return CODEC_ERROR; 1220 return CODEC_ERROR;
1221 } 1221 }
1222 1222
1223 while (!*ci->taginfo_ready && !ci->stop_codec) 1223 if (codec_wait_taginfo() != 0)
1224 ci->sleep(1); 1224 goto request_next_track;
1225 1225
1226 codec_set_replaygain(ci->id3); 1226 codec_set_replaygain(ci->id3);
1227 1227
@@ -1306,6 +1306,7 @@ next_track:
1306 ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE); 1306 ci->pcmbuf_insert(samples, NULL, CHUNK_SIZE);
1307 } 1307 }
1308 1308
1309request_next_track:
1309 if (ci->request_next_track()) 1310 if (ci->request_next_track())
1310 goto next_track; 1311 goto next_track;
1311 1312
diff --git a/apps/codecs/smaf.c b/apps/codecs/smaf.c
index 6763e95001..3e8a41387d 100644
--- a/apps/codecs/smaf.c
+++ b/apps/codecs/smaf.c
@@ -334,7 +334,7 @@ static uint8_t *read_buffer(size_t *realsize)
334 334
335enum codec_status codec_main(void) 335enum codec_status codec_main(void)
336{ 336{
337 int status = CODEC_OK; 337 int status;
338 uint32_t decodedsamples; 338 uint32_t decodedsamples;
339 size_t n; 339 size_t n;
340 int bufcount; 340 int bufcount;
@@ -347,13 +347,15 @@ enum codec_status codec_main(void)
347 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 347 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
348 348
349next_track: 349next_track:
350 status = CODEC_OK;
351
350 if (codec_init()) { 352 if (codec_init()) {
351 status = CODEC_ERROR; 353 status = CODEC_ERROR;
352 goto exit; 354 goto exit;
353 } 355 }
354 356
355 while (!*ci->taginfo_ready && !ci->stop_codec) 357 if (codec_wait_taginfo() != 0)
356 ci->sleep(1); 358 goto done;
357 359
358 codec_set_replaygain(ci->id3); 360 codec_set_replaygain(ci->id3);
359 361
@@ -479,7 +481,6 @@ next_track:
479 481
480 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 482 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
481 } 483 }
482 status = CODEC_OK;
483 484
484done: 485done:
485 if (ci->request_next_track()) 486 if (ci->request_next_track())
diff --git a/apps/codecs/spc.c b/apps/codecs/spc.c
index 3a06a228ef..d4ed741f7e 100644
--- a/apps/codecs/spc.c
+++ b/apps/codecs/spc.c
@@ -553,8 +553,8 @@ enum codec_status codec_main(void)
553 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED); 553 ci->configure(DSP_SET_STEREO_MODE, STEREO_NONINTERLEAVED);
554 554
555 /* wait for track info to load */ 555 /* wait for track info to load */
556 while (!*ci->taginfo_ready && !ci->stop_codec) 556 if (codec_wait_taginfo() != 0)
557 ci->yield(); 557 continue;
558 558
559 codec_set_replaygain(ci->id3); 559 codec_set_replaygain(ci->id3);
560 560
diff --git a/apps/codecs/speex.c b/apps/codecs/speex.c
index 2a02ccb4b5..e38a04495c 100644
--- a/apps/codecs/speex.c
+++ b/apps/codecs/speex.c
@@ -371,7 +371,7 @@ static void *process_header(spx_ogg_packet *op,
371enum codec_status codec_main(void) 371enum codec_status codec_main(void)
372{ 372{
373 SpeexBits bits; 373 SpeexBits bits;
374 int error = 0; 374 int error;
375 int eof = 0; 375 int eof = 0;
376 spx_ogg_sync_state oy; 376 spx_ogg_sync_state oy;
377 spx_ogg_page og; 377 spx_ogg_page og;
@@ -395,16 +395,18 @@ enum codec_status codec_main(void)
395 395
396 /* Ogg handling still uses mallocs, so reset the malloc buffer per track */ 396 /* Ogg handling still uses mallocs, so reset the malloc buffer per track */
397next_track: 397next_track:
398 error = CODEC_OK;
398 399
399 if (codec_init()) { 400 if (codec_init()) {
400 error = CODEC_ERROR; 401 error = CODEC_ERROR;
401 goto exit; 402 goto exit;
402 } 403 }
403 stereo = speex_stereo_state_init(); 404 stereo = speex_stereo_state_init();
404 strtoffset = ci->id3->offset;
405 405
406 while (!*ci->taginfo_ready && !ci->stop_codec) 406 if (codec_wait_taginfo() != 0)
407 ci->sleep(1); 407 goto done;
408
409 strtoffset = ci->id3->offset;
408 410
409 spx_ogg_sync_init(&oy); 411 spx_ogg_sync_init(&oy);
410 spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE); 412 spx_ogg_alloc_buffer(&oy,2*CHUNKSIZE);
@@ -569,8 +571,6 @@ done:
569 goto next_track; 571 goto next_track;
570 } 572 }
571 573
572 error = CODEC_OK;
573
574exit: 574exit:
575 speex_bits_destroy(&bits); 575 speex_bits_destroy(&bits);
576 576
diff --git a/apps/codecs/tta.c b/apps/codecs/tta.c
index 2d531315a2..1d0846ea61 100644
--- a/apps/codecs/tta.c
+++ b/apps/codecs/tta.c
@@ -37,7 +37,7 @@ static int32_t samples[PCM_BUFFER_LENGTH * 2] IBSS_ATTR;
37enum codec_status codec_main(void) 37enum codec_status codec_main(void)
38{ 38{
39 tta_info info; 39 tta_info info;
40 int status = CODEC_OK; 40 int status;
41 unsigned int decodedsamples; 41 unsigned int decodedsamples;
42 int endofstream; 42 int endofstream;
43 int new_pos = 0; 43 int new_pos = 0;
@@ -47,6 +47,8 @@ enum codec_status codec_main(void)
47 ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1); 47 ci->configure(DSP_SET_SAMPLE_DEPTH, TTA_OUTPUT_DEPTH - 1);
48 48
49next_track: 49next_track:
50 status = CODEC_OK;
51
50 if (codec_init()) 52 if (codec_init())
51 { 53 {
52 DEBUGF("codec_init() error\n"); 54 DEBUGF("codec_init() error\n");
@@ -54,8 +56,8 @@ next_track:
54 goto exit; 56 goto exit;
55 } 57 }
56 58
57 while (!*ci->taginfo_ready && !ci->stop_codec) 59 if (codec_wait_taginfo() != 0)
58 ci->sleep(1); 60 goto done;
59 61
60 if (set_tta_info(&info) < 0 || player_init(&info) < 0) 62 if (set_tta_info(&info) < 0 || player_init(&info) < 0)
61 { 63 {
@@ -117,7 +119,7 @@ next_track:
117 endofstream = 1; 119 endofstream = 1;
118 ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH); 120 ci->set_elapsed((uint64_t)info.LENGTH * 1000 * decodedsamples / info.DATALENGTH);
119 } 121 }
120 status = CODEC_OK; 122
121done: 123done:
122 player_stop(); 124 player_stop();
123 if (ci->request_next_track()) 125 if (ci->request_next_track())
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c
index cb621e8a55..17cc4a03f9 100644
--- a/apps/codecs/vorbis.c
+++ b/apps/codecs/vorbis.c
@@ -136,10 +136,12 @@ enum codec_status codec_main(void)
136#endif 136#endif
137 137
138next_track: 138next_track:
139 error = CODEC_OK;
140
139 ogg_malloc_init(); 141 ogg_malloc_init();
140 142
141 while (!*ci->taginfo_ready && !ci->stop_codec) 143 if (codec_wait_taginfo() != 0)
142 ci->sleep(1); 144 goto done;
143 145
144 /* Create a decoder instance */ 146 /* Create a decoder instance */
145 callbacks.read_func = read_handler; 147 callbacks.read_func = read_handler;
@@ -233,8 +235,7 @@ next_track:
233 ci->set_elapsed(ov_time_tell(&vf)); 235 ci->set_elapsed(ov_time_tell(&vf));
234 } 236 }
235 } 237 }
236 error = CODEC_OK; 238
237
238done: 239done:
239#if 0 /* defined(SIMULATOR) */ 240#if 0 /* defined(SIMULATOR) */
240 { 241 {
diff --git a/apps/codecs/vox.c b/apps/codecs/vox.c
index ff5d571e8d..c7f39342c3 100644
--- a/apps/codecs/vox.c
+++ b/apps/codecs/vox.c
@@ -46,7 +46,7 @@ static uint8_t *read_buffer(size_t *realsize)
46/* this is the codec entry point */ 46/* this is the codec entry point */
47enum codec_status codec_main(void) 47enum codec_status codec_main(void)
48{ 48{
49 int status = CODEC_OK; 49 int status;
50 uint32_t decodedsamples; 50 uint32_t decodedsamples;
51 size_t n; 51 size_t n;
52 int bufcount; 52 int bufcount;
@@ -59,14 +59,16 @@ enum codec_status codec_main(void)
59 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 59 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
60 60
61next_track: 61next_track:
62 status = CODEC_OK;
63
62 if (codec_init()) { 64 if (codec_init()) {
63 DEBUGF("codec_init() error\n"); 65 DEBUGF("codec_init() error\n");
64 status = CODEC_ERROR; 66 status = CODEC_ERROR;
65 goto exit; 67 goto exit;
66 } 68 }
67 69
68 while (!*ci->taginfo_ready && !ci->stop_codec) 70 if (codec_wait_taginfo() != 0)
69 ci->sleep(1); 71 goto done;
70 72
71 codec_set_replaygain(ci->id3); 73 codec_set_replaygain(ci->id3);
72 74
@@ -189,7 +191,6 @@ next_track:
189 endofstream = 1; 191 endofstream = 1;
190 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 192 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
191 } 193 }
192 status = CODEC_OK;
193 194
194done: 195done:
195 if (ci->request_next_track()) 196 if (ci->request_next_track())
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c
index e286f4dc6a..e179470f27 100644
--- a/apps/codecs/wav.c
+++ b/apps/codecs/wav.c
@@ -153,7 +153,7 @@ static uint8_t *read_buffer(size_t *realsize)
153/* this is the codec entry point */ 153/* this is the codec entry point */
154enum codec_status codec_main(void) 154enum codec_status codec_main(void)
155{ 155{
156 int status = CODEC_OK; 156 int status;
157 uint32_t decodedsamples; 157 uint32_t decodedsamples;
158 size_t n; 158 size_t n;
159 int bufcount; 159 int bufcount;
@@ -168,14 +168,16 @@ enum codec_status codec_main(void)
168 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 168 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
169 169
170next_track: 170next_track:
171 status = CODEC_OK;
172
171 if (codec_init()) { 173 if (codec_init()) {
172 DEBUGF("codec_init() error\n"); 174 DEBUGF("codec_init() error\n");
173 status = CODEC_ERROR; 175 status = CODEC_ERROR;
174 goto exit; 176 goto exit;
175 } 177 }
176 178
177 while (!*ci->taginfo_ready && !ci->stop_codec) 179 if (codec_wait_taginfo() != 0)
178 ci->sleep(1); 180 goto done;
179 181
180 codec_set_replaygain(ci->id3); 182 codec_set_replaygain(ci->id3);
181 183
@@ -437,7 +439,6 @@ next_track:
437 endofstream = 1; 439 endofstream = 1;
438 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency); 440 ci->set_elapsed(decodedsamples*1000LL/ci->id3->frequency);
439 } 441 }
440 status = CODEC_OK;
441 442
442done: 443done:
443 if (ci->request_next_track()) 444 if (ci->request_next_track())
diff --git a/apps/codecs/wav64.c b/apps/codecs/wav64.c
index c06f78c802..9dbdab8368 100644
--- a/apps/codecs/wav64.c
+++ b/apps/codecs/wav64.c
@@ -161,7 +161,7 @@ static uint8_t *read_buffer(size_t *realsize)
161/* this is the codec entry point */ 161/* this is the codec entry point */
162enum codec_status codec_main(void) 162enum codec_status codec_main(void)
163{ 163{
164 int status = CODEC_OK; 164 int status;
165 uint32_t decodedsamples; 165 uint32_t decodedsamples;
166 size_t n; 166 size_t n;
167 int bufcount; 167 int bufcount;
@@ -176,14 +176,16 @@ enum codec_status codec_main(void)
176 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1); 176 ci->configure(DSP_SET_SAMPLE_DEPTH, PCM_OUTPUT_DEPTH-1);
177 177
178next_track: 178next_track:
179 status = CODEC_OK;
180
179 if (codec_init()) { 181 if (codec_init()) {
180 DEBUGF("codec_init() error\n"); 182 DEBUGF("codec_init() error\n");
181 status = CODEC_ERROR; 183 status = CODEC_ERROR;
182 goto exit; 184 goto exit;
183 } 185 }
184 186
185 while (!*ci->taginfo_ready && !ci->stop_codec) 187 if (codec_wait_taginfo() != 0)
186 ci->sleep(1); 188 goto done;
187 189
188 codec_set_replaygain(ci->id3); 190 codec_set_replaygain(ci->id3);
189 191
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c
index c85c254580..d27a9fb621 100644
--- a/apps/codecs/wavpack.c
+++ b/apps/codecs/wavpack.c
@@ -46,15 +46,16 @@ enum codec_status codec_main(void)
46 /* Generic codec initialisation */ 46 /* Generic codec initialisation */
47 ci->configure(DSP_SET_SAMPLE_DEPTH, 28); 47 ci->configure(DSP_SET_SAMPLE_DEPTH, 28);
48 48
49 next_track: 49next_track:
50 retval = CODEC_OK;
50 51
51 if (codec_init()) { 52 if (codec_init()) {
52 retval = CODEC_ERROR; 53 retval = CODEC_ERROR;
53 goto exit; 54 goto exit;
54 } 55 }
55 56
56 while (!*ci->taginfo_ready && !ci->stop_codec) 57 if (codec_wait_taginfo() != 0)
57 ci->sleep(1); 58 goto done;
58 59
59 /* Create a decoder instance */ 60 /* Create a decoder instance */
60 wpc = WavpackOpenFileInput (read_callback, error); 61 wpc = WavpackOpenFileInput (read_callback, error);
@@ -121,7 +122,6 @@ enum codec_status codec_main(void)
121 ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10); 122 ci->set_elapsed (WavpackGetSampleIndex (wpc) / sr_100 * 10);
122 ci->yield (); 123 ci->yield ();
123 } 124 }
124 retval = CODEC_OK;
125 125
126done: 126done:
127 if (ci->request_next_track()) 127 if (ci->request_next_track())
diff --git a/apps/codecs/wma.c b/apps/codecs/wma.c
index e740373cfc..1b46813444 100644
--- a/apps/codecs/wma.c
+++ b/apps/codecs/wma.c
@@ -46,19 +46,22 @@ enum codec_status codec_main(void)
46 ci->configure(DSP_SET_SAMPLE_DEPTH, 29); 46 ci->configure(DSP_SET_SAMPLE_DEPTH, 29);
47 47
48next_track: 48next_track:
49 retval = CODEC_OK;
50
49 /* Proper reset of the decoder context. */ 51 /* Proper reset of the decoder context. */
50 memset(&wmadec, 0, sizeof(wmadec)); 52 memset(&wmadec, 0, sizeof(wmadec));
51 53
52 /* Wait for the metadata to be read */ 54 /* Wait for the metadata to be read */
53 while (!*ci->taginfo_ready && !ci->stop_codec) 55 if (codec_wait_taginfo() != 0)
54 ci->sleep(1); 56 goto done;
55
56 retval = CODEC_OK;
57 57
58 /* Remember the resume position - when the codec is opened, the 58 /* Remember the resume position - when the codec is opened, the
59 playback engine will reset it. */ 59 playback engine will reset it. */
60 resume_offset = ci->id3->offset; 60 resume_offset = ci->id3->offset;
61
61restart_track: 62restart_track:
63 retval = CODEC_OK;
64
62 if (codec_init()) { 65 if (codec_init()) {
63 LOGF("WMA: Error initialising codec\n"); 66 LOGF("WMA: Error initialising codec\n");
64 retval = CODEC_ERROR; 67 retval = CODEC_ERROR;
@@ -176,7 +179,6 @@ new_packet:
176 179
177 ci->advance_buffer(packetlength); 180 ci->advance_buffer(packetlength);
178 } 181 }
179 retval = CODEC_OK;
180 182
181done: 183done:
182 /*LOGF("WMA: Decoded %ld samples\n",elapsedtime*wfx.rate/1000);*/ 184 /*LOGF("WMA: Decoded %ld samples\n",elapsedtime*wfx.rate/1000);*/
diff --git a/apps/codecs/wmapro.c b/apps/codecs/wmapro.c
index 75bbd24cda..c02dddeeb3 100644
--- a/apps/codecs/wmapro.c
+++ b/apps/codecs/wmapro.c
@@ -48,16 +48,18 @@ enum codec_status codec_main(void)
48 48
49 49
50next_track: 50next_track:
51 retval = CODEC_OK;
51 52
52 /* Wait for the metadata to be read */ 53 /* Wait for the metadata to be read */
53 while (!*ci->taginfo_ready && !ci->stop_codec) 54 if (codec_wait_taginfo() != 0)
54 ci->sleep(1); 55 goto done;
55
56 retval = CODEC_OK;
57 56
58 /* Remember the resume position */ 57 /* Remember the resume position */
59 resume_offset = ci->id3->offset; 58 resume_offset = ci->id3->offset;
60 restart_track: 59
60restart_track:
61 retval = CODEC_OK;
62
61 if (codec_init()) { 63 if (codec_init()) {
62 LOGF("(WMA PRO) Error: Error initialising codec\n"); 64 LOGF("(WMA PRO) Error: Error initialising codec\n");
63 retval = CODEC_ERROR; 65 retval = CODEC_ERROR;
@@ -149,7 +151,6 @@ next_track:
149 /* Advance to the next logical packet */ 151 /* Advance to the next logical packet */
150 ci->advance_buffer(packetlength); 152 ci->advance_buffer(packetlength);
151 } 153 }
152 retval = CODEC_OK;
153 154
154done: 155done:
155 if (ci->request_next_track()) 156 if (ci->request_next_track())
diff --git a/apps/codecs/wmavoice.c b/apps/codecs/wmavoice.c
index 904af23b99..ddf66828f1 100644
--- a/apps/codecs/wmavoice.c
+++ b/apps/codecs/wmavoice.c
@@ -70,16 +70,17 @@ enum codec_status codec_main(void)
70 70
71 71
72next_track: 72next_track:
73 retval = CODEC_OK;
73 74
74 /* Wait for the metadata to be read */ 75 /* Wait for the metadata to be read */
75 while (!*ci->taginfo_ready && !ci->stop_codec) 76 if (codec_wait_taginfo() != 0)
76 ci->sleep(1); 77 goto done;
77
78 retval = CODEC_OK;
79 78
80 /* Remember the resume position */ 79 /* Remember the resume position */
81 resume_offset = ci->id3->offset; 80 resume_offset = ci->id3->offset;
82 restart_track: 81restart_track:
82 retval = CODEC_OK;
83
83 if (codec_init()) { 84 if (codec_init()) {
84 LOGF("(WMA Voice) Error: Error initialising codec\n"); 85 LOGF("(WMA Voice) Error: Error initialising codec\n");
85 retval = CODEC_ERROR; 86 retval = CODEC_ERROR;
@@ -184,7 +185,6 @@ new_packet:
184 /* Advance to the next logical packet */ 185 /* Advance to the next logical packet */
185 ci->advance_buffer(packetlength); 186 ci->advance_buffer(packetlength);
186 } 187 }
187 retval = CODEC_OK;
188 188
189done: 189done:
190 if (ci->request_next_track()) 190 if (ci->request_next_track())