summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgefin <g.fink@gmx.net>2017-01-21 21:14:46 +0100
committerPierre GRANDIN <pgrandin@users.noreply.github.com>2017-01-21 12:14:46 -0800
commit101d8e1eadb04dc55fef2dbacf5abed7ffd284f8 (patch)
treedeb0455d31467dbb8881be33ffc5d9e335e35421
parent7a113363b5257eb8d87bb39b6439423cf1836cb4 (diff)
downloadnavit-101d8e1eadb04dc55fef2dbacf5abed7ffd284f8.tar.gz
fix espeakdsp buffer usage for tomtom (#200)
* fix buffer usage dont send more bytes then received. * remove last blank line
-rw-r--r--contrib/tomtom/espeakdsp.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/contrib/tomtom/espeakdsp.c b/contrib/tomtom/espeakdsp.c
index b1d9136d9..bd6689a1f 100644
--- a/contrib/tomtom/espeakdsp.c
+++ b/contrib/tomtom/espeakdsp.c
@@ -7,7 +7,9 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <libgen.h>
+#define espeakpath "/mnt/sdcard/navit/bin/espeak"
#define IBUFFERLEN 1024
#define MAXARGC 30
@@ -51,9 +53,9 @@ int main(int argc, char *argv[],char *envp[])
{ /* Child writes to pipe */
close(pipefd[0]); /* Close unused read end */
- dup2(pipefd[1],1);
- execve("/mnt/sdcard/navit/bin/espeak",newargv,envp);
- perror("exec /mnt/sdcard/navit/bin/espeak");
+ dup2(pipefd[1],1);
+ execve(espeakpath,newargv,envp);
+ perror(espeakpath);
close(pipefd[1]); /* Reader will see EOF */
wait(NULL); /* Wait for child */
exit(EXIT_SUCCESS);
@@ -73,12 +75,6 @@ int main(int argc, char *argv[],char *envp[])
exit(EXIT_SUCCESS);
}
l=read(pipefd[0],bufi,IBUFFERLEN);
- if(l<500)
- {
- printf("espeakdsp: avoid noise speaking a empty string\n");
- exit(EXIT_SUCCESS);
- }
- usleep (50000);
fh=open("/dev/dsp",O_WRONLY);
if(fh<0)
@@ -90,7 +86,7 @@ int main(int argc, char *argv[],char *envp[])
ioctl(fh, SNDCTL_DSP_SYNC, 0);
while(l)
{
- for(co=0,wp=0;co<IBUFFERLEN;co++)
+ for(co=0,wp=0;(co<IBUFFERLEN)&&(co<l);co++)
{
bufo[wp++]=bufi[co]; /* mono->stereo */
bufo[wp++]=bufi[co];