diff options
author | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-10 16:33:03 +0000 |
---|---|---|
committer | Miika Pekkarinen <miipekk@ihme.org> | 2005-07-10 16:33:03 +0000 |
commit | 645a2e16ed645c30858e3b494ba2ff7d00b7a09b (patch) | |
tree | be5da24477ae465c77342947de6ef73c57505e0d /uisimulator/common/io.c | |
parent | a9203b4d8352d9de761c5baf95314ff189242ec0 (diff) | |
download | rockbox-645a2e16ed645c30858e3b494ba2ff7d00b7a09b.tar.gz rockbox-645a2e16ed645c30858e3b494ba2ff7d00b7a09b.zip |
Fixed a simulator crash while trying to play a song. Fixed crossfade
when selecting a new track to play. Most likely fixed a bug which
caused playback to stop on track change.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@7094 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator/common/io.c')
-rw-r--r-- | uisimulator/common/io.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c index 78fb835785..7ea2d6878f 100644 --- a/uisimulator/common/io.c +++ b/uisimulator/common/io.c | |||
@@ -307,6 +307,78 @@ int sim_fsync(int fd) | |||
307 | #include <dlfcn.h> | 307 | #include <dlfcn.h> |
308 | #endif | 308 | #endif |
309 | 309 | ||
310 | void *sim_codec_load_ram(char* codecptr, int size, | ||
311 | void* ptr2, int bufwrap, int *pd_fd) | ||
312 | { | ||
313 | void *pd; | ||
314 | char *path = "archos/_temp_codec.dll"; | ||
315 | int (*codec_start)(void * api); | ||
316 | int fd; | ||
317 | int copy_n; | ||
318 | #ifdef WIN32 | ||
319 | char buf[256]; | ||
320 | #endif | ||
321 | |||
322 | /* We have to create the dynamic link library file from ram | ||
323 | * so we could simulate the codec loading. | ||
324 | */ | ||
325 | *pd_fd = -1; | ||
326 | fd = open(path, O_WRONLY | O_CREAT, S_IRWXU); | ||
327 | if (fd < 0) { | ||
328 | DEBUGF("failed to open for write: %s\n", path); | ||
329 | return NULL; | ||
330 | } | ||
331 | |||
332 | if (bufwrap == 0) | ||
333 | bufwrap = size; | ||
334 | |||
335 | copy_n = bufwrap < size ? bufwrap : size; | ||
336 | if (write(fd, codecptr, copy_n) != copy_n) { | ||
337 | DEBUGF("write failed"); | ||
338 | return NULL; | ||
339 | } | ||
340 | size -= copy_n; | ||
341 | if (size > 0) { | ||
342 | if (write(fd, ptr2, size) != size) { | ||
343 | DEBUGF("write failed [2]"); | ||
344 | return NULL; | ||
345 | } | ||
346 | } | ||
347 | close(fd); | ||
348 | |||
349 | /* Now load the library. */ | ||
350 | pd = dlopen(path, RTLD_NOW); | ||
351 | if (!pd) { | ||
352 | DEBUGF("failed to load %s\n", path); | ||
353 | #ifdef WIN32 | ||
354 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, | ||
355 | buf, sizeof buf, NULL); | ||
356 | DEBUGF("dlopen(%s): %s\n", path, buf); | ||
357 | #else | ||
358 | DEBUGF("dlopen(%s): %s\n", path, dlerror()); | ||
359 | #endif | ||
360 | dlclose(pd); | ||
361 | return NULL; | ||
362 | } | ||
363 | |||
364 | codec_start = dlsym(pd, "codec_start"); | ||
365 | if (!codec_start) { | ||
366 | codec_start = dlsym(pd, "_codec_start"); | ||
367 | if (!codec_start) { | ||
368 | dlclose(pd); | ||
369 | return NULL; | ||
370 | } | ||
371 | } | ||
372 | |||
373 | *pd_fd = (int)pd; | ||
374 | return codec_start; | ||
375 | } | ||
376 | |||
377 | void sim_codec_close(int pd) | ||
378 | { | ||
379 | dlclose((void *)pd); | ||
380 | } | ||
381 | |||
310 | void *sim_plugin_load(char *plugin, int *fd) | 382 | void *sim_plugin_load(char *plugin, int *fd) |
311 | { | 383 | { |
312 | void* pd; | 384 | void* pd; |