diff options
Diffstat (limited to 'apps/codecs.c')
-rw-r--r-- | apps/codecs.c | 57 |
1 files changed, 35 insertions, 22 deletions
diff --git a/apps/codecs.c b/apps/codecs.c index 646d5f289b..86e36edcf0 100644 --- a/apps/codecs.c +++ b/apps/codecs.c | |||
@@ -97,7 +97,6 @@ struct codec_api ci = { | |||
97 | NULL, /* seek_buffer */ | 97 | NULL, /* seek_buffer */ |
98 | NULL, /* seek_complete */ | 98 | NULL, /* seek_complete */ |
99 | NULL, /* request_next_track */ | 99 | NULL, /* request_next_track */ |
100 | NULL, /* discard_codec */ | ||
101 | NULL, /* set_offset */ | 100 | NULL, /* set_offset */ |
102 | NULL, /* configure */ | 101 | NULL, /* configure */ |
103 | 102 | ||
@@ -149,8 +148,6 @@ struct codec_api ci = { | |||
149 | #endif | 148 | #endif |
150 | 149 | ||
151 | #ifdef HAVE_RECORDING | 150 | #ifdef HAVE_RECORDING |
152 | false, /* stop_encoder */ | ||
153 | 0, /* enc_codec_loaded */ | ||
154 | enc_get_inputs, | 151 | enc_get_inputs, |
155 | enc_set_parameters, | 152 | enc_set_parameters, |
156 | enc_get_chunk, | 153 | enc_get_chunk, |
@@ -178,11 +175,10 @@ void codec_get_full_path(char *path, const char *codec_root_fn) | |||
178 | CODECS_DIR, codec_root_fn); | 175 | CODECS_DIR, codec_root_fn); |
179 | } | 176 | } |
180 | 177 | ||
181 | static int codec_load_ram(void *handle, struct codec_api *api) | 178 | static void * codec_load_ram(void *handle, struct codec_api *api) |
182 | { | 179 | { |
183 | struct codec_header *c_hdr = lc_get_header(handle); | 180 | struct codec_header *c_hdr = lc_get_header(handle); |
184 | struct lc_header *hdr = c_hdr ? &c_hdr->lc_hdr : NULL; | 181 | struct lc_header *hdr = c_hdr ? &c_hdr->lc_hdr : NULL; |
185 | int status; | ||
186 | 182 | ||
187 | if (hdr == NULL | 183 | if (hdr == NULL |
188 | || (hdr->magic != CODEC_MAGIC | 184 | || (hdr->magic != CODEC_MAGIC |
@@ -199,14 +195,14 @@ static int codec_load_ram(void *handle, struct codec_api *api) | |||
199 | { | 195 | { |
200 | logf("codec header error"); | 196 | logf("codec header error"); |
201 | lc_close(handle); | 197 | lc_close(handle); |
202 | return CODEC_ERROR; | 198 | return NULL; |
203 | } | 199 | } |
204 | 200 | ||
205 | if (hdr->api_version > CODEC_API_VERSION | 201 | if (hdr->api_version > CODEC_API_VERSION |
206 | || hdr->api_version < CODEC_MIN_API_VERSION) { | 202 | || hdr->api_version < CODEC_MIN_API_VERSION) { |
207 | logf("codec api version error"); | 203 | logf("codec api version error"); |
208 | lc_close(handle); | 204 | lc_close(handle); |
209 | return CODEC_ERROR; | 205 | return NULL; |
210 | } | 206 | } |
211 | 207 | ||
212 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 208 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
@@ -216,34 +212,31 @@ static int codec_load_ram(void *handle, struct codec_api *api) | |||
216 | #endif | 212 | #endif |
217 | 213 | ||
218 | *(c_hdr->api) = api; | 214 | *(c_hdr->api) = api; |
219 | status = c_hdr->entry_point(); | ||
220 | 215 | ||
221 | lc_close(handle); | 216 | return handle; |
222 | |||
223 | return status; | ||
224 | } | 217 | } |
225 | 218 | ||
226 | int codec_load_buf(unsigned int hid, struct codec_api *api) | 219 | void * codec_load_buf(int hid, struct codec_api *api) |
227 | { | 220 | { |
228 | int rc; | 221 | int rc; |
229 | void *handle; | 222 | void *handle; |
230 | rc = bufread(hid, CODEC_SIZE, codecbuf); | 223 | rc = bufread(hid, CODEC_SIZE, codecbuf); |
231 | if (rc < 0) { | 224 | if (rc < 0) { |
232 | logf("error loading codec"); | 225 | logf("Codec: cannot read buf handle"); |
233 | return CODEC_ERROR; | 226 | return NULL; |
234 | } | 227 | } |
228 | |||
235 | handle = lc_open_from_mem(codecbuf, rc); | 229 | handle = lc_open_from_mem(codecbuf, rc); |
236 | if (handle == NULL) | 230 | |
237 | { | 231 | if (handle == NULL) { |
238 | logf("error loading codec"); | 232 | logf("error loading codec"); |
239 | return CODEC_ERROR; | 233 | return NULL; |
240 | } | 234 | } |
241 | 235 | ||
242 | api->discard_codec(); | ||
243 | return codec_load_ram(handle, api); | 236 | return codec_load_ram(handle, api); |
244 | } | 237 | } |
245 | 238 | ||
246 | int codec_load_file(const char *plugin, struct codec_api *api) | 239 | void * codec_load_file(const char *plugin, struct codec_api *api) |
247 | { | 240 | { |
248 | char path[MAX_PATH]; | 241 | char path[MAX_PATH]; |
249 | void *handle; | 242 | void *handle; |
@@ -253,10 +246,30 @@ int codec_load_file(const char *plugin, struct codec_api *api) | |||
253 | handle = lc_open(path, codecbuf, CODEC_SIZE); | 246 | handle = lc_open(path, codecbuf, CODEC_SIZE); |
254 | 247 | ||
255 | if (handle == NULL) { | 248 | if (handle == NULL) { |
256 | logf("Codec load error"); | 249 | logf("Codec: cannot read file"); |
257 | splashf(HZ*2, "Couldn't load codec: %s", path); | 250 | return NULL; |
258 | return CODEC_ERROR; | ||
259 | } | 251 | } |
260 | 252 | ||
261 | return codec_load_ram(handle, api); | 253 | return codec_load_ram(handle, api); |
262 | } | 254 | } |
255 | |||
256 | int codec_begin(void *handle) | ||
257 | { | ||
258 | int status = CODEC_ERROR; | ||
259 | struct codec_header *c_hdr; | ||
260 | |||
261 | c_hdr = lc_get_header(handle); | ||
262 | |||
263 | if (c_hdr != NULL) { | ||
264 | logf("Codec: calling entry_point"); | ||
265 | status = c_hdr->entry_point(); | ||
266 | } | ||
267 | |||
268 | return status; | ||
269 | } | ||
270 | |||
271 | void codec_close(void *handle) | ||
272 | { | ||
273 | if (handle) | ||
274 | lc_close(handle); | ||
275 | } | ||