Skip to content

Commit

Permalink
excise now-unused terminate flag
Browse files Browse the repository at this point in the history
  • Loading branch information
ka9q committed Apr 11, 2024
1 parent c796b10 commit 586f6a1
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 33 deletions.
8 changes: 2 additions & 6 deletions fm.c
Expand Up @@ -65,11 +65,7 @@ void *demod_fm(void *arg){

realtime();

while(!chan->terminate){
int rval = downconvert(chan);
if(rval != 0)
break;

while(downconvert(chan) == 0){
if(power_squelch && squelch_state == 0){
// quick check SNR from raw signal power to save time on variance-based squelch
// Variance squelch is still needed to suppress various spurs and QRM
Expand Down Expand Up @@ -262,6 +258,6 @@ void *demod_fm(void *arg){
chan->output.energy += output_level;
if(send_output(chan,baseband,N,false) < 0)
break; // no valid output stream; terminate!
} // while(!chan->terminate)
}
return NULL;
}
6 changes: 1 addition & 5 deletions linear.c
Expand Up @@ -56,11 +56,7 @@ void *demod_linear(void *arg){

realtime();

while(!chan->terminate){
int rval = downconvert(chan);
if(rval != 0)
break;

while(downconvert(chan) == 0){
int const N = chan->filter.out.olen; // Number of raw samples in filter output buffer

// First pass over sample block.
Expand Down
11 changes: 3 additions & 8 deletions radio.c
Expand Up @@ -505,11 +505,10 @@ int downconvert(struct channel *chan){

while(true){
// Should we die?
// Won't work correctly if 0 Hz is outside front end coverage
// Should make this cleaner
// Will be slower if 0 Hz is outside front end coverage because of slow timed wait below
// But at least it will eventually go away
if(chan->tune.freq == 0 && chan->lifetime > 0){
chan->lifetime--;
if(chan->lifetime <= 0){
if(--chan->lifetime <= 0){
chan->demod_type = -1; // No demodulator
return -1; // terminate needed
}
Expand Down Expand Up @@ -547,10 +546,6 @@ int downconvert(struct channel *chan){
// end status changes rather than process zeroes. We must still poll the terminate flag.
pthread_mutex_lock(&Frontend.status_mutex);

if(chan->terminate){
pthread_mutex_unlock(&Frontend.status_mutex);
return -1;
}
chan->tune.second_LO = Frontend.frequency - chan->tune.freq;
double const freq = chan->tune.doppler + chan->tune.second_LO; // Total logical oscillator frequency
if(compute_tuning(Frontend.in.ilen + Frontend.in.impulse_length - 1,
Expand Down
3 changes: 0 additions & 3 deletions radio.h
Expand Up @@ -246,9 +246,6 @@ struct channel {
} sap;

pthread_t demod_thread;
// Set this flag to ask demod_thread to terminate.
// pthread_cancel() can't be used because we're usually waiting inside of a mutex, and deadlock will occur
bool terminate;
float tp1,tp2; // Spare test points that can be read on the status channel
};

Expand Down
6 changes: 1 addition & 5 deletions spectrum.c
Expand Up @@ -68,11 +68,7 @@ void *demod_spectrum(void *arg){
set_freq(chan,chan->tune.freq); // retune front end if needed to cover requested bandwidth

// Still need to clean up code to force radio freq to be multiple of FFT bin spacing
while(!chan->terminate){
int rval = downconvert(chan);
if(rval != 0)
break;

while(downconvert(chan) == 0){
int binp = 0;
for(int i=0; i < chan->spectrum.bin_count; i++){ // For each noncoherent integration bin above center freq
float p = 0;
Expand Down
8 changes: 2 additions & 6 deletions wfm.c
Expand Up @@ -112,11 +112,7 @@ void *demod_wfm(void *arg){

realtime();

while(!chan->terminate){
int rval = downconvert(chan);
if(rval != 0)
break;

while(downconvert(chan) == 0){
if(power_squelch && squelch_state == 0){
// quick check SNR from raw signal power to save time on variance-based squelch
// Variance squelch is still needed to suppress various spurs and QRM
Expand Down Expand Up @@ -281,7 +277,7 @@ void *demod_wfm(void *arg){
break; // No output stream! Terminate
chan->output.channels = channels_save;
}
} // while(!chan->terminate)
}
quit:;
delete_filter_output(&mono);
delete_filter_output(&lminusr);
Expand Down

0 comments on commit 586f6a1

Please sign in to comment.