diff --git a/common.c b/common.c index f53846f..e85574c 100644 --- a/common.c +++ b/common.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -12,13 +11,13 @@ #include "common.h" -bool Abort = false; -bool Adaptive = true; +gboolean Abort = FALSE; +gboolean Adaptive = TRUE; double *in = NULL; -bool *HasSync = NULL; +gboolean *HasSync = NULL; gshort HedrShift = 0; -bool ManualActivated = false; -bool ManualResync = false; +gboolean ManualActivated = FALSE; +gboolean ManualResync = FALSE; double *out = NULL; guchar *StoredLum = NULL; @@ -89,7 +88,7 @@ void saveCurrentPic() { ensure_dir_exists(g_key_file_get_string(config,"slowrx","rxdir",NULL)); gdk_pixbuf_savev(scaledpb, pngfilename->str, "png", NULL, NULL, NULL); g_object_unref(scaledpb); - g_string_free(pngfilename, true); + g_string_free(pngfilename, TRUE); } @@ -108,12 +107,12 @@ void evt_GetAdaptive() { // Manual Start clicked void evt_ManualStart() { - ManualActivated = true; + ManualActivated = TRUE; } // Abort clicked during rx void evt_AbortRx() { - Abort = true; + Abort = TRUE; } // Another device selected from list @@ -121,8 +120,8 @@ void evt_changeDevices() { int status; - pcm.BufferDrop = false; - Abort = true; + pcm.BufferDrop = FALSE; + Abort = TRUE; pthread_join(thread1, NULL); @@ -164,7 +163,7 @@ void evt_clearPix() { // Manual slant adjust void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge) { static double prevx=0,prevy=0,newrate; - static bool secondpress=false; + static gboolean secondpress=FALSE; double x,y,dx,dy,xic; (void)widget; @@ -176,12 +175,12 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge) y = event->y * (ModeSpec[CurrentPic.Mode].ImgWidth / 500.0) / ModeSpec[CurrentPic.Mode].YScale; if (secondpress) { - secondpress=false; + secondpress=FALSE; dx = x - prevx; dy = y - prevy; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge),false); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge),FALSE); // Adjust sample rate, if in sensible limits newrate = CurrentPic.Rate + CurrentPic.Rate * (dx * ModeSpec[CurrentPic.Mode].PixelLen) / (dy * ModeSpec[CurrentPic.Mode].YScale * ModeSpec[CurrentPic.Mode].LineLen); @@ -197,16 +196,16 @@ void evt_clickimg(GtkWidget *widget, GdkEventButton* event, GdkWindowEdge edge) CurrentPic.Skip -= ModeSpec[CurrentPic.Mode].LineLen * CurrentPic.Rate; // Signal the listener to exit from GetVIS() and re-process the pic - ManualResync = true; + ManualResync = TRUE; } } else { - secondpress = true; + secondpress = TRUE; prevx = x; prevy = y; } } else { - secondpress=false; - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), false); + secondpress=FALSE; + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), FALSE); } } diff --git a/common.h b/common.h index 56adbf5..0445550 100644 --- a/common.h +++ b/common.h @@ -6,12 +6,12 @@ #define BUFLEN 4096 #define SYNCPIXLEN 1.5e-3 -extern bool Abort; -extern bool Adaptive; -extern bool *HasSync; +extern gboolean Abort; +extern gboolean Adaptive; +extern gboolean *HasSync; extern double *in; -extern bool ManualActivated; -extern bool ManualResync; +extern gboolean ManualActivated; +extern gboolean ManualResync; extern double *out; extern guchar *StoredLum; extern pthread_t thread1; @@ -23,7 +23,7 @@ struct _PcmData { int PeakVal; gint16 *Buffer; int WindowPtr; - bool BufferDrop; + gboolean BufferDrop; }; extern PcmData pcm; @@ -124,7 +124,7 @@ void createGUI (); double deg2rad (double Deg); double FindSync (guchar Mode, double Rate, int *Skip); void GetFSK (char *dest); -bool GetVideo (guchar Mode, double Rate, int Skip, bool Redraw); +gboolean GetVideo (guchar Mode, double Rate, int Skip, gboolean Redraw); guchar GetVIS (); guint GetBin (double Freq, guint FFTLen); int initPcmDevice (); diff --git a/fsk.c b/fsk.c index f4ad8a2..6e07278 100644 --- a/fsk.c +++ b/fsk.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -23,7 +22,7 @@ void GetFSK (char *dest) { guint FFTLen = 2048, i=0, LoBin, HiBin, MidBin, TestNum=0, TestPtr=0; guchar Bit = 0, AsciiByte = 0, BytePtr = 0, TestBits[24] = {0}, BitPtr=0; double HiPow,LoPow,Hann[970]; - bool InSync = false; + gboolean InSync = FALSE; // Bit-reversion lookup table static const guchar BitRev[] = { @@ -41,7 +40,7 @@ void GetFSK (char *dest) { // Create 22ms Hann window for (i = 0; i < 970; i++) Hann[i] = 0.5 * (1 - cos( 2 * M_PI * i / 969.0 ) ); - while ( true ) { + while ( TRUE ) { // Read data from DSP readPcm(InSync ? 970: 485); @@ -78,7 +77,7 @@ void GetFSK (char *dest) { for (i=0; i<12; i++) TestNum |= TestBits[(TestPtr - (23-i*2)) % 24] << (11-i); if (BitRev[(TestNum >> 6) & 0x3f] == 0x20 && BitRev[TestNum & 0x3f] == 0x2a) { - InSync = true; + InSync = TRUE; AsciiByte = 0; BitPtr = 0; BytePtr = 0; diff --git a/gui.c b/gui.c index 681ae8a..a077f26 100644 --- a/gui.c +++ b/gui.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -61,13 +60,13 @@ void createGUI() { savedstore = GTK_LIST_STORE(gtk_icon_view_get_model(GTK_ICON_VIEW(gui.iconview))); - pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 320, 256); + pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 320, 256); gdk_pixbuf_fill(pixbuf_rx, 0x000000ff); pixbuf_disp = gdk_pixbuf_scale_simple (pixbuf_rx, 500, 400, GDK_INTERP_BILINEAR); gtk_image_set_from_pixbuf(GTK_IMAGE(gui.image_rx), pixbuf_disp); - pixbuf_PWR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 100, 20); - pixbuf_SNR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, 100, 20); + pixbuf_PWR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 100, 20); + pixbuf_SNR = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 100, 20); gtk_combo_box_set_active(GTK_COMBO_BOX(gui.combo_mode), 0); diff --git a/modespec.c b/modespec.c index 5f98f71..4160bb3 100644 --- a/modespec.c +++ b/modespec.c @@ -1,6 +1,5 @@ #include #include -#include #include #include diff --git a/pcm.c b/pcm.c index 78d6eb9..88ee303 100644 --- a/pcm.c +++ b/pcm.c @@ -1,6 +1,5 @@ #include #include -#include #include #include @@ -31,7 +30,7 @@ void readPcm(gint numsamples) { else if (samplesread < 0) { printf("ALSA error %d (%s)\n", samplesread, snd_strerror(samplesread)); gtk_widget_set_tooltip_text(gui.image_devstatus, "ALSA error"); - Abort = true; + Abort = TRUE; pthread_exit(NULL); } else @@ -43,7 +42,7 @@ void readPcm(gint numsamples) { gtk_image_set_from_stock(GTK_IMAGE(gui.image_devstatus),GTK_STOCK_DIALOG_WARNING,GTK_ICON_SIZE_SMALL_TOOLBAR); gtk_widget_set_tooltip_text(gui.image_devstatus, "Device is dropping samples"); gdk_threads_leave(); - pcm.BufferDrop = true; + pcm.BufferDrop = TRUE; } } @@ -111,24 +110,24 @@ int initPcmDevice(char *wanteddevname) { char pcm_name[30]; unsigned int exact_rate = 44100; int card; - bool found; + gboolean found; char *cardname; - pcm.BufferDrop = false; + pcm.BufferDrop = FALSE; snd_pcm_hw_params_alloca(&hwparams); card = -1; - found = false; + found = FALSE; if (strcmp(wanteddevname,"default") == 0) { - found=true; + found=TRUE; } else { do { snd_card_next(&card); if (card != -1) { snd_card_get_name(card,&cardname); if (strcmp(cardname, wanteddevname) == 0) { - found=true; + found=TRUE; break; } } diff --git a/slowrx.c b/slowrx.c index 6901d5d..8894026 100644 --- a/slowrx.c +++ b/slowrx.c @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -29,22 +28,22 @@ void *Listen() { guchar Mode=0; struct tm *timeptr = NULL; time_t timet; - bool Finished; + gboolean Finished; char id[20]; GtkTreeIter iter; - while (true) { + while (TRUE) { gdk_threads_enter (); - gtk_widget_set_sensitive (gui.grid_vu, true); - gtk_widget_set_sensitive (gui.button_abort, false); - gtk_widget_set_sensitive (gui.button_clear, true); + gtk_widget_set_sensitive (gui.grid_vu, TRUE); + gtk_widget_set_sensitive (gui.button_abort, FALSE); + gtk_widget_set_sensitive (gui.button_clear, TRUE); gdk_threads_leave (); pcm.WindowPtr = 0; snd_pcm_prepare(pcm.handle); snd_pcm_start (pcm.handle); - Abort = false; + Abort = FALSE; do { @@ -56,10 +55,10 @@ void *Listen() { // If manual resync was requested, redraw image if (ManualResync) { - ManualResync = false; + ManualResync = FALSE; snd_pcm_drop(pcm.handle); printf("getvideo at %.2f skip %d\n",CurrentPic.Rate,CurrentPic.Skip); - GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, true); + GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, TRUE); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(gui.tog_save))) saveCurrentPic(); pcm.WindowPtr = 0; @@ -91,7 +90,7 @@ void *Listen() { } // Allocate space for sync signal - HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight / SYNCPIXLEN +1), sizeof(bool)); + HasSync = calloc((int)(ModeSpec[CurrentPic.Mode].LineLen * ModeSpec[CurrentPic.Mode].ImgHeight / SYNCPIXLEN +1), sizeof(gboolean)); if (HasSync == NULL) { perror("Listen: Unable to allocate memory for sync signal"); exit(EXIT_FAILURE); @@ -101,22 +100,22 @@ void *Listen() { strftime(rctime, sizeof(rctime)-1, "%H:%Mz", timeptr); gdk_threads_enter (); gtk_label_set_text (GTK_LABEL(gui.label_fskid), ""); - gtk_widget_set_sensitive (gui.frame_manual, false); - gtk_widget_set_sensitive (gui.frame_slant, false); - gtk_widget_set_sensitive (gui.combo_card, false); - gtk_widget_set_sensitive (gui.button_abort, true); - gtk_widget_set_sensitive (gui.button_clear, false); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), false); + gtk_widget_set_sensitive (gui.frame_manual, FALSE); + gtk_widget_set_sensitive (gui.frame_slant, FALSE); + gtk_widget_set_sensitive (gui.combo_card, FALSE); + gtk_widget_set_sensitive (gui.button_abort, TRUE); + gtk_widget_set_sensitive (gui.button_clear, FALSE); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(gui.tog_setedge), FALSE); gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Receiving video..." ); gtk_label_set_markup (GTK_LABEL(gui.label_lastmode), ModeSpec[CurrentPic.Mode].Name); gtk_label_set_markup (GTK_LABEL(gui.label_utc), rctime); gdk_threads_leave (); printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", 44100.0, 0, CurrentPic.HedrShift); - Finished = GetVideo(CurrentPic.Mode, 44100, 0, false); + Finished = GetVideo(CurrentPic.Mode, 44100, 0, FALSE); gdk_threads_enter (); - gtk_widget_set_sensitive (gui.button_abort, false); + gtk_widget_set_sensitive (gui.button_abort, FALSE); gdk_threads_leave (); id[0] = '\0'; @@ -140,14 +139,14 @@ void *Listen() { setVU(0,-100); gdk_threads_enter (); gtk_statusbar_push (GTK_STATUSBAR(gui.statusbar), 0, "Calculating slant..." ); - gtk_widget_set_sensitive (gui.grid_vu, false); + gtk_widget_set_sensitive (gui.grid_vu, FALSE); gdk_threads_leave (); printf(" FindSync @ %.1f Hz\n",CurrentPic.Rate); CurrentPic.Rate = FindSync(CurrentPic.Mode, CurrentPic.Rate, &CurrentPic.Skip); // Final image printf(" getvideo @ %.1f Hz, Skip %d, HedrShift %+d Hz\n", CurrentPic.Rate, CurrentPic.Skip, CurrentPic.HedrShift); - GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, true); + GetVideo(CurrentPic.Mode, CurrentPic.Rate, CurrentPic.Skip, TRUE); } free (HasSync); @@ -177,9 +176,9 @@ void *Listen() { } gdk_threads_enter (); - gtk_widget_set_sensitive (gui.frame_slant, true); - gtk_widget_set_sensitive (gui.frame_manual, true); - gtk_widget_set_sensitive (gui.combo_card, true); + gtk_widget_set_sensitive (gui.frame_slant, TRUE); + gtk_widget_set_sensitive (gui.frame_manual, TRUE); + gtk_widget_set_sensitive (gui.combo_card, TRUE); gdk_threads_leave (); } diff --git a/sync.c b/sync.c index 6cefbad..eec02e6 100644 --- a/sync.c +++ b/sync.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -24,14 +23,14 @@ double FindSync (guchar Mode, double Rate, int *Skip) { gushort xAcc[700] = {0}; gushort lines[600][(MAXSLANT-MINSLANT)*2]; gushort cy, cx, Retries = 0; - bool SyncImg[700][630] = {{false}}; + gboolean SyncImg[700][630] = {{FALSE}}; double t=0, slantAngle, s; double ConvoFilter[8] = { 1,1,1,1,-1,-1,-1,-1 }; double convd, maxconvd=0; int xmax=0; // Repeat until slant < 0.5° or until we give up - while (true) { + while (TRUE) { // Draw the 2D sync signal at current rate diff --git a/video.c b/video.c index 3afddc0..05cc8cf 100644 --- a/video.c +++ b/video.c @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -14,10 +13,10 @@ * Mode: M1, M2, S1, S2, R72, R36... * Rate: exact sampling rate used * Skip: number of PCM samples to skip at the beginning (for sync phase adjustment) - * Redraw: false = Apply windowing and FFT to the signal, true = Redraw from cached FFT data - * returns: true when finished, false when aborted + * Redraw: FALSE = Apply windowing and FFT to the signal, TRUE = Redraw from cached FFT data + * returns: TRUE when finished, FALSE when aborted */ -bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) { +gboolean GetVideo(guchar Mode, double Rate, int Skip, gboolean Redraw) { guint MaxBin = 0; guint VideoPlusNoiseBins=0, ReceiverBins=0, NoiseOnlyBins=0; @@ -80,7 +79,7 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) { // Initialize pixbuffer if (!Redraw) { g_object_unref(pixbuf_rx); - pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, false, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight); + pixbuf_rx = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, ModeSpec[Mode].ImgWidth, ModeSpec[Mode].ImgHeight); gdk_pixbuf_fill(pixbuf_rx, 0); } @@ -99,7 +98,7 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) { Length = ModeSpec[Mode].LineLen * ModeSpec[Mode].ImgHeight * 44100; SyncTargetBin = GetBin(1200+CurrentPic.HedrShift, FFTLen); LopassBin = GetBin(5000, FFTLen); - Abort = false; + Abort = FALSE; SyncSampleNum = 0; // Loop through signal @@ -143,8 +142,8 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) { // If there is more than twice the amount of power per Hz in the // sync band than in the video band, we have a sync signal here - if (Psync > 2*Praw) HasSync[SyncSampleNum] = true; - else HasSync[SyncSampleNum] = false; + if (Psync > 2*Praw) HasSync[SyncSampleNum] = TRUE; + else HasSync[SyncSampleNum] = FALSE; NextSyncTime += SYNCPIXLEN; SyncSampleNum ++; @@ -394,12 +393,12 @@ bool GetVideo(guchar Mode, double Rate, int Skip, bool Redraw) { pcm.PeakVal = 0; } - if (Abort) return false; + if (Abort) return FALSE; pcm.WindowPtr ++; } - return true; + return TRUE; } diff --git a/vis.c b/vis.c index 3fd80e0..d97d525 100644 --- a/vis.c +++ b/vis.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -24,7 +23,7 @@ guchar GetVIS () { //gushort pcm.PeakVal = 0; guint FFTLen = 2048, i=0, j=0, k=0, MaxBin = 0; double Power[2048] = {0}, HedrBuf[100] = {0}, tone[100] = {0}, Hann[882] = {0}; - bool gotvis = false; + gboolean gotvis = FALSE; guchar Bit[8] = {0}, ParityBit = 0; for (i = 0; i < FFTLen; i++) in[i] = 0; @@ -32,7 +31,7 @@ guchar GetVIS () { // Create 20ms Hann window for (i = 0; i < 882; i++) Hann[i] = 0.5 * (1 - cos( (2 * M_PI * (double)i) / 881 ) ); - ManualActivated = false; + ManualActivated = FALSE; printf("Waiting for header\n"); @@ -40,7 +39,7 @@ guchar GetVIS () { gtk_statusbar_push( GTK_STATUSBAR(gui.statusbar), 0, "Listening" ); gdk_threads_leave(); - while ( true ) { + while ( TRUE ) { if (Abort || ManualResync) return(0); @@ -78,7 +77,7 @@ guchar GetVIS () { // Is there a pattern that looks like (the end of) a calibration header + VIS? // Tolerance ±25 Hz CurrentPic.HedrShift = 0; - gotvis = false; + gotvis = FALSE; for (i = 0; i < 3; i++) { if (CurrentPic.HedrShift != 0) break; for (j = 0; j < 3; j++) { @@ -93,12 +92,12 @@ guchar GetVIS () { // Attempt to read VIS - gotvis = true; + gotvis = TRUE; for (k = 0; k < 8; k++) { if (tone[6*3+i+3*k] > tone[0+j] - 625 && tone[6*3+i+3*k] < tone[0+j] - 575) Bit[k] = 0; else if (tone[6*3+i+3*k] > tone[0+j] - 825 && tone[6*3+i+3*k] < tone[0+j] - 775) Bit[k] = 1; else { // erroneous bit - gotvis = false; + gotvis = FALSE; break; } } @@ -117,10 +116,10 @@ guchar GetVIS () { if (Parity != ParityBit) { printf(" Parity fail\n"); - gotvis = false; + gotvis = FALSE; } else if (VISmap[VIS] == UNKNOWN) { printf(" Unknown VIS\n"); - gotvis = false; + gotvis = FALSE; } else { gdk_threads_enter(); gtk_combo_box_set_active (GTK_COMBO_BOX(gui.combo_mode), VISmap[VIS]-1); @@ -140,8 +139,8 @@ guchar GetVIS () { if (ManualActivated) { gdk_threads_enter(); - gtk_widget_set_sensitive( gui.frame_manual, false ); - gtk_widget_set_sensitive( gui.combo_card, false ); + gtk_widget_set_sensitive( gui.frame_manual, FALSE ); + gtk_widget_set_sensitive( gui.combo_card, FALSE ); gdk_threads_leave(); selmode = gtk_combo_box_get_active (GTK_COMBO_BOX(gui.combo_mode)) + 1;