diff options
| author | Pierre Grandin <grandinp@altern.org> | 2017-01-01 14:43:21 -0800 |
|---|---|---|
| committer | Pierre Grandin <grandinp@altern.org> | 2017-01-01 14:43:21 -0800 |
| commit | 05054992fa283cc313ca90fe1c968f5c9c13e6d1 (patch) | |
| tree | 6dd5757d36fb454254506a2ace2944d0cc9368ce | |
| parent | dadc39585cd41aadf42a6a840f29e0bfea25288f (diff) | |
| download | navit-05054992fa283cc313ca90fe1c968f5c9c13e6d1.tar.gz | |
Reducing code duplication in the tomtom builds
| -rw-r--r-- | ci/build_tomtom_minimal.sh | 2 | ||||
| -rw-r--r-- | ci/build_tomtom_plugin.sh | 2 | ||||
| -rw-r--r-- | circle.yml | 1 | ||||
| -rw-r--r-- | contrib/tomtom/espeakdsp.c | 105 |
4 files changed, 107 insertions, 3 deletions
diff --git a/ci/build_tomtom_minimal.sh b/ci/build_tomtom_minimal.sh index e7c58ed1c..529c35eca 100644 --- a/ci/build_tomtom_minimal.sh +++ b/ci/build_tomtom_minimal.sh @@ -7,7 +7,7 @@ set -e -bash setup_tomtom_requirements.sh +bash ~/navit/ci/setup_tomtom_requirements.sh # navit diff --git a/ci/build_tomtom_plugin.sh b/ci/build_tomtom_plugin.sh index 0137506c6..4f72aa5ec 100644 --- a/ci/build_tomtom_plugin.sh +++ b/ci/build_tomtom_plugin.sh @@ -6,7 +6,7 @@ set -e -bash setup_tomtom_requirements.sh +bash ~/navit/ci/setup_tomtom_requirements.sh # sdl test utilities cd test diff --git a/circle.yml b/circle.yml index 4b296a25c..6fa1ccc22 100644 --- a/circle.yml +++ b/circle.yml @@ -6,7 +6,6 @@ dependencies: - ~/.android - ~/android - "~/assets/" - - ~/tomtom_assets pre: - "[ -d ~/assets ] || mkdir ~/assets" - "[ -d ~/android ] || mkdir ~/android" diff --git a/contrib/tomtom/espeakdsp.c b/contrib/tomtom/espeakdsp.c new file mode 100644 index 000000000..b1d9136d9 --- /dev/null +++ b/contrib/tomtom/espeakdsp.c @@ -0,0 +1,105 @@ +#include <fcntl.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/soundcard.h> +#include <sys/wait.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> + +#define IBUFFERLEN 1024 +#define MAXARGC 30 + + +int main(int argc, char *argv[],char *envp[]) +{ + int pipefd[2]; + pid_t cpid; + char buf; + int co,wp,l,fh; + short bufi[IBUFFERLEN],bufo[IBUFFERLEN*2]; + int rate=22050; + + char *newargv[MAXARGC+2]; + + for(co=0;co<argc;co++) + { + if(co>=MAXARGC)break; + newargv[co]=argv[co]; + } + newargv[co++]="--stdout"; + newargv[co++]=NULL; + + if (pipe(pipefd) == -1) + { + perror("pipe"); + exit(EXIT_FAILURE); + } + + if(setpriority(PRIO_PROCESS,0,-10)) + perror ("setpriority"); + + cpid = fork(); + if (cpid == -1) + { + perror("fork"); + exit(EXIT_FAILURE); + } + + if (cpid == 0) + { /* 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"); + close(pipefd[1]); /* Reader will see EOF */ + wait(NULL); /* Wait for child */ + exit(EXIT_SUCCESS); + + } else { /* Parent read from pipe */ + + close(pipefd[1]); /* Close unused write end */ + + l=read(pipefd[0],bufi,64); + if(memcmp(bufi,"RIFF",4)) + { + while(l>0) + { + write(1,bufi,l); + l=read(pipefd[0],bufi,IBUFFERLEN); + } + 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) + { + perror("open /dev/dsp"); + exit(EXIT_FAILURE); + } + ioctl(fh, SNDCTL_DSP_SPEED , &rate); + ioctl(fh, SNDCTL_DSP_SYNC, 0); + while(l) + { + for(co=0,wp=0;co<IBUFFERLEN;co++) + { + bufo[wp++]=bufi[co]; /* mono->stereo */ + bufo[wp++]=bufi[co]; + } + write (fh,bufo,wp); + l=read(pipefd[0],bufi,IBUFFERLEN); + } + ioctl(fh, SNDCTL_DSP_SYNC, 0); + close(pipefd[0]); + exit(EXIT_SUCCESS); + } +} |
