talk_init() : don't try to load the voice file if it won't fit in memory
authorfunman <funman@a1c6a512-1295-4272-9138-f99709370657>
Sat, 15 May 2010 10:05:47 +0000 (15 10:05 +0000)
committerfunman <funman@a1c6a512-1295-4272-9138-f99709370657>
Sat, 15 May 2010 10:05:47 +0000 (15 10:05 +0000)
now playback still works if voicing is enabled on the clipv1

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26047 a1c6a512-1295-4272-9138-f99709370657

apps/talk.c

index 9f31645..c327487 100644 (file)
@@ -540,7 +540,9 @@ void talk_init(void)
     reset_state(); /* use this for most of our inits */
 
     filehandle = open_voicefile();
-    has_voicefile = (filehandle >= 0); /* test if we can open it */
+    size_t audiobufsz = audiobufend - audiobuf;
+    /* test if we can open and if it fits in the audiobuffer */
+    has_voicefile = filehandle >= 0 && filesize(filehandle) > (off_t)audiobufsz;
     voicefile_size = 0;
 
     if (has_voicefile)