Event History: Move event_history_s from the stack to the heap; Calloc Plenty of Memory for it; #287

This commit is contained in:
lwvmobile
2025-04-23 16:27:25 -04:00
parent 8cbfb96141
commit 71d4d30f3a
2 changed files with 3614 additions and 3611 deletions

View File

@@ -731,7 +731,7 @@ typedef struct
dPMRVoiceFS2Frame_t dPMRVoiceFS2Frame; dPMRVoiceFS2Frame_t dPMRVoiceFS2Frame;
//event history itemized per slot //event history itemized per slot
Event_History_I event_history_s[2]; Event_History_I * event_history_s;
//new audio filter structs //new audio filter structs
LPFilter RCFilter; LPFilter RCFilter;

View File

@@ -15,34 +15,34 @@
* PERFORMANCE OF THIS SOFTWARE. * PERFORMANCE OF THIS SOFTWARE.
*/ */
#define _MAIN #define _MAIN
#include "dsd.h" #include "dsd.h"
#include "p25p1_const.h" #include "p25p1_const.h"
#include "x2tdma_const.h" #include "x2tdma_const.h"
#include "dstar_const.h" #include "dstar_const.h"
#include "nxdn_const.h" #include "nxdn_const.h"
#include "dmr_const.h" #include "dmr_const.h"
#include "provoice_const.h" #include "provoice_const.h"
#include "git_ver.h" #include "git_ver.h"
#include <signal.h> #include <signal.h>
#ifdef USE_RTLSDR #ifdef USE_RTLSDR
#include <rtl-sdr.h> #include <rtl-sdr.h>
#endif #endif
volatile uint8_t exitflag; //fix for issue #136 volatile uint8_t exitflag; //fix for issue #136
void handler(int sgnl) void handler(int sgnl)
{ {
UNUSED(sgnl); UNUSED(sgnl);
exitflag = 1; exitflag = 1;
} }
int pretty_colors() int pretty_colors()
{ {
fprintf (stderr,"%sred\n", KRED); fprintf (stderr,"%sred\n", KRED);
fprintf (stderr,"%sgreen\n", KGRN); fprintf (stderr,"%sgreen\n", KGRN);
fprintf (stderr,"%syellow\n", KYEL); fprintf (stderr,"%syellow\n", KYEL);
@@ -53,14 +53,14 @@ int pretty_colors()
fprintf (stderr,"%snormal\n", KNRM); fprintf (stderr,"%snormal\n", KNRM);
return 0; return 0;
} }
#include "p25p1_heuristics.h" #include "p25p1_heuristics.h"
#include "pa_devs.h" #include "pa_devs.h"
#ifdef LIMAZULUTWEAKS #ifdef LIMAZULUTWEAKS
char * FM_banner[9] = { char * FM_banner[9] = {
" ", " ",
" ██████╗ ██████╗██████╗ ███╗ ███████╗", " ██████╗ ██████╗██████╗ ███╗ ███████╗",
" ██╔══██╗██╔════╝██╔══██╗ ███║ ╚════██║", " ██╔══██╗██╔════╝██╔══██╗ ███║ ╚════██║",
@@ -69,9 +69,9 @@ char * FM_banner[9] = {
" ██████╔╝██████╔╝██████╔╝ Edition VI ████████╗███████╗", " ██████╔╝██████╔╝██████╔╝ Edition VI ████████╗███████╗",
" ╚═════╝ ╚═════╝ ╚═════╝ ╚═══════╝╚══════╝", " ╚═════╝ ╚═════╝ ╚═════╝ ╚═══════╝╚══════╝",
" " " "
}; };
#else #else
char * FM_banner[9] = { char * FM_banner[9] = {
" ", " ",
" ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗", " ██████╗ ██████╗██████╗    ███████╗███╗ ███╗███████╗",
" ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝", " ██╔══██╗██╔════╝██╔══██╗   ██╔════╝████╗ ████║██╔════╝",
@@ -80,32 +80,32 @@ char * FM_banner[9] = {
" ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗", " ██████╔╝██████╔╝██████╔╝   ██║ ██║ ╚═╝ ██║███████╗",
" ╚═════╝ ╚═════╝ ╚═════╝    ╚═╝ ╚═╝ ╚═╝╚══════╝", " ╚═════╝ ╚═════╝ ╚═════╝    ╚═╝ ╚═╝ ╚═╝╚══════╝",
" " " "
}; };
#endif #endif
int comp (const void *a, const void *b) int comp (const void *a, const void *b)
{ {
if (*((const int *) a) == *((const int *) b)) if (*((const int *) a) == *((const int *) b))
return 0; return 0;
else if (*((const int *) a) < *((const int *) b)) else if (*((const int *) a) < *((const int *) b))
return -1; return -1;
else else
return 1; return 1;
} }
//struct for checking existence of directory to write to //struct for checking existence of directory to write to
struct stat st = {0}; struct stat st = {0};
char wav_file_directory[1024] = {0}; char wav_file_directory[1024] = {0};
char dsp_filename[1024] = {0}; char dsp_filename[1024] = {0};
unsigned long long int p2vars = 0; unsigned long long int p2vars = 0;
char * pEnd; //bugfix char * pEnd; //bugfix
int slotson = 3; int slotson = 3;
void void
noCarrier (dsd_opts * opts, dsd_state * state) noCarrier (dsd_opts * opts, dsd_state * state)
{ {
if (opts->floating_point == 1) if (opts->floating_point == 1)
{ {
@@ -580,11 +580,11 @@ noCarrier (dsd_opts * opts, dsd_state * state)
memset (state->s_l4u, 0, sizeof(state->s_l4u)); memset (state->s_l4u, 0, sizeof(state->s_l4u));
memset (state->s_r4u, 0, sizeof(state->s_r4u)); memset (state->s_r4u, 0, sizeof(state->s_r4u));
} //nocarrier } //nocarrier
void void
initOpts (dsd_opts * opts) initOpts (dsd_opts * opts)
{ {
opts->floating_point = 0; //use floating point audio output opts->floating_point = 0; //use floating point audio output
opts->onesymbol = 10; opts->onesymbol = 10;
opts->mbe_in_file[0] = 0; opts->mbe_in_file[0] = 0;
@@ -831,11 +831,11 @@ initOpts (dsd_opts * opts)
//Use P25p1 heuristics //Use P25p1 heuristics
opts->use_heuristics = 0; opts->use_heuristics = 0;
} //initopts } //initopts
void void
initState (dsd_state * state) initState (dsd_state * state)
{ {
int i, j; int i, j;
// state->testcounter = 0; // state->testcounter = 0;
@@ -1321,15 +1321,17 @@ initState (dsd_state * state)
state->dmr_color_code = 16; state->dmr_color_code = 16;
state->event_history_s = calloc(1, 10000000000); //TODO: tweak this size later on
//initialize event history items (0 to 255) //initialize event history items (0 to 255)
for (uint8_t i = 0; i < 2; i++) for (uint8_t i = 0; i < 2; i++)
init_event_history(&state->event_history_s[i], 0, 255); init_event_history(&state->event_history_s[i], 0, 255);
} //init_state } //init_state
void void
usage () usage ()
{ {
printf ("\n"); printf ("\n");
printf ("Usage: dsd-fme [options] Decoder/Trunking Mode\n"); printf ("Usage: dsd-fme [options] Decoder/Trunking Mode\n");
@@ -1571,11 +1573,11 @@ usage ()
printf (" Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n"); printf (" Trunking Example RTL: dsd-fme -fs -i rtl:0:450M:26:-2:8 -T -C connect_plus_chan.csv -G group.csv -N 2> log.ans\n");
printf ("\n"); printf ("\n");
exit (0); exit (0);
} }
void void
liveScanner (dsd_opts * opts, dsd_state * state) liveScanner (dsd_opts * opts, dsd_state * state)
{ {
if (opts->floating_point == 1) if (opts->floating_point == 1)
{ {
@@ -1589,7 +1591,7 @@ liveScanner (dsd_opts * opts, dsd_state * state)
state->aout_gainR = 15.0f; state->aout_gainR = 15.0f;
} }
#ifdef USE_RTLSDR #ifdef USE_RTLSDR
if(opts->audio_in_type == 3) if(opts->audio_in_type == 3)
{ {
open_rtlsdr_stream(opts); open_rtlsdr_stream(opts);
@@ -1601,25 +1603,25 @@ liveScanner (dsd_opts * opts, dsd_state * state)
// opts->rtl_squelch_level = 0; // opts->rtl_squelch_level = 0;
// #endif // #endif
} }
#endif #endif
if (opts->use_ncurses_terminal == 1) if (opts->use_ncurses_terminal == 1)
{ {
ncursesOpen(opts, state); ncursesOpen(opts, state);
} }
if (opts->audio_in_type == 0) if (opts->audio_in_type == 0)
{ {
openPulseInput(opts); openPulseInput(opts);
} }
if (opts->audio_out_type == 0) if (opts->audio_out_type == 0)
{ {
openPulseOutput(opts); openPulseOutput(opts);
} }
//test P25 moto alias by loading in test vectors captured from a system and dumped on forum (see dsd_gps.c) //test P25 moto alias by loading in test vectors captured from a system and dumped on forum (see dsd_gps.c)
// apx_embedded_alias_test_phase1(opts, state); //enable this to run test // apx_embedded_alias_test_phase1(opts, state); //enable this to run test
while (!exitflag) while (!exitflag)
{ {
@@ -1640,15 +1642,15 @@ if (opts->audio_out_type == 0)
{ {
processFrame (opts, state); processFrame (opts, state);
#ifdef TRACE_DSD #ifdef TRACE_DSD
state->debug_prefix = 'S'; state->debug_prefix = 'S';
#endif #endif
// state->synctype = getFrameSync (opts, state); // state->synctype = getFrameSync (opts, state);
#ifdef TRACE_DSD #ifdef TRACE_DSD
state->debug_prefix = '\0'; state->debug_prefix = '\0';
#endif #endif
// // recalibrate center/umid/lmid // // recalibrate center/umid/lmid
// state->center = ((state->max) + (state->min)) / 2; // state->center = ((state->max) + (state->min)) / 2;
@@ -1664,11 +1666,11 @@ if (opts->audio_out_type == 0)
} }
} }
} }
} }
void void
cleanupAndExit (dsd_opts * opts, dsd_state * state) cleanupAndExit (dsd_opts * opts, dsd_state * state)
{ {
// Signal that everything should shutdown. // Signal that everything should shutdown.
exitflag = 1; exitflag = 1;
@@ -1724,10 +1726,10 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
fprintf (stderr,"Total irrecoverable header errors: %i\n", state->debug_header_critical_errors); fprintf (stderr,"Total irrecoverable header errors: %i\n", state->debug_header_critical_errors);
fprintf (stderr,"Exiting.\n"); fprintf (stderr,"Exiting.\n");
exit (0); exit (0);
} }
double atofs(char *s) double atofs(char *s)
{ {
char last; char last;
int len; int len;
double suff = 1.0; double suff = 1.0;
@@ -1750,11 +1752,11 @@ double atofs(char *s)
} }
s[len-1] = last; s[len-1] = last;
return atof(s); return atof(s);
} }
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
int c; int c;
//optarg and optind already defined when using Cygwin, no need to do so again //optarg and optind already defined when using Cygwin, no need to do so again
#ifdef __CYGWIN__ #ifdef __CYGWIN__
@@ -3622,6 +3624,7 @@ main (int argc, char **argv)
cleanupAndExit (&opts, &state); cleanupAndExit (&opts, &state);
return (0); return (0);
} }
//Tag: 2025
//Tag: 2025