From 51687876a7dbd2ef539d4775f1f130ca46cb5560 Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sun, 24 May 2009 17:20:00 +0200 Subject: [PATCH] Little corrections to dsp command line parsing and small optimization on main.c --- Makefile | 2 +- dsp.c | 5 +++-- main.c | 11 +++-------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index fefcc87..ce05190 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ all: - gcc -Wall -ansi -pedantic -o vocal main.c dsp.c utils.c -lm -w -O3 -funroll-loops -fno-rtti -ffast-math -fno-stack-protector -ffunction-sections + gcc -Wall -ansi -pedantic -o vocal main.c dsp.c utils.c -lm -w -O3 -funroll-loops -fno-rtti -ffast-math -fno-stack-protector -ffunction-sections -funsafe-math-optimizations -fno-trapping-math clean: rm vocal diff --git a/dsp.c b/dsp.c index 189b9ab..b43d7e1 100644 --- a/dsp.c +++ b/dsp.c @@ -2,8 +2,9 @@ int init_dsp( char *device ) { int dsp, arg; - - if ((dsp=open( (device == NULL ? "/dev/dsp" : device), O_RDONLY)) < 0) { + char *dev = (device == NULL ? "/dev/dsp" : device); + + if ((dsp=open( dev, O_RDONLY)) < 0) { perror("open of sound device failed"); return -1; } diff --git a/main.c b/main.c index 115ff58..366c075 100644 --- a/main.c +++ b/main.c @@ -18,7 +18,7 @@ int main (int argc, char **argv) { int i, j, dsp, fd, ch, size, recognized; int TOTSIZE = BUF_SIZE*SAMPLE_SIZE; - char *line, *tmp, *cmd = NULL, *fname = NULL, device = NULL; + char *line, *tmp, *cmd = NULL, *fname = NULL, *device = NULL; char **match = NULL; double deviance; @@ -46,7 +46,7 @@ int main (int argc, char **argv) { return 1; } } - + printf( "DEVICE : %s\n", device ); buf = (u8*) malloc(TOTSIZE); neutral = (double*) malloc(TOTSIZE*sizeof(double)); trans = (double*) malloc(TOTSIZE*sizeof(double)); @@ -78,8 +78,7 @@ int main (int argc, char **argv) { close(dsp); - printf ("capture done, computing DCT...\n"); - int count = 0; + printf ("capture done, computing DCT...\n" ); t1 = time((unsigned) NULL); for (i=0; i