summaryrefslogtreecommitdiff
path: root/apps/codecs/mpc.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/mpc.c')
-rw-r--r--apps/codecs/mpc.c33
1 files changed, 23 insertions, 10 deletions
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
113next_track: 114next_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;
197exit:
198 return retval;
186} 199}
187 200