diff options
Diffstat (limited to 'apps/codecs')
-rw-r--r-- | apps/codecs/a52.c | 11 | ||||
-rw-r--r-- | apps/codecs/aac.c | 22 | ||||
-rw-r--r-- | apps/codecs/alac.c | 17 | ||||
-rw-r--r-- | apps/codecs/flac.c | 16 | ||||
-rw-r--r-- | apps/codecs/mpa.c | 7 | ||||
-rw-r--r-- | apps/codecs/mpc.c | 33 | ||||
-rw-r--r-- | apps/codecs/shorten.c | 14 | ||||
-rw-r--r-- | apps/codecs/vorbis.c | 14 | ||||
-rw-r--r-- | apps/codecs/wav.c | 55 | ||||
-rw-r--r-- | apps/codecs/wavpack.c | 17 |
10 files changed, 141 insertions, 65 deletions
diff --git a/apps/codecs/a52.c b/apps/codecs/a52.c index f12fce1027..ff8fe0afea 100644 --- a/apps/codecs/a52.c +++ b/apps/codecs/a52.c | |||
@@ -129,6 +129,7 @@ enum codec_status codec_start(struct codec_api *api) | |||
129 | long n; | 129 | long n; |
130 | unsigned char *filebuf; | 130 | unsigned char *filebuf; |
131 | int sample_loc; | 131 | int sample_loc; |
132 | int retval; | ||
132 | 133 | ||
133 | /* Generic codec initialisation */ | 134 | /* Generic codec initialisation */ |
134 | ci = api; | 135 | ci = api; |
@@ -147,8 +148,10 @@ enum codec_status codec_start(struct codec_api *api) | |||
147 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128)); | 148 | ci->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*128)); |
148 | 149 | ||
149 | next_track: | 150 | next_track: |
150 | if (codec_init(api)) | 151 | if (codec_init(api)) { |
151 | return CODEC_ERROR; | 152 | retval = CODEC_ERROR; |
153 | goto exit; | ||
154 | } | ||
152 | 155 | ||
153 | while (!ci->taginfo_ready) | 156 | while (!ci->taginfo_ready) |
154 | ci->yield(); | 157 | ci->yield(); |
@@ -184,6 +187,8 @@ next_track: | |||
184 | } | 187 | } |
185 | if (ci->request_next_track()) | 188 | if (ci->request_next_track()) |
186 | goto next_track; | 189 | goto next_track; |
190 | retval = CODEC_OK; | ||
191 | exit: | ||
187 | a52_free(state); | 192 | a52_free(state); |
188 | return CODEC_OK; | 193 | return retval; |
189 | } | 194 | } |
diff --git a/apps/codecs/aac.c b/apps/codecs/aac.c index baa3935175..06a0e16527 100644 --- a/apps/codecs/aac.c +++ b/apps/codecs/aac.c | |||
@@ -72,7 +72,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
72 | 72 | ||
73 | if (codec_init(api)) { | 73 | if (codec_init(api)) { |
74 | LOGF("FAAD: Error initialising codec\n"); | 74 | LOGF("FAAD: Error initialising codec\n"); |
75 | return CODEC_ERROR; | 75 | err = CODEC_ERROR; |
76 | goto exit; | ||
76 | } | 77 | } |
77 | 78 | ||
78 | while (!rb->taginfo_ready) | 79 | while (!rb->taginfo_ready) |
@@ -86,7 +87,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
86 | * the movie data, which can be used directly by the decoder */ | 87 | * the movie data, which can be used directly by the decoder */ |
87 | if (!qtmovie_read(&input_stream, &demux_res)) { | 88 | if (!qtmovie_read(&input_stream, &demux_res)) { |
88 | LOGF("FAAD: Error initialising file\n"); | 89 | LOGF("FAAD: Error initialising file\n"); |
89 | return CODEC_ERROR; | 90 | err = CODEC_ERROR; |
91 | goto exit; | ||
90 | } | 92 | } |
91 | 93 | ||
92 | /* initialise the sound converter */ | 94 | /* initialise the sound converter */ |
@@ -95,7 +97,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
95 | 97 | ||
96 | if (!hDecoder) { | 98 | if (!hDecoder) { |
97 | LOGF("FAAD: Error opening decoder\n"); | 99 | LOGF("FAAD: Error opening decoder\n"); |
98 | return CODEC_ERROR; | 100 | err = CODEC_ERROR; |
101 | goto exit; | ||
99 | } | 102 | } |
100 | 103 | ||
101 | NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hDecoder); | 104 | NeAACDecConfigurationPtr conf = NeAACDecGetCurrentConfiguration(hDecoder); |
@@ -108,7 +111,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
108 | err = NeAACDecInit2(hDecoder, demux_res.codecdata,demux_res.codecdata_len, &s, &c); | 111 | err = NeAACDecInit2(hDecoder, demux_res.codecdata,demux_res.codecdata_len, &s, &c); |
109 | if (err) { | 112 | if (err) { |
110 | LOGF("FAAD: Error initialising decoder: %d, type=%d\n", err,hDecoder->object_type); | 113 | LOGF("FAAD: Error initialising decoder: %d, type=%d\n", err,hDecoder->object_type); |
111 | return CODEC_ERROR; | 114 | err = CODEC_ERROR; |
115 | goto exit; | ||
112 | } | 116 | } |
113 | 117 | ||
114 | ci->id3->frequency=s; | 118 | ci->id3->frequency=s; |
@@ -137,7 +141,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
137 | if (!get_sample_info(&demux_res, i, &sample_duration, | 141 | if (!get_sample_info(&demux_res, i, &sample_duration, |
138 | &sample_byte_size)) { | 142 | &sample_byte_size)) { |
139 | LOGF("AAC: Error in get_sample_info\n"); | 143 | LOGF("AAC: Error in get_sample_info\n"); |
140 | return CODEC_ERROR; | 144 | err = CODEC_ERROR; |
145 | goto exit; | ||
141 | } | 146 | } |
142 | 147 | ||
143 | /* Request the required number of bytes from the input buffer */ | 148 | /* Request the required number of bytes from the input buffer */ |
@@ -150,7 +155,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
150 | decoder struct directly */ | 155 | decoder struct directly */ |
151 | if (frameInfo.error > 0) { | 156 | if (frameInfo.error > 0) { |
152 | LOGF("FAAD: decoding error \"%s\"\n", NeAACDecGetErrorMessage(frameInfo.error)); | 157 | LOGF("FAAD: decoding error \"%s\"\n", NeAACDecGetErrorMessage(frameInfo.error)); |
153 | return CODEC_ERROR; | 158 | err = CODEC_ERROR; |
159 | goto exit; | ||
154 | } | 160 | } |
155 | 161 | ||
156 | /* Get the number of decoded samples */ | 162 | /* Get the number of decoded samples */ |
@@ -182,5 +188,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
182 | if (ci->request_next_track()) | 188 | if (ci->request_next_track()) |
183 | goto next_track; | 189 | goto next_track; |
184 | 190 | ||
185 | return CODEC_OK; | 191 | err = CODEC_OK; |
192 | exit: | ||
193 | return err; | ||
186 | } | 194 | } |
diff --git a/apps/codecs/alac.c b/apps/codecs/alac.c index 7ca70ce83c..a1c4f41683 100644 --- a/apps/codecs/alac.c +++ b/apps/codecs/alac.c | |||
@@ -50,6 +50,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
50 | unsigned int i; | 50 | unsigned int i; |
51 | unsigned char* buffer; | 51 | unsigned char* buffer; |
52 | alac_file alac; | 52 | alac_file alac; |
53 | int retval; | ||
53 | 54 | ||
54 | /* Generic codec initialisation */ | 55 | /* Generic codec initialisation */ |
55 | rb = api; | 56 | rb = api; |
@@ -72,7 +73,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
72 | 73 | ||
73 | if (codec_init(api)) { | 74 | if (codec_init(api)) { |
74 | LOGF("ALAC: Error initialising codec\n"); | 75 | LOGF("ALAC: Error initialising codec\n"); |
75 | return CODEC_ERROR; | 76 | retval = CODEC_ERROR; |
77 | goto exit; | ||
76 | } | 78 | } |
77 | 79 | ||
78 | while (!rb->taginfo_ready) | 80 | while (!rb->taginfo_ready) |
@@ -86,7 +88,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
86 | * the movie data, which can be used directly by the decoder */ | 88 | * the movie data, which can be used directly by the decoder */ |
87 | if (!qtmovie_read(&input_stream, &demux_res)) { | 89 | if (!qtmovie_read(&input_stream, &demux_res)) { |
88 | LOGF("ALAC: Error initialising file\n"); | 90 | LOGF("ALAC: Error initialising file\n"); |
89 | return CODEC_ERROR; | 91 | retval = CODEC_ERROR; |
92 | goto exit; | ||
90 | } | 93 | } |
91 | 94 | ||
92 | /* initialise the sound converter */ | 95 | /* initialise the sound converter */ |
@@ -117,14 +120,16 @@ enum codec_status codec_start(struct codec_api* api) | |||
117 | if (!get_sample_info(&demux_res, i, &sample_duration, | 120 | if (!get_sample_info(&demux_res, i, &sample_duration, |
118 | &sample_byte_size)) { | 121 | &sample_byte_size)) { |
119 | LOGF("ALAC: Error in get_sample_info\n"); | 122 | LOGF("ALAC: Error in get_sample_info\n"); |
120 | return CODEC_ERROR; | 123 | retval = CODEC_ERROR; |
124 | goto exit; | ||
121 | } | 125 | } |
122 | 126 | ||
123 | /* Request the required number of bytes from the input buffer */ | 127 | /* Request the required number of bytes from the input buffer */ |
124 | 128 | ||
125 | buffer=ci->request_buffer((long*)&n,sample_byte_size); | 129 | buffer=ci->request_buffer((long*)&n,sample_byte_size); |
126 | if (n!=sample_byte_size) { | 130 | if (n!=sample_byte_size) { |
127 | return CODEC_ERROR; | 131 | retval = CODEC_ERROR; |
132 | goto exit; | ||
128 | } | 133 | } |
129 | 134 | ||
130 | /* Decode one block - returned samples will be host-endian */ | 135 | /* Decode one block - returned samples will be host-endian */ |
@@ -157,5 +162,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
157 | if (ci->request_next_track()) | 162 | if (ci->request_next_track()) |
158 | goto next_track; | 163 | goto next_track; |
159 | 164 | ||
160 | return CODEC_OK; | 165 | retval = CODEC_OK; |
166 | exit: | ||
167 | return retval; | ||
161 | } | 168 | } |
diff --git a/apps/codecs/flac.c b/apps/codecs/flac.c index a96963dd80..4782c95d55 100644 --- a/apps/codecs/flac.c +++ b/apps/codecs/flac.c | |||
@@ -226,6 +226,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
226 | int consumed; | 226 | int consumed; |
227 | int res; | 227 | int res; |
228 | int frame; | 228 | int frame; |
229 | int retval; | ||
229 | 230 | ||
230 | /* Generic codec initialisation */ | 231 | /* Generic codec initialisation */ |
231 | rb = api; | 232 | rb = api; |
@@ -243,17 +244,19 @@ enum codec_status codec_start(struct codec_api* api) | |||
243 | ci->configure(DSP_DITHER, (bool *)false); | 244 | ci->configure(DSP_DITHER, (bool *)false); |
244 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); | 245 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); |
245 | ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(FLAC_OUTPUT_DEPTH-1)); | 246 | ci->configure(DSP_SET_SAMPLE_DEPTH, (int *)(FLAC_OUTPUT_DEPTH-1)); |
246 | 247 | ||
247 | next_track: | 248 | next_track: |
248 | 249 | ||
249 | if (codec_init(api)) { | 250 | if (codec_init(api)) { |
250 | LOGF("FLAC: Error initialising codec\n"); | 251 | LOGF("FLAC: Error initialising codec\n"); |
251 | return CODEC_ERROR; | 252 | retval = CODEC_ERROR; |
253 | goto exit; | ||
252 | } | 254 | } |
253 | 255 | ||
254 | if (!flac_init(&fc,ci->id3->first_frame_offset)) { | 256 | if (!flac_init(&fc,ci->id3->first_frame_offset)) { |
255 | LOGF("FLAC: Error initialising codec\n"); | 257 | LOGF("FLAC: Error initialising codec\n"); |
256 | return CODEC_ERROR; | 258 | retval = CODEC_ERROR; |
259 | goto exit; | ||
257 | } | 260 | } |
258 | 261 | ||
259 | while (!*ci->taginfo_ready) | 262 | while (!*ci->taginfo_ready) |
@@ -284,7 +287,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
284 | if((res=flac_decode_frame(&fc,decoded0,decoded1,buf, | 287 | if((res=flac_decode_frame(&fc,decoded0,decoded1,buf, |
285 | bytesleft,ci->yield)) < 0) { | 288 | bytesleft,ci->yield)) < 0) { |
286 | LOGF("FLAC: Frame %d, error %d\n",frame,res); | 289 | LOGF("FLAC: Frame %d, error %d\n",frame,res); |
287 | return CODEC_ERROR; | 290 | retval = CODEC_ERROR; |
291 | goto exit; | ||
288 | } | 292 | } |
289 | consumed=fc.gb.index/8; | 293 | consumed=fc.gb.index/8; |
290 | frame++; | 294 | frame++; |
@@ -309,5 +313,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
309 | if (ci->request_next_track()) | 313 | if (ci->request_next_track()) |
310 | goto next_track; | 314 | goto next_track; |
311 | 315 | ||
312 | return CODEC_OK; | 316 | retval = CODEC_OK; |
317 | exit: | ||
318 | return retval; | ||
313 | } | 319 | } |
diff --git a/apps/codecs/mpa.c b/apps/codecs/mpa.c index 3c57f3f33f..3ee2b352f1 100644 --- a/apps/codecs/mpa.c +++ b/apps/codecs/mpa.c | |||
@@ -75,7 +75,7 @@ void recalc_samplecount(void) | |||
75 | /* this is the codec entry point */ | 75 | /* this is the codec entry point */ |
76 | enum codec_status codec_start(struct codec_api *api) | 76 | enum codec_status codec_start(struct codec_api *api) |
77 | { | 77 | { |
78 | int status = 0; | 78 | int status = CODEC_OK; |
79 | long size; | 79 | long size; |
80 | int file_end; | 80 | int file_end; |
81 | int frame_skip; /* samples to skip current frame */ | 81 | int frame_skip; /* samples to skip current frame */ |
@@ -193,7 +193,7 @@ next_track: | |||
193 | continue; | 193 | continue; |
194 | } else { | 194 | } else { |
195 | /* Some other unrecoverable error */ | 195 | /* Some other unrecoverable error */ |
196 | status = 1; | 196 | status = CODEC_ERROR; |
197 | break; | 197 | break; |
198 | } | 198 | } |
199 | break; | 199 | break; |
@@ -264,5 +264,6 @@ next_track: | |||
264 | 264 | ||
265 | if (ci->request_next_track()) | 265 | if (ci->request_next_track()) |
266 | goto next_track; | 266 | goto next_track; |
267 | return CODEC_OK; | 267 | |
268 | return status; | ||
268 | } | 269 | } |
diff --git a/apps/codecs/mpc.c b/apps/codecs/mpc.c index 1d1ed3a8b7..67c0eaa3de 100644 --- a/apps/codecs/mpc.c +++ b/apps/codecs/mpc.c | |||
@@ -83,6 +83,7 @@ enum codec_status codec_start(struct codec_api *api) | |||
83 | unsigned status; | 83 | unsigned status; |
84 | mpc_reader reader; | 84 | mpc_reader reader; |
85 | mpc_streaminfo info; | 85 | mpc_streaminfo info; |
86 | int retval; | ||
86 | 87 | ||
87 | #ifdef USE_IRAM | 88 | #ifdef USE_IRAM |
88 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); | 89 | ci->memcpy(iramstart, iramcopy, iramend - iramstart); |
@@ -111,13 +112,17 @@ enum codec_status codec_start(struct codec_api *api) | |||
111 | reader.data = ci; | 112 | reader.data = ci; |
112 | 113 | ||
113 | next_track: | 114 | next_track: |
114 | if (codec_init(api)) | 115 | if (codec_init(api)) { |
115 | return CODEC_ERROR; | 116 | retval = CODEC_ERROR; |
117 | goto exit; | ||
118 | } | ||
116 | 119 | ||
117 | /* read file's streaminfo data */ | 120 | /* read file's streaminfo data */ |
118 | mpc_streaminfo_init(&info); | 121 | mpc_streaminfo_init(&info); |
119 | if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) | 122 | if (mpc_streaminfo_read(&info, &reader) != ERROR_CODE_OK) { |
120 | return CODEC_ERROR; | 123 | retval = CODEC_ERROR; |
124 | goto exit; | ||
125 | } | ||
121 | frequency = info.sample_freq; | 126 | frequency = info.sample_freq; |
122 | ci->configure(DSP_SET_FREQUENCY, (long *)info.sample_freq); | 127 | ci->configure(DSP_SET_FREQUENCY, (long *)info.sample_freq); |
123 | 128 | ||
@@ -128,14 +133,18 @@ next_track: | |||
128 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); | 133 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_NONINTERLEAVED); |
129 | else if (info.channels == 1) | 134 | else if (info.channels == 1) |
130 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_MONO); | 135 | ci->configure(DSP_SET_STEREO_MODE, (long *)STEREO_MONO); |
131 | else | 136 | else { |
132 | return CODEC_ERROR; | 137 | retval = CODEC_ERROR; |
138 | goto exit; | ||
139 | } | ||
133 | 140 | ||
134 | codec_set_replaygain(ci->id3); | 141 | codec_set_replaygain(ci->id3); |
135 | /* instantiate a decoder with our file reader */ | 142 | /* instantiate a decoder with our file reader */ |
136 | mpc_decoder_setup(&decoder, &reader); | 143 | mpc_decoder_setup(&decoder, &reader); |
137 | if (!mpc_decoder_initialize(&decoder, &info)) | 144 | if (!mpc_decoder_initialize(&decoder, &info)) { |
138 | return CODEC_ERROR; | 145 | retval = CODEC_ERROR; |
146 | goto exit; | ||
147 | } | ||
139 | 148 | ||
140 | /* This is the decoding loop. */ | 149 | /* This is the decoding loop. */ |
141 | samplesdone = 0; | 150 | samplesdone = 0; |
@@ -169,7 +178,8 @@ next_track: | |||
169 | status = mpc_decoder_decode(&decoder, sample_buffer, NULL, NULL); | 178 | status = mpc_decoder_decode(&decoder, sample_buffer, NULL, NULL); |
170 | ci->yield(); | 179 | ci->yield(); |
171 | if (status == (unsigned)(-1)) { /* decode error */ | 180 | if (status == (unsigned)(-1)) { /* decode error */ |
172 | return CODEC_ERROR; | 181 | retval = CODEC_ERROR; |
182 | goto exit; | ||
173 | } else { | 183 | } else { |
174 | while (!ci->pcmbuf_insert_split(sample_buffer, | 184 | while (!ci->pcmbuf_insert_split(sample_buffer, |
175 | sample_buffer + MPC_FRAME_LENGTH, | 185 | sample_buffer + MPC_FRAME_LENGTH, |
@@ -182,6 +192,9 @@ next_track: | |||
182 | 192 | ||
183 | if (ci->request_next_track()) | 193 | if (ci->request_next_track()) |
184 | goto next_track; | 194 | goto next_track; |
185 | return CODEC_OK; | 195 | |
196 | retval = CODEC_OK; | ||
197 | exit: | ||
198 | return retval; | ||
186 | } | 199 | } |
187 | 200 | ||
diff --git a/apps/codecs/shorten.c b/apps/codecs/shorten.c index ffbd42a9ff..290686e968 100644 --- a/apps/codecs/shorten.c +++ b/apps/codecs/shorten.c | |||
@@ -50,6 +50,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
50 | int8_t *buf; | 50 | int8_t *buf; |
51 | int cur_chan, consumed, res; | 51 | int cur_chan, consumed, res; |
52 | long bytesleft; | 52 | long bytesleft; |
53 | int retval; | ||
53 | 54 | ||
54 | /* Generic codec initialisation */ | 55 | /* Generic codec initialisation */ |
55 | rb = api; | 56 | rb = api; |
@@ -72,7 +73,8 @@ next_track: | |||
72 | /* Codec initialization */ | 73 | /* Codec initialization */ |
73 | if (codec_init(api)) { | 74 | if (codec_init(api)) { |
74 | LOGF("Shorten: Error initialising codec\n"); | 75 | LOGF("Shorten: Error initialising codec\n"); |
75 | return CODEC_ERROR; | 76 | retval = CODEC_ERROR; |
77 | goto exit; | ||
76 | } | 78 | } |
77 | 79 | ||
78 | while (!*ci->taginfo_ready) | 80 | while (!*ci->taginfo_ready) |
@@ -92,7 +94,8 @@ next_track: | |||
92 | res = shorten_init(&sc, (unsigned char *)buf, bytesleft); | 94 | res = shorten_init(&sc, (unsigned char *)buf, bytesleft); |
93 | if (res < 0) { | 95 | if (res < 0) { |
94 | LOGF("shorten_init error: %d\n", res); | 96 | LOGF("shorten_init error: %d\n", res); |
95 | return CODEC_ERROR; | 97 | retval = CODEC_ERROR; |
98 | goto exit; | ||
96 | } | 99 | } |
97 | 100 | ||
98 | ci->id3->frequency = sc.sample_rate; | 101 | ci->id3->frequency = sc.sample_rate; |
@@ -169,7 +172,8 @@ seek_start: | |||
169 | break; | 172 | break; |
170 | } else if (res < 0) { | 173 | } else if (res < 0) { |
171 | LOGF("shorten_decode_frame error: \n", res); | 174 | LOGF("shorten_decode_frame error: \n", res); |
172 | return CODEC_ERROR; | 175 | retval = CODEC_ERROR; |
176 | goto exit; | ||
173 | } | 177 | } |
174 | 178 | ||
175 | consumed = sc.gb.index/8; | 179 | consumed = sc.gb.index/8; |
@@ -183,5 +187,7 @@ seek_start: | |||
183 | if (ci->request_next_track()) | 187 | if (ci->request_next_track()) |
184 | goto next_track; | 188 | goto next_track; |
185 | 189 | ||
186 | return CODEC_OK; | 190 | retval = CODEC_OK; |
191 | exit: | ||
192 | return retval; | ||
187 | } | 193 | } |
diff --git a/apps/codecs/vorbis.c b/apps/codecs/vorbis.c index fdd7a952d4..e77ecada0c 100644 --- a/apps/codecs/vorbis.c +++ b/apps/codecs/vorbis.c | |||
@@ -145,11 +145,11 @@ enum codec_status codec_start(struct codec_api *api) | |||
145 | */ | 145 | */ |
146 | rb->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256)); | 146 | rb->configure(CODEC_SET_FILEBUF_CHUNKSIZE, (long *)(1024*256)); |
147 | 147 | ||
148 | |||
149 | /* We need to flush reserver memory every track load. */ | 148 | /* We need to flush reserver memory every track load. */ |
150 | next_track: | 149 | next_track: |
151 | if (codec_init(rb)) { | 150 | if (codec_init(rb)) { |
152 | return CODEC_ERROR; | 151 | error = CODEC_ERROR; |
152 | goto exit; | ||
153 | } | 153 | } |
154 | 154 | ||
155 | while (!*rb->taginfo_ready && !rb->stop_codec) | 155 | while (!*rb->taginfo_ready && !rb->stop_codec) |
@@ -195,7 +195,8 @@ next_track: | |||
195 | vf.links = 1; | 195 | vf.links = 1; |
196 | } else { | 196 | } else { |
197 | //rb->logf("ov_open: %d", error); | 197 | //rb->logf("ov_open: %d", error); |
198 | return CODEC_ERROR; | 198 | error = CODEC_ERROR; |
199 | goto exit; | ||
199 | } | 200 | } |
200 | 201 | ||
201 | if (rb->id3->offset) { | 202 | if (rb->id3->offset) { |
@@ -224,7 +225,8 @@ next_track: | |||
224 | /* Change DSP and buffer settings for this bitstream */ | 225 | /* Change DSP and buffer settings for this bitstream */ |
225 | if (current_section != previous_section) { | 226 | if (current_section != previous_section) { |
226 | if (!vorbis_set_codec_parameters(&vf)) { | 227 | if (!vorbis_set_codec_parameters(&vf)) { |
227 | return CODEC_ERROR; | 228 | error = CODEC_ERROR; |
229 | goto exit; | ||
228 | } else { | 230 | } else { |
229 | previous_section = current_section; | 231 | previous_section = current_section; |
230 | } | 232 | } |
@@ -255,6 +257,8 @@ next_track: | |||
255 | goto next_track; | 257 | goto next_track; |
256 | } | 258 | } |
257 | 259 | ||
258 | return CODEC_OK; | 260 | error = CODEC_OK; |
261 | exit: | ||
262 | return error; | ||
259 | } | 263 | } |
260 | 264 | ||
diff --git a/apps/codecs/wav.c b/apps/codecs/wav.c index 1dda2c3d58..ca4b4750f4 100644 --- a/apps/codecs/wav.c +++ b/apps/codecs/wav.c | |||
@@ -248,7 +248,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
248 | next_track: | 248 | next_track: |
249 | 249 | ||
250 | if (codec_init(api)) { | 250 | if (codec_init(api)) { |
251 | return CODEC_ERROR; | 251 | i = CODEC_ERROR; |
252 | goto exit; | ||
252 | } | 253 | } |
253 | 254 | ||
254 | while (!*ci->taginfo_ready) | 255 | while (!*ci->taginfo_ready) |
@@ -257,10 +258,12 @@ enum codec_status codec_start(struct codec_api* api) | |||
257 | /* assume the WAV header is less than 1024 bytes */ | 258 | /* assume the WAV header is less than 1024 bytes */ |
258 | buf=ci->request_buffer((long *)&n,1024); | 259 | buf=ci->request_buffer((long *)&n,1024); |
259 | if (n<44) { | 260 | if (n<44) { |
260 | return CODEC_ERROR; | 261 | i = CODEC_ERROR; |
262 | goto exit; | ||
261 | } | 263 | } |
262 | if ((memcmp(buf,"RIFF",4)!=0) || (memcmp(&buf[8],"WAVE",4)!=0)) { | 264 | if ((memcmp(buf,"RIFF",4)!=0) || (memcmp(&buf[8],"WAVE",4)!=0)) { |
263 | return CODEC_ERROR; | 265 | i = CODEC_ERROR; |
266 | goto exit; | ||
264 | } | 267 | } |
265 | 268 | ||
266 | buf += 12; | 269 | buf += 12; |
@@ -275,7 +278,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
275 | if (memcmp(buf,"fmt ",4)==0) { | 278 | if (memcmp(buf,"fmt ",4)==0) { |
276 | if (i<16) { | 279 | if (i<16) { |
277 | DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n",i); | 280 | DEBUGF("CODEC_ERROR: 'fmt ' chunk size=%lu < 16\n",i); |
278 | return CODEC_ERROR; | 281 | i = CODEC_ERROR; |
282 | goto exit; | ||
279 | } | 283 | } |
280 | /* wFormatTag */ | 284 | /* wFormatTag */ |
281 | formattag=buf[8]|(buf[9]<<8); | 285 | formattag=buf[8]|(buf[9]<<8); |
@@ -302,7 +306,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
302 | if (size < 2) { | 306 | if (size < 2) { |
303 | DEBUGF("CODEC_ERROR: dvi_adpcm is missing " | 307 | DEBUGF("CODEC_ERROR: dvi_adpcm is missing " |
304 | "SamplesPerBlock value\n"); | 308 | "SamplesPerBlock value\n"); |
305 | return CODEC_ERROR; | 309 | i = CODEC_ERROR; |
310 | goto exit; | ||
306 | } | 311 | } |
307 | samplesperblock = buf[26]|(buf[27]<<8); | 312 | samplesperblock = buf[26]|(buf[27]<<8); |
308 | } | 313 | } |
@@ -310,7 +315,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
310 | if (size < 22) { | 315 | if (size < 22) { |
311 | DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " | 316 | DEBUGF("CODEC_ERROR: WAVE_FORMAT_EXTENSIBLE is " |
312 | "missing extension\n"); | 317 | "missing extension\n"); |
313 | return CODEC_ERROR; | 318 | i = CODEC_ERROR; |
319 | goto exit; | ||
314 | } | 320 | } |
315 | /* wValidBitsPerSample */ | 321 | /* wValidBitsPerSample */ |
316 | bitspersample = buf[26]|(buf[27]<<8); | 322 | bitspersample = buf[26]|(buf[27]<<8); |
@@ -340,18 +346,21 @@ enum codec_status codec_start(struct codec_api* api) | |||
340 | buf += i+8; | 346 | buf += i+8; |
341 | if (n < (i+8)) { | 347 | if (n < (i+8)) { |
342 | DEBUGF("CODEC_ERROR: WAVE header size > 1024\n"); | 348 | DEBUGF("CODEC_ERROR: WAVE header size > 1024\n"); |
343 | return CODEC_ERROR; | 349 | i = CODEC_ERROR; |
350 | goto exit; | ||
344 | } | 351 | } |
345 | n -= i+8; | 352 | n -= i+8; |
346 | } | 353 | } |
347 | 354 | ||
348 | if (channels == 0) { | 355 | if (channels == 0) { |
349 | DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); | 356 | DEBUGF("CODEC_ERROR: 'fmt ' chunk not found or 0-channels file\n"); |
350 | return CODEC_ERROR; | 357 | i = CODEC_ERROR; |
358 | goto exit; | ||
351 | } | 359 | } |
352 | if (numbytes == 0) { | 360 | if (numbytes == 0) { |
353 | DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); | 361 | DEBUGF("CODEC_ERROR: 'data' chunk not found or has zero-length\n"); |
354 | return CODEC_ERROR; | 362 | i = CODEC_ERROR; |
363 | goto exit; | ||
355 | } | 364 | } |
356 | if (formattag != WAVE_FORMAT_PCM && totalsamples == 0) { | 365 | if (formattag != WAVE_FORMAT_PCM && totalsamples == 0) { |
357 | /* This is non-fatal for some formats */ | 366 | /* This is non-fatal for some formats */ |
@@ -361,19 +370,22 @@ enum codec_status codec_start(struct codec_api* api) | |||
361 | formattag == IBM_FORMAT_ALAW || formattag == IBM_FORMAT_MULAW) { | 370 | formattag == IBM_FORMAT_ALAW || formattag == IBM_FORMAT_MULAW) { |
362 | if (bitspersample != 8) { | 371 | if (bitspersample != 8) { |
363 | DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample\n"); | 372 | DEBUGF("CODEC_ERROR: alaw and mulaw must have 8 bitspersample\n"); |
364 | return CODEC_ERROR; | 373 | i = CODEC_ERROR; |
374 | goto exit; | ||
365 | } | 375 | } |
366 | bytespersample = channels; | 376 | bytespersample = channels; |
367 | } | 377 | } |
368 | if ( formattag == WAVE_FORMAT_DVI_ADPCM | 378 | if ( formattag == WAVE_FORMAT_DVI_ADPCM |
369 | && bitspersample != 4 && bitspersample != 3) { | 379 | && bitspersample != 4 && bitspersample != 3) { |
370 | DEBUGF("CODEC_ERROR: dvi_adpcm must have 3 or 4 bitspersample\n"); | 380 | DEBUGF("CODEC_ERROR: dvi_adpcm must have 3 or 4 bitspersample\n"); |
371 | return CODEC_ERROR; | 381 | i = CODEC_ERROR; |
382 | goto exit; | ||
372 | } | 383 | } |
373 | if (formattag == WAVE_FORMAT_PCM && bitspersample > 32) { | 384 | if (formattag == WAVE_FORMAT_PCM && bitspersample > 32) { |
374 | DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " | 385 | DEBUGF("CODEC_ERROR: pcm with more than 32 bitspersample " |
375 | "is unsupported\n"); | 386 | "is unsupported\n"); |
376 | return CODEC_ERROR; | 387 | i = CODEC_ERROR; |
388 | goto exit; | ||
377 | } | 389 | } |
378 | 390 | ||
379 | ci->configure(CODEC_DSP_ENABLE, (bool *)true); | 391 | ci->configure(CODEC_DSP_ENABLE, (bool *)true); |
@@ -395,7 +407,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
395 | ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO); | 407 | ci->configure(DSP_SET_STEREO_MODE, (int *)STEREO_MONO); |
396 | } else { | 408 | } else { |
397 | DEBUGF("CODEC_ERROR: more than 2 channels\n"); | 409 | DEBUGF("CODEC_ERROR: more than 2 channels\n"); |
398 | return CODEC_ERROR; | 410 | i = CODEC_ERROR; |
411 | goto exit; | ||
399 | } | 412 | } |
400 | 413 | ||
401 | if (totalsamples == 0) { | 414 | if (totalsamples == 0) { |
@@ -408,7 +421,8 @@ enum codec_status codec_start(struct codec_api* api) | |||
408 | } | 421 | } |
409 | else { | 422 | else { |
410 | DEBUGF("CODEC_ERROR: cannot compute totalsamples\n"); | 423 | DEBUGF("CODEC_ERROR: cannot compute totalsamples\n"); |
411 | return CODEC_ERROR; | 424 | i = CODEC_ERROR; |
425 | goto exit; | ||
412 | } | 426 | } |
413 | } | 427 | } |
414 | 428 | ||
@@ -519,15 +533,18 @@ enum codec_status codec_start(struct codec_api* api) | |||
519 | int16_samples+i*samplesperblock*channels, | 533 | int16_samples+i*samplesperblock*channels, |
520 | &decodedsize) | 534 | &decodedsize) |
521 | != CODEC_OK) | 535 | != CODEC_OK) |
522 | return CODEC_ERROR; | 536 | i = CODEC_ERROR; |
537 | goto exit; | ||
523 | if (decodedsize != samplesperblock) | 538 | if (decodedsize != samplesperblock) |
524 | return CODEC_ERROR; | 539 | i = CODEC_ERROR; |
540 | goto exit; | ||
525 | } | 541 | } |
526 | wavbufsize = nblocks*samplesperblock*channels*2; | 542 | wavbufsize = nblocks*samplesperblock*channels*2; |
527 | } | 543 | } |
528 | else { | 544 | else { |
529 | DEBUGF("CODEC_ERROR: unsupported format %x\n", formattag); | 545 | DEBUGF("CODEC_ERROR: unsupported format %x\n", formattag); |
530 | return CODEC_ERROR; | 546 | i = CODEC_ERROR; |
547 | goto exit; | ||
531 | } | 548 | } |
532 | 549 | ||
533 | while (!ci->pcmbuf_insert((char*)int16_samples, wavbufsize)) { | 550 | while (!ci->pcmbuf_insert((char*)int16_samples, wavbufsize)) { |
@@ -546,7 +563,9 @@ enum codec_status codec_start(struct codec_api* api) | |||
546 | if (ci->request_next_track()) | 563 | if (ci->request_next_track()) |
547 | goto next_track; | 564 | goto next_track; |
548 | 565 | ||
549 | return CODEC_OK; | 566 | i = CODEC_OK; |
567 | exit: | ||
568 | return i; | ||
550 | } | 569 | } |
551 | 570 | ||
552 | static enum codec_status | 571 | static enum codec_status |
diff --git a/apps/codecs/wavpack.c b/apps/codecs/wavpack.c index 2804d3ef72..19c7581e29 100644 --- a/apps/codecs/wavpack.c +++ b/apps/codecs/wavpack.c | |||
@@ -52,6 +52,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
52 | WavpackContext *wpc; | 52 | WavpackContext *wpc; |
53 | char error [80]; | 53 | char error [80]; |
54 | int bps, nchans, sr_100; | 54 | int bps, nchans, sr_100; |
55 | int retval; | ||
55 | 56 | ||
56 | /* Generic codec initialisation */ | 57 | /* Generic codec initialisation */ |
57 | ci = api; | 58 | ci = api; |
@@ -70,8 +71,10 @@ enum codec_status codec_start(struct codec_api* api) | |||
70 | 71 | ||
71 | next_track: | 72 | next_track: |
72 | 73 | ||
73 | if (codec_init(api)) | 74 | if (codec_init(api)) { |
74 | return CODEC_ERROR; | 75 | retval = CODEC_ERROR; |
76 | goto exit; | ||
77 | } | ||
75 | 78 | ||
76 | while (!*ci->taginfo_ready && !ci->stop_codec) | 79 | while (!*ci->taginfo_ready && !ci->stop_codec) |
77 | ci->sleep(1); | 80 | ci->sleep(1); |
@@ -94,8 +97,10 @@ enum codec_status codec_start(struct codec_api* api) | |||
94 | /* Create a decoder instance */ | 97 | /* Create a decoder instance */ |
95 | wpc = WavpackOpenFileInput (read_callback, error); | 98 | wpc = WavpackOpenFileInput (read_callback, error); |
96 | 99 | ||
97 | if (!wpc) | 100 | if (!wpc) { |
98 | return CODEC_ERROR; | 101 | retval = CODEC_ERROR; |
102 | goto exit; | ||
103 | } | ||
99 | 104 | ||
100 | bps = WavpackGetBytesPerSample (wpc); | 105 | bps = WavpackGetBytesPerSample (wpc); |
101 | nchans = WavpackGetReducedChannels (wpc); | 106 | nchans = WavpackGetReducedChannels (wpc); |
@@ -206,5 +211,7 @@ enum codec_status codec_start(struct codec_api* api) | |||
206 | if (ci->request_next_track()) | 211 | if (ci->request_next_track()) |
207 | goto next_track; | 212 | goto next_track; |
208 | 213 | ||
209 | return CODEC_OK; | 214 | retval = CODEC_OK; |
215 | exit: | ||
216 | return retval; | ||
210 | } | 217 | } |