summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Nielsen Feltzing <linus@haxx.se>2006-08-15 18:01:42 +0000
committerLinus Nielsen Feltzing <linus@haxx.se>2006-08-15 18:01:42 +0000
commit42f0ad3c8f11a699f4ce7d500b91e195e1a619e3 (patch)
treef58d7c1e1153a3ab96441ea857b5ac36e3f14e65
parent599fa9a6279a4e7dda4b6a46bef6bf4958bb0399 (diff)
downloadrockbox-42f0ad3c8f11a699f4ce7d500b91e195e1a619e3.zip
rockbox-42f0ad3c8f11a699f4ce7d500b91e195e1a619e3.tar.gz
rockbox-42f0ad3c8f11a699f4ce7d500b91e195e1a619e3.tar.bz2
rockbox-42f0ad3c8f11a699f4ce7d500b91e195e1a619e3.tar.xz
Patch #5766 by Steve Bavin - Fix for various voice related crashes
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@10590 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/playback.c23
-rw-r--r--apps/settings_menu.c8
-rw-r--r--apps/talk.c17
-rw-r--r--apps/talk.h1
4 files changed, 37 insertions, 12 deletions
diff --git a/apps/playback.c b/apps/playback.c
index 890a2d7..ef93177 100644
--- a/apps/playback.c
+++ b/apps/playback.c
@@ -481,9 +481,13 @@ static void* get_voice_memory_callback(size_t *size)
static void* get_codec_memory_callback(size_t *size)
{
*size = MALLOC_BUFSIZE;
+#if CONFIG_CODEC != SWCODEC
+ /* MASCODEC cannot play audio and voice simultaneously, so its
+ voice strategy is different - see talk.c for details */
if (voice_codec_loaded)
return &audiobuf[talk_get_bufsize()];
else
+#endif
return audiobuf;
}
@@ -2559,7 +2563,7 @@ static void reset_buffer(void)
filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE -
(pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2);
- if (talk_get_bufsize())
+ if (talk_voice_required())
{
filebuf = &filebuf[talk_get_bufsize()];
filebuflen -= 2*CODEC_IRAM_SIZE + 2*CODEC_SIZE + talk_get_bufsize();
@@ -2569,8 +2573,17 @@ static void reset_buffer(void)
iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE];
#endif
dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
- dram_buf[1] =
- (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE];
+ dram_buf[1] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE];
+ }
+ else
+ {
+ filebuf = &filebuf[talk_get_bufsize()];
+ filebuflen -= CODEC_IRAM_SIZE + CODEC_SIZE + talk_get_bufsize();
+
+#ifndef SIMULATOR
+ iram_buf[0] = &filebuf[filebuflen];
+#endif
+ dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
}
/* Ensure that everything is aligned */
@@ -2616,8 +2629,8 @@ void voice_init(void)
voice_codec_loaded = false;
}
- if (!talk_get_bufsize())
- return ;
+ if (!talk_voice_required())
+ return;
logf("Starting voice codec");
queue_init(&voice_codec_queue);
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 48e8c1d..4484115 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1264,16 +1264,20 @@ static const struct opt_items voice_names[] = {
static bool voice_dirs(void)
{
- return set_option( str(LANG_VOICE_DIR),
+ bool ret = set_option( str(LANG_VOICE_DIR),
&global_settings.talk_dir, INT, voice_names, 4, NULL);
+ audio_set_crossfade(global_settings.crossfade);
+ return ret;
}
static bool voice_files(void)
{
int oldval = global_settings.talk_file;
bool ret;
+
ret = set_option( str(LANG_VOICE_FILE),
&global_settings.talk_file, INT, voice_names, 4, NULL);
+ audio_set_crossfade(global_settings.crossfade);
if (oldval != 3 && global_settings.talk_file == 3)
{ /* force reload if newly talking thumbnails,
because the clip presence is cached only if enabled */
@@ -1462,9 +1466,7 @@ static bool crossfade(void)
ret=set_option( str(LANG_CROSSFADE_ENABLE),
&global_settings.crossfade, INT, names, 4, NULL);
-
audio_set_crossfade(global_settings.crossfade);
-
return ret;
}
diff --git a/apps/talk.c b/apps/talk.c
index 736c68c..8f507eb 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -146,10 +146,6 @@ static int open_voicefile(void)
return open(buf, O_RDONLY);
}
-int talk_get_bufsize(void)
-{
- return voicefile_size;
-}
/* load the voice file into the mp3 buffer */
static void load_voicefile(void)
@@ -532,6 +528,19 @@ void talk_init(void)
}
}
+/* return if a voice codec is required or not */
+bool talk_voice_required(void)
+{
+ return (voicefile_size != 0)
+ || (global_settings.talk_dir == 3)
+ || (global_settings.talk_file == 3);
+}
+
+/* return size of voice file */
+int talk_get_bufsize(void)
+{
+ return voicefile_size;
+}
/* somebody else claims the mp3 buffer, e.g. for regular play/record */
int talk_buffer_steal(void)
diff --git a/apps/talk.h b/apps/talk.h
index 58ab0ef..0dc6996 100644
--- a/apps/talk.h
+++ b/apps/talk.h
@@ -58,6 +58,7 @@ extern const char* const dir_thumbnail_name; /* "_dirname.talk" */
extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */
void talk_init(void);
+bool talk_voice_required(void); /* returns true if voice codec required */
int talk_get_bufsize(void); /* get the loaded voice file size */
int talk_buffer_steal(void); /* claim the mp3 buffer e.g. for play/record */
int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */