summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/talk.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/apps/talk.c b/apps/talk.c
index aa79dd1b33..03da4897c8 100644
--- a/apps/talk.c
+++ b/apps/talk.c
@@ -177,7 +177,7 @@ static int index_handle, talk_handle;
177 177
178static int move_callback(int handle, void *current, void *new) 178static int move_callback(int handle, void *current, void *new)
179{ 179{
180 (void)handle; (void)current; (void)new; 180 (void)current;
181 if (handle == talk_handle && !buflib_context_relocate(&clip_ctx, new)) 181 if (handle == talk_handle && !buflib_context_relocate(&clip_ctx, new))
182 return BUFLIB_CB_CANNOT_MOVE; 182 return BUFLIB_CB_CANNOT_MOVE;
183 return BUFLIB_CB_OK; 183 return BUFLIB_CB_OK;
@@ -246,7 +246,7 @@ static ssize_t read_to_handle(int fd, int handle, int handle_offset, size_t coun
246 246
247static int shrink_callback(int handle, unsigned hints, void *start, size_t old_size) 247static int shrink_callback(int handle, unsigned hints, void *start, size_t old_size)
248{ 248{
249 (void)start;(void)old_size;(void)hints; 249 (void)start;(void)old_size;
250 int *h; 250 int *h;
251#if (MAX_CLIP_BUFFER_SIZE < (MEMORYSIZE<<20) || (MEMORYSIZE > 2)) 251#if (MAX_CLIP_BUFFER_SIZE < (MEMORYSIZE<<20) || (MEMORYSIZE > 2))
252 /* on low-mem and when the voice buffer size is not limited (i.e. 252 /* on low-mem and when the voice buffer size is not limited (i.e.
@@ -258,18 +258,22 @@ static int shrink_callback(int handle, unsigned hints, void *start, size_t old_s
258 * not necessary. */ 258 * not necessary. */
259 if (give_buffer_away 259 if (give_buffer_away
260 && (hints & BUFLIB_SHRINK_POS_MASK) == BUFLIB_SHRINK_POS_MASK) 260 && (hints & BUFLIB_SHRINK_POS_MASK) == BUFLIB_SHRINK_POS_MASK)
261#else
262 (void)hints;
261#endif 263#endif
262 { 264 {
263 if (handle == talk_handle) 265 if (handle == talk_handle)
264 h = &talk_handle; 266 h = &talk_handle;
265 else //if (handle == index_handle) 267 else if (handle == index_handle)
266 h = &index_handle; 268 h = &index_handle;
269 else h = NULL;
267 270
268 mutex_lock(&read_buffer_mutex); 271 mutex_lock(&read_buffer_mutex);
269 /* the clip buffer isn't usable without index table */ 272 /* the clip buffer isn't usable without index table */
270 if (handle == index_handle && talk_handle > 0) 273 if (handle == index_handle && talk_handle > 0)
271 talk_handle = core_free(talk_handle); 274 talk_handle = core_free(talk_handle);
272 *h = core_free(handle); 275 if (h)
276 *h = core_free(handle);
273 mutex_unlock(&read_buffer_mutex); 277 mutex_unlock(&read_buffer_mutex);
274 278
275 return BUFLIB_CB_OK; 279 return BUFLIB_CB_OK;
@@ -435,8 +439,9 @@ static ssize_t read_clip_data(int fd, int index, int clip_handle)
435 439
436static void load_initial_clips(int fd) 440static void load_initial_clips(int fd)
437{ 441{
442#if defined(TALK_PROGRESSIVE_LOAD)
438 (void) fd; 443 (void) fd;
439#ifndef TALK_PROGRESSIVE_LOAD 444#else
440 unsigned index, i; 445 unsigned index, i;
441 unsigned num_clips = voicefile.id1_max + voicefile.id2_max; 446 unsigned num_clips = voicefile.id1_max + voicefile.id2_max;
442 447
@@ -1059,8 +1064,14 @@ static int _talk_file(const char* filename,
1059 return -1; /* talking has been disabled */ 1064 return -1; /* talking has been disabled */
1060 if (!check_audio_status()) 1065 if (!check_audio_status())
1061 return -1; 1066 return -1;
1062 if (talk_handle <= 0) 1067 if (talk_handle <= 0 || index_handle <= 0)
1063 load_voicefile_data(-1); 1068 {
1069 int fd = open_voicefile();
1070 if (fd < 0 || !load_voicefile_index(fd))
1071 return -1;
1072 load_voicefile_data(fd);
1073 close(fd);
1074 }
1064 1075
1065#if CONFIG_CODEC != SWCODEC 1076#if CONFIG_CODEC != SWCODEC
1066 if(mp3info(&info, filename)) /* use this to find real start */ 1077 if(mp3info(&info, filename)) /* use this to find real start */