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 | |
parent | a9203b4d8352d9de761c5baf95314ff189242ec0 (diff) |
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')
-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) #include <dlfcn.h> #endif +void *sim_codec_load_ram(char* codecptr, int size, + void* ptr2, int bufwrap, int *pd_fd) +{ + void *pd; + char *path = "archos/_temp_codec.dll"; + int (*codec_start)(void * api); + int fd; + int copy_n; +#ifdef WIN32 + char buf[256]; +#endif + + /* We have to create the dynamic link library file from ram + * so we could simulate the codec loading. + */ + *pd_fd = -1; + fd = open(path, O_WRONLY | O_CREAT, S_IRWXU); + if (fd < 0) { + DEBUGF("failed to open for write: %s\n", path); + return NULL; + } + + if (bufwrap == 0) + bufwrap = size; + + copy_n = bufwrap < size ? bufwrap : size; + if (write(fd, codecptr, copy_n) != copy_n) { + DEBUGF("write failed"); + return NULL; + } + size -= copy_n; + if (size > 0) { + if (write(fd, ptr2, size) != size) { + DEBUGF("write failed [2]"); + return NULL; + } + } + close(fd); + + /* Now load the library. */ + pd = dlopen(path, RTLD_NOW); + if (!pd) { + DEBUGF("failed to load %s\n", path); +#ifdef WIN32 + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, + buf, sizeof buf, NULL); + DEBUGF("dlopen(%s): %s\n", path, buf); +#else + DEBUGF("dlopen(%s): %s\n", path, dlerror()); +#endif + dlclose(pd); + return NULL; + } + + codec_start = dlsym(pd, "codec_start"); + if (!codec_start) { + codec_start = dlsym(pd, "_codec_start"); + if (!codec_start) { + dlclose(pd); + return NULL; + } + } + + *pd_fd = (int)pd; + return codec_start; +} + +void sim_codec_close(int pd) +{ + dlclose((void *)pd); +} + void *sim_plugin_load(char *plugin, int *fd) { void* pd; |