Skip to content

Commit

Permalink
fix crash when attempting to record from disabled radio
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreRouma committed Apr 22, 2024
1 parent ccb10bf commit e60eca5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions decoder_modules/radio/src/radio_module.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,22 +597,24 @@ class RadioModule : public ModuleManager::Instance {

static void moduleInterfaceHandler(int code, void* in, void* out, void* ctx) {
RadioModule* _this = (RadioModule*)ctx;
if (!_this->enabled || !_this->selectedDemod) { return; }

// If no demod is selected, reject the command
if (!_this->selectedDemod) { return; }

// Execute commands
if (code == RADIO_IFACE_CMD_GET_MODE && out) {
int* _out = (int*)out;
*_out = _this->selectedDemodID;
}
else if (code == RADIO_IFACE_CMD_SET_MODE && in) {
else if (code == RADIO_IFACE_CMD_SET_MODE && in && _this->enabled) {
int* _in = (int*)in;
_this->selectDemodByID((DemodID)*_in);
}
else if (code == RADIO_IFACE_CMD_GET_BANDWIDTH && out) {
float* _out = (float*)out;
*_out = _this->bandwidth;
}
else if (code == RADIO_IFACE_CMD_SET_BANDWIDTH && in) {
else if (code == RADIO_IFACE_CMD_SET_BANDWIDTH && in && _this->enabled) {
float* _in = (float*)in;
if (_this->bandwidthLocked) { return; }
_this->setBandwidth(*_in);
Expand All @@ -621,15 +623,15 @@ class RadioModule : public ModuleManager::Instance {
bool* _out = (bool*)out;
*_out = _this->squelchEnabled;
}
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_ENABLED && in) {
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_ENABLED && in && _this->enabled) {
bool* _in = (bool*)in;
_this->setSquelchEnabled(*_in);
}
else if (code == RADIO_IFACE_CMD_GET_SQUELCH_LEVEL && out) {
float* _out = (float*)out;
*_out = _this->squelchLevel;
}
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_LEVEL && in) {
else if (code == RADIO_IFACE_CMD_SET_SQUELCH_LEVEL && in && _this->enabled) {
float* _in = (float*)in;
_this->setSquelchLevel(*_in);
}
Expand Down

0 comments on commit e60eca5

Please sign in to comment.