summaryrefslogtreecommitdiffstats
path: root/uisimulator
diff options
context:
space:
mode:
authorSteve Bavin <pondlife@pondlife.me>2006-09-28 08:46:28 +0000
committerSteve Bavin <pondlife@pondlife.me>2006-09-28 08:46:28 +0000
commit8c9d5f35f005140629d116a09d75e36ddc44f4f3 (patch)
tree8f6f4263212d5b747d831d6e1f02c210569047ec /uisimulator
parent076ab8d206549f9d8b1454994d1ce43f15c618dc (diff)
downloadrockbox-8c9d5f35f005140629d116a09d75e36ddc44f4f3.tar.gz
rockbox-8c9d5f35f005140629d116a09d75e36ddc44f4f3.tar.bz2
rockbox-8c9d5f35f005140629d116a09d75e36ddc44f4f3.zip
Improve simulator use of multiple codecs
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11083 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'uisimulator')
-rw-r--r--uisimulator/common/io.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/uisimulator/common/io.c b/uisimulator/common/io.c
index 241bcfc3a1..34bcef483c 100644
--- a/uisimulator/common/io.c
+++ b/uisimulator/common/io.c
@@ -331,28 +331,31 @@ void *sim_codec_load_ram(char* codecptr, int size,
char path[MAX_PATH];
int fd;
int copy_n;
- static int codec_count = 0;
+ int codec_count;
#ifdef WIN32
char buf[256];
#endif
*pd = NULL;
- /* We have to create the dynamic link library file from ram
- so we could simulate the codec loading. */
-
- sprintf(path, TEMP_CODEC_FILE, codec_count);
-
- /* if voice is enabled, two codecs may be loaded at same time */
- if (!codec_count)
- codec_count++;
-
-#ifdef WIN32
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
-#else
- fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
-#endif
- if (fd < 0) {
+ /* We have to create the dynamic link library file from ram so we
+ can simulate the codec loading. With voice and crossfade,
+ multiple codecs may be loaded at the same time, so we need
+ to find an unused filename */
+ for (codec_count = 0; codec_count < 10; codec_count++)
+ {
+ sprintf(path, TEMP_CODEC_FILE, codec_count);
+
+ #ifdef WIN32
+ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, S_IRWXU);
+ #else
+ fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRWXU);
+ #endif
+ if (fd >= 0)
+ break; /* Created a file ok */
+ }
+ if (fd < 0)
+ {
DEBUGF("failed to open for write: %s\n", path);
return NULL;
}