mirror of
https://github.com/lwvmobile/dsd-fme.git
synced 2026-11-12 08:47:24 -05:00
Cleanup code related to symbol out (logic did not change)
This commit is contained in:
@@ -229,7 +229,6 @@ typedef struct
|
||||
char symbol_out_file[1024];
|
||||
char lrrp_out_file[1024];
|
||||
char szNumbers[1024]; //**tera 10/32/64 char str
|
||||
short int symbol_out;
|
||||
short int mbe_out; //flag for mbe out, don't attempt fclose more than once
|
||||
short int mbe_outR; //flag for mbe out, don't attempt fclose more than once
|
||||
SNDFILE *wav_out_f;
|
||||
@@ -838,7 +837,6 @@ void openWavOutFileR (dsd_opts * opts, dsd_state * state);
|
||||
void openWavOutFileRaw (dsd_opts * opts, dsd_state * state);
|
||||
void openSymbolOutFile (dsd_opts * opts, dsd_state * state);
|
||||
void closeSymbolOutFile (dsd_opts * opts, dsd_state * state);
|
||||
void writeSymbolOutFile (dsd_opts * opts, dsd_state * state);
|
||||
void writeRawSample (dsd_opts * opts, dsd_state * state, short sample);
|
||||
void closeWavOutFile (dsd_opts * opts, dsd_state * state);
|
||||
void closeWavOutFileL (dsd_opts * opts, dsd_state * state);
|
||||
|
||||
@@ -445,7 +445,7 @@ get_dibit_and_analog_signal (dsd_opts* opts, dsd_state* state, int* out_analog_s
|
||||
}
|
||||
|
||||
//symbol/dibit file capture/writing
|
||||
if (opts->symbol_out == 1)
|
||||
if (opts->symbol_out_f)
|
||||
{
|
||||
//fprintf (stderr, "%d", dibit);
|
||||
fputc (dibit, opts->symbol_out_f);
|
||||
|
||||
@@ -560,29 +560,15 @@ void closeWavOutFileRaw (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
void openSymbolOutFile (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
//Do something
|
||||
closeSymbolOutFile(opts, state);
|
||||
opts->symbol_out_f = fopen (opts->symbol_out_file, "w");
|
||||
}
|
||||
|
||||
void writeSymbolOutFile (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
//Do something
|
||||
|
||||
}
|
||||
|
||||
void closeSymbolOutFile (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
//Do something
|
||||
if (opts->symbol_out == 1)
|
||||
if (opts->symbol_out_f)
|
||||
{
|
||||
if (opts->symbol_out_f != NULL)
|
||||
{
|
||||
fclose(opts->symbol_out_f);
|
||||
opts->symbol_out_f = NULL;
|
||||
}
|
||||
|
||||
opts->symbol_out = 0; //set flag to 1
|
||||
|
||||
fclose(opts->symbol_out_f);
|
||||
opts->symbol_out_f = NULL;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state)
|
||||
dibit = 51; // '3'
|
||||
}
|
||||
|
||||
if (opts->symbol_out == 1 && dibit != 0)
|
||||
if (opts->symbol_out_f && dibit != 0)
|
||||
{
|
||||
int csymbol = 0;
|
||||
if (dibit == 49)
|
||||
|
||||
@@ -501,7 +501,6 @@ initOpts (dsd_opts * opts)
|
||||
//end import filenames
|
||||
opts->szNumbers[0] = 0;
|
||||
opts->symbol_out_f = NULL;
|
||||
opts->symbol_out = 0;
|
||||
opts->mbe_out = 0;
|
||||
opts->mbe_outR = 0; //second slot on a TDMA system
|
||||
opts->wav_out_f = NULL;
|
||||
@@ -1312,11 +1311,8 @@ cleanupAndExit (dsd_opts * opts, dsd_state * state)
|
||||
closeWavOutFileL (opts, state);
|
||||
closeWavOutFileR (opts, state);
|
||||
}
|
||||
if (opts->symbol_out == 1)
|
||||
{
|
||||
closeSymbolOutFile (opts, state);
|
||||
}
|
||||
|
||||
closeSymbolOutFile (opts, state);
|
||||
|
||||
//close MBE out files
|
||||
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
|
||||
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
|
||||
@@ -1698,7 +1694,6 @@ main (int argc, char **argv)
|
||||
strncpy(opts.symbol_out_file, optarg, 1023);
|
||||
opts.symbol_out_file[1023] = '\0';
|
||||
fprintf (stderr,"Writing + Appending symbol capture to file %s\n", opts.symbol_out_file);
|
||||
opts.symbol_out = 1;
|
||||
openSymbolOutFile (&opts, &state);
|
||||
break;
|
||||
|
||||
|
||||
@@ -607,12 +607,7 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||
wscanw(entry_win, "%s", opts->symbol_out_file); //&opts->symbol_out_file
|
||||
noecho();
|
||||
|
||||
if (opts->symbol_out_file[0] != 0) //NULL
|
||||
{
|
||||
opts->symbol_out = 1; //set flag to 1
|
||||
openSymbolOutFile (opts, state);
|
||||
}
|
||||
|
||||
openSymbolOutFile (opts, state);
|
||||
}
|
||||
if (choicec == 4)
|
||||
{
|
||||
@@ -1030,16 +1025,10 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
|
||||
|
||||
if (choicec == 16) //stop/close last file RECORDING
|
||||
{
|
||||
if (opts->symbol_out == 1)
|
||||
if (opts->symbol_out_f)
|
||||
{
|
||||
if (opts->symbol_out_file[0] != 0) //NULL
|
||||
{
|
||||
fclose(opts->symbol_out_f); //free(): double free detected in tcache 2 (this is a new one) happens when closing more than once
|
||||
sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file); //swap output bin filename to input for quick replay
|
||||
}
|
||||
|
||||
opts->symbol_out = 0; //set flag to 1
|
||||
|
||||
closeSymbolOutFile (opts, state);
|
||||
sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file); //swap output bin filename to input for quick replay
|
||||
}
|
||||
choicec = 18; //exit
|
||||
}
|
||||
@@ -2278,11 +2267,11 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
{
|
||||
printw ("| Appending Raw Sig Audio WAV to file %s\n", opts->wav_out_file_raw);
|
||||
}
|
||||
if (opts->symbol_out_file[0] != 0 && opts->symbol_out == 1)
|
||||
if (opts->symbol_out_file[0] != 0)
|
||||
{
|
||||
printw ("| SymbolC Bin: %s\n", opts->symbol_out_file);
|
||||
}
|
||||
if (opts->wav_out_file[0] != 0 && opts->dmr_stereo_wav == 0)
|
||||
if (opts->wav_out_file[0] != 0)
|
||||
{
|
||||
printw ("| Decoded WAV: %s\n", opts->wav_out_file);
|
||||
}
|
||||
@@ -3420,24 +3409,15 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
|
||||
if (c == 82) //'R', save symbol capture bin with date/time string as name
|
||||
{
|
||||
sprintf (opts->symbol_out_file, "%s %s.bin", getDateN(), getTimeN());
|
||||
if (opts->symbol_out_file[0] != 0)
|
||||
{
|
||||
opts->symbol_out = 1; //set flag to 1
|
||||
openSymbolOutFile (opts, state);
|
||||
}
|
||||
openSymbolOutFile (opts, state);
|
||||
}
|
||||
|
||||
if (c == 114) //'r' key, stop capturing symbol capture bin file
|
||||
{
|
||||
if (opts->symbol_out == 1)
|
||||
if (opts->symbol_out_f)
|
||||
{
|
||||
if (opts->symbol_out_file[0] != 0)
|
||||
{
|
||||
fclose(opts->symbol_out_f);
|
||||
sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file);
|
||||
}
|
||||
|
||||
opts->symbol_out = 0;
|
||||
closeSymbolOutFile (opts, state);
|
||||
sprintf (opts->audio_in_dev, "%s", opts->symbol_out_file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user