From 1f4252160f3ba717e5aef16faaa3be4b8055b31e Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Sun, 24 Jun 2012 20:04:41 +0000 Subject: Correction segfault a la fermeture si module USB<->DMX non present git-svn-id: file:///var/svn/2012-violon-leds/trunk@32 6be1fa4d-33ac-4c33-becc-79fcb3794bb6 --- src/Makefile | 4 ++-- src/illuminate.c | 3 ++- src/instru2light.c | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Makefile b/src/Makefile index 17b646f..d4f0979 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,10 +1,10 @@ CC=gcc # For debug -#CFLAGS=-W -Wall -Werror -Wno-error=unused-parameter -g +CFLAGS=-W -Wall -Werror -Wno-error=unused-parameter -g #LDFLAGS=-Werror -g # For release -CFLAGS=-W -Wall -Werror -Wno-unused-parameter -O2 +#CFLAGS=-W -Wall -Werror -Wno-unused-parameter -O2 LDFLAGS=-export-dynamic -Werror EXEC=instru2light diff --git a/src/illuminate.c b/src/illuminate.c index b3afbfb..d5d40b2 100644 --- a/src/illuminate.c +++ b/src/illuminate.c @@ -75,7 +75,8 @@ int dmx_init() { //Always take the first device if (devlist==NULL || devlist->dev==NULL) { fprintf(stderr, "No usb device detected (looking for USB ID 0x%04X:0x%04X)\n", VID, PID); - return(2); + ftdi_deinit(&ftdi); + return 1; } dev=devlist->dev; diff --git a/src/instru2light.c b/src/instru2light.c index 33892b5..a72fd0f 100644 --- a/src/instru2light.c +++ b/src/instru2light.c @@ -29,6 +29,8 @@ gint *audio_vumeter_val, *light_h, *light_s, *light_v, *light_r, *light_g, *ligh void my_process(float *data, size_t nsamples, size_t nchan); int main (int argc, char **argv) { + int dmx_init_res; + GtkWidget *mainwin; gint vals_for_vumeters[7]={0,0,0,0,0,0,0}; //sound,h,s,v,r,g,b //Some handy references to the previous array items to make things clear whenever possible @@ -50,7 +52,7 @@ int main (int argc, char **argv) { mainwin=win_main_build(); gtk_widget_show_all (mainwin); - dmx_init(); + dmx_init_res=dmx_init(); printf("debug : main my_process==%p\n", my_process); printf("debug : main (void *)my_process==%p\n", (void *)my_process); @@ -60,7 +62,8 @@ int main (int argc, char **argv) { gtk_main (); gdk_threads_leave(); - dmx_deinit(); + + if (dmx_init_res==0) dmx_deinit(); return 0; } -- cgit v1.2.3