From 83f67db3ee24d426c956de1d426695fc547ba262 Mon Sep 17 00:00:00 2001 From: Jens Arnold Date: Mon, 15 May 2006 21:00:58 +0000 Subject: Ondio: Two voice bugfixes. (1) When changing language and voice is enabled, do the voice file presence check the same way as on the other targets. Loading the tables right away when music is playing isn't a good idea... (2) Changing language with voice enabled leaked file handles. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9946 a1c6a512-1295-4272-9138-f99709370657 --- apps/talk.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/talk.c b/apps/talk.c index 80b4fa335f..6807481e0d 100644 --- a/apps/talk.c +++ b/apps/talk.c @@ -89,7 +89,7 @@ static int queue_write; /* write index of queue, by application */ static int queue_read; /* read index of queue, by ISR context */ static int sent; /* how many bytes handed over to playback, owned by ISR */ static unsigned char curr_hd[3]; /* current frame header, for re-sync */ -static int filehandle; /* global, so the MMC variant can keep the file open */ +static int filehandle = -1; /* global, so the MMC variant can keep the file open */ static unsigned char* p_silence; /* VOICE_PAUSE clip, used for termination */ static long silence_len; /* length of the VOICE_PAUSE clip */ static unsigned char* p_lastclip; /* address of latest clip, for silence add */ @@ -466,6 +466,14 @@ void talk_init(void) return; } +#ifdef HAVE_MMC + if (filehandle >= 0) /* MMC: An old voice file might still be open */ + { + close(filehandle); + filehandle = -1; + } +#endif + talk_initialized = true; strncpy((char *) last_lang, (char *)global_settings.lang_file, MAX_FILENAME); @@ -475,14 +483,10 @@ void talk_init(void) #endif reset_state(); /* use this for most of our inits */ -#ifdef HAVE_MMC - load_voicefile(); /* load the tables right away */ - has_voicefile = (p_voicefile != NULL); -#else filehandle = open_voicefile(); has_voicefile = (filehandle >= 0); /* test if we can open it */ voicefile_size = 0; - + if (has_voicefile) { voicefile_size = filesize(filehandle); @@ -492,8 +496,6 @@ void talk_init(void) close(filehandle); /* close again, this was just to detect presence */ filehandle = -1; } -#endif - } -- cgit v1.2.3