]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fix memory leak
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Mon, 19 Dec 2016 21:43:25 +0000 (21:43 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Mon, 19 Dec 2016 21:43:25 +0000 (21:43 +0000)
gpio.c
iambic.c
main.c
memory.c [new file with mode: 0644]
memory.h [new file with mode: 0644]
receiver.h [new file with mode: 0644]
toolbar.c
vfo.c

diff --git a/gpio.c b/gpio.c
index 6dbce4878ef057d8b1e4ddac41cc86606cdf9ff7..c9ac3bee05e8e614bffd05a6fce6735171795f98 100644 (file)
--- a/gpio.c
+++ b/gpio.c
@@ -245,6 +245,7 @@ static void lockAlert(int gpio, int level, uint32_t tick) {
 }
 
 static void cwAlert(int gpio, int level, uint32_t tick) {
+fprintf(stderr,"cwAlert: gpio=%d level=%d internal=%d\n",gpio,level,cw_keyer_internal);
     if (cw_keyer_internal == 0)
        keyer_event(gpio, cw_active_level == 0 ? level : (level==0));
 }
@@ -726,6 +727,7 @@ fprintf(stderr,"encoder_init\n");
   }
 #endif
 
+fprintf(stderr,"GPIO: ENABLE_CW_BUTTONS=%d  CWL_BUTTON=%d CWR_BUTTON=%d\n",ENABLE_CW_BUTTONS, CWL_BUTTON, CWR_BUTTON);
   if(ENABLE_CW_BUTTONS) {
     setup_button(CWL_BUTTON, cwAlert);
     setup_button(CWR_BUTTON, cwAlert);
index 35ea9cb32364c2eaff6195c88ac76aaf5444d44b..aa94ecfbe8bbec98411d0c527941627c4230c08a 100644 (file)
--- a/iambic.c
+++ b/iambic.c
@@ -193,8 +193,10 @@ static void* keyer_thread(void *arg) {
     struct timespec loop_delay;
     int interval = 1000000; // 1 ms
 
+fprintf(stderr,"keyer_thread\n");
     while(running) {
         sem_wait(&cw_event);
+
         key_state = CHECK;
 
         while (key_state != EXITLOOP) {
@@ -358,7 +360,9 @@ static void* keyer_thread(void *arg) {
             }
             clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &loop_delay, NULL);
         }
+
     }
+fprintf(stderr,"keyer_thread: EXIT\n");
 }
 
 void keyer_close() {
@@ -384,10 +388,27 @@ int keyer_init() {
     //stack_prefault();
 
 
+/*
     if (wiringPiSetup () < 0) {
         fprintf(stderr,"pthread_create for keyer_thread failed %d\n", rc);
         exit(-1);
     }
+*/
+
+    if (SIDETONE_GPIO)
+        softToneCreate(SIDETONE_GPIO);
+    else {
+        beep_init();
+        beep_vol(cw_keyer_sidetone_volume);
+    }
+
+    rc = sem_init(&cw_event, 0, 0);
+    rc |= pthread_create(&keyer_thread_id, NULL, keyer_thread, NULL);
+    running = 1;
+    if(rc < 0) {
+        fprintf(stderr,"pthread_create for keyer_thread failed %d\n", rc);
+        exit(-1);
+    }
 
     return 0;
 }
diff --git a/main.c b/main.c
index 53df2ed47887b03f3c177e443990995f9f659ff4..0226125b712ab99da9ec7575217fe5880a66cb87 100644 (file)
--- a/main.c
+++ b/main.c
@@ -871,6 +871,7 @@ fprintf(stderr,"reconfigure_display: sliders_init: width:%d height:%d\n",display
       gtk_widget_show(sliders);
     }
     gtk_widget_show_all(sliders);
+    linein_changed();
     y+=SLIDERS_HEIGHT;
   } else {
     gtk_widget_hide(sliders);
diff --git a/memory.c b/memory.c
new file mode 100644 (file)
index 0000000..e9f8ff1
--- /dev/null
+++ b/memory.c
@@ -0,0 +1,27 @@
+/* Copyright (C)
+* 2015 - John Melton, G0ORX/N6LYT
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+#include <sys/resource.h>
+#include <stdio.h>
+
+void show_memory(char *title) {
+  struct rusage r_usage;
+  getrusage(RUSAGE_SELF,&r_usage);
+  fprintf(stderr, "%s: Memory usage: %ld bytes\n",title,r_usage.ru_maxrss);
+}
diff --git a/memory.h b/memory.h
new file mode 100644 (file)
index 0000000..fbd75c1
--- /dev/null
+++ b/memory.h
@@ -0,0 +1,20 @@
+/* Copyright (C)
+* 2015 - John Melton, G0ORX/N6LYT
+*
+* This program is free software; you can redistribute it and/or
+* modify it under the terms of the GNU General Public License
+* as published by the Free Software Foundation; either version 2
+* of the License, or (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+*
+*/
+
+extern void show_memory(char *title);
diff --git a/receiver.h b/receiver.h
new file mode 100644 (file)
index 0000000..1d91a7e
--- /dev/null
@@ -0,0 +1,13 @@
+#define MAX_RECEIVERS 2
+
+struct _receiver {
+  int sample_rate;
+  int buffer_size;
+  int band;
+  int bandstack;
+  int mode;
+  int filter;
+  int audio;
+} rx[MAX_RECEIVERS];
+
+
index e37b35f79c953bbfa2a100473a63c6d947673b0c..93b2add9fffe44952f6ae2293b5c7ab7b882506b 100644 (file)
--- a/toolbar.c
+++ b/toolbar.c
@@ -975,6 +975,8 @@ void lock_cb(GtkWidget *widget, gpointer data) {
 }
 
 void mox_cb(GtkWidget *widget, gpointer data) {
+
+
   if(getTune()==1) {
     setTune(0);
   }
@@ -1209,7 +1211,7 @@ void sim_mox_cb(GtkWidget *widget, gpointer data) {
   } else {
     mox_cb((GtkWidget *)NULL, (gpointer)NULL);
   }
-  vfo_update(NULL);
+  //vfo_update(NULL);
 }
 
 void sim_function_cb(GtkWidget *widget, gpointer data) {
diff --git a/vfo.c b/vfo.c
index 80ab0464e159ead1bcbb06d078d8347752e7168c..3097f1bf3c8d59c298de7e4f67dc3b0e89c2b0e5 100644 (file)
--- a/vfo.c
+++ b/vfo.c
@@ -169,6 +169,7 @@ fprintf(stderr,"vfo_configure_event_cb: width=%d height=%d\n",
   cr = cairo_create (vfo_surface);
   cairo_set_source_rgb (cr, 0, 0, 0);
   cairo_paint (cr);
+  cairo_destroy(cr);
 
   g_idle_add(vfo_update,NULL);