summaryrefslogtreecommitdiff
path: root/uisimulator/common/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r--uisimulator/common/io.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 1871b29395..68eb8933a5 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -306,20 +306,20 @@ int sim_fsync(int fd)
306void *sim_codec_load_ram(char* codecptr, int size, 306void *sim_codec_load_ram(char* codecptr, int size,
307 void* ptr2, int bufwrap, int *pd_fd) 307 void* ptr2, int bufwrap, int *pd_fd)
308{ 308{
309 void *pd; 309 void *pd, *hdr;
310 char *path = "archos/_temp_codec.dll"; 310 const char *path = "archos/_temp_codec.dll";
311 int (*codec_start)(void * api);
312 int fd; 311 int fd;
313 int copy_n; 312 int copy_n;
314#ifdef WIN32 313#ifdef WIN32
315 char buf[256]; 314 char buf[256];
316#endif 315#endif
317 316
317 *pd_fd = 0;
318
318 /* We have to create the dynamic link library file from ram 319 /* We have to create the dynamic link library file from ram
319 * so we could simulate the codec loading. 320 so we could simulate the codec loading. */
320 */ 321
321 *pd_fd = -1; 322 fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
322 fd = open(path, O_WRONLY | O_CREAT, S_IRWXU);
323 if (fd < 0) { 323 if (fd < 0) {
324 DEBUGF("failed to open for write: %s\n", path); 324 DEBUGF("failed to open for write: %s\n", path);
325 return NULL; 325 return NULL;
@@ -341,7 +341,7 @@ void *sim_codec_load_ram(char* codecptr, int size,
341 } 341 }
342 } 342 }
343 close(fd); 343 close(fd);
344 344
345 /* Now load the library. */ 345 /* Now load the library. */
346 pd = dlopen(path, RTLD_NOW); 346 pd = dlopen(path, RTLD_NOW);
347 if (!pd) { 347 if (!pd) {
@@ -357,17 +357,12 @@ void *sim_codec_load_ram(char* codecptr, int size,
357 return NULL; 357 return NULL;
358 } 358 }
359 359
360 codec_start = dlsym(pd, "codec_start"); 360 hdr = dlsym(pd, "__header");
361 if (!codec_start) { 361 if (!hdr)
362 codec_start = dlsym(pd, "_codec_start"); 362 hdr = dlsym(pd, "___header");
363 if (!codec_start) {
364 dlclose(pd);
365 return NULL;
366 }
367 }
368 363
369 *pd_fd = (int)pd; 364 *pd_fd = (int)pd;
370 return codec_start; 365 return hdr; /* maybe NULL if symbol not present */
371} 366}
372 367
373void sim_codec_close(int pd) 368void sim_codec_close(int pd)