mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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
This commit is contained in:
parent
599fa9a627
commit
42f0ad3c8f
4 changed files with 37 additions and 12 deletions
|
@ -481,9 +481,13 @@ static void* get_voice_memory_callback(size_t *size)
|
||||||
static void* get_codec_memory_callback(size_t *size)
|
static void* get_codec_memory_callback(size_t *size)
|
||||||
{
|
{
|
||||||
*size = MALLOC_BUFSIZE;
|
*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)
|
if (voice_codec_loaded)
|
||||||
return &audiobuf[talk_get_bufsize()];
|
return &audiobuf[talk_get_bufsize()];
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
return audiobuf;
|
return audiobuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2559,7 +2563,7 @@ static void reset_buffer(void)
|
||||||
filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE -
|
filebuflen = audiobufend - audiobuf - MALLOC_BUFSIZE - GUARD_BUFSIZE -
|
||||||
(pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2);
|
(pcmbuf_get_bufsize() + get_pcmbuf_descsize() + PCMBUF_MIX_CHUNK * 2);
|
||||||
|
|
||||||
if (talk_get_bufsize())
|
if (talk_voice_required())
|
||||||
{
|
{
|
||||||
filebuf = &filebuf[talk_get_bufsize()];
|
filebuf = &filebuf[talk_get_bufsize()];
|
||||||
filebuflen -= 2*CODEC_IRAM_SIZE + 2*CODEC_SIZE + 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];
|
iram_buf[1] = &filebuf[filebuflen+CODEC_IRAM_SIZE];
|
||||||
#endif
|
#endif
|
||||||
dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
|
dram_buf[0] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2];
|
||||||
dram_buf[1] =
|
dram_buf[1] = (unsigned char *)&filebuf[filebuflen+CODEC_IRAM_SIZE*2+CODEC_SIZE];
|
||||||
(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 */
|
/* Ensure that everything is aligned */
|
||||||
|
@ -2616,8 +2629,8 @@ void voice_init(void)
|
||||||
voice_codec_loaded = false;
|
voice_codec_loaded = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!talk_get_bufsize())
|
if (!talk_voice_required())
|
||||||
return ;
|
return;
|
||||||
|
|
||||||
logf("Starting voice codec");
|
logf("Starting voice codec");
|
||||||
queue_init(&voice_codec_queue);
|
queue_init(&voice_codec_queue);
|
||||||
|
|
|
@ -1264,16 +1264,20 @@ static const struct opt_items voice_names[] = {
|
||||||
|
|
||||||
static bool voice_dirs(void)
|
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);
|
&global_settings.talk_dir, INT, voice_names, 4, NULL);
|
||||||
|
audio_set_crossfade(global_settings.crossfade);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool voice_files(void)
|
static bool voice_files(void)
|
||||||
{
|
{
|
||||||
int oldval = global_settings.talk_file;
|
int oldval = global_settings.talk_file;
|
||||||
bool ret;
|
bool ret;
|
||||||
|
|
||||||
ret = set_option( str(LANG_VOICE_FILE),
|
ret = set_option( str(LANG_VOICE_FILE),
|
||||||
&global_settings.talk_file, INT, voice_names, 4, NULL);
|
&global_settings.talk_file, INT, voice_names, 4, NULL);
|
||||||
|
audio_set_crossfade(global_settings.crossfade);
|
||||||
if (oldval != 3 && global_settings.talk_file == 3)
|
if (oldval != 3 && global_settings.talk_file == 3)
|
||||||
{ /* force reload if newly talking thumbnails,
|
{ /* force reload if newly talking thumbnails,
|
||||||
because the clip presence is cached only if enabled */
|
because the clip presence is cached only if enabled */
|
||||||
|
@ -1462,9 +1466,7 @@ static bool crossfade(void)
|
||||||
|
|
||||||
ret=set_option( str(LANG_CROSSFADE_ENABLE),
|
ret=set_option( str(LANG_CROSSFADE_ENABLE),
|
||||||
&global_settings.crossfade, INT, names, 4, NULL);
|
&global_settings.crossfade, INT, names, 4, NULL);
|
||||||
|
|
||||||
audio_set_crossfade(global_settings.crossfade);
|
audio_set_crossfade(global_settings.crossfade);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
apps/talk.c
17
apps/talk.c
|
@ -146,10 +146,6 @@ static int open_voicefile(void)
|
||||||
return open(buf, O_RDONLY);
|
return open(buf, O_RDONLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
int talk_get_bufsize(void)
|
|
||||||
{
|
|
||||||
return voicefile_size;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* load the voice file into the mp3 buffer */
|
/* load the voice file into the mp3 buffer */
|
||||||
static void load_voicefile(void)
|
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 */
|
/* somebody else claims the mp3 buffer, e.g. for regular play/record */
|
||||||
int talk_buffer_steal(void)
|
int talk_buffer_steal(void)
|
||||||
|
|
|
@ -58,6 +58,7 @@ extern const char* const dir_thumbnail_name; /* "_dirname.talk" */
|
||||||
extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */
|
extern const char* const file_thumbnail_ext; /* ".talk" for file voicing */
|
||||||
|
|
||||||
void talk_init(void);
|
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_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_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 */
|
int talk_id(long id, bool enqueue); /* play a voice ID from voicefont */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue