fix crash when attempting to record from disabled radio

This commit is contained in:
AlexandreRouma 2024-04-22 21:51:49 +02:00
parent ccb10bfb9a
commit e60eca5d6d

View File

@ -597,14 +597,16 @@ private:
static void moduleInterfaceHandler(int code, void* in, void* out, void* ctx) { static void moduleInterfaceHandler(int code, void* in, void* out, void* ctx) {
RadioModule* _this = (RadioModule*)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 // Execute commands
if (code == RADIO_IFACE_CMD_GET_MODE && out) { if (code == RADIO_IFACE_CMD_GET_MODE && out) {
int* _out = (int*)out; int* _out = (int*)out;
*_out = _this->selectedDemodID; *_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; int* _in = (int*)in;
_this->selectDemodByID((DemodID)*_in); _this->selectDemodByID((DemodID)*_in);
} }
@ -612,7 +614,7 @@ private:
float* _out = (float*)out; float* _out = (float*)out;
*_out = _this->bandwidth; *_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; float* _in = (float*)in;
if (_this->bandwidthLocked) { return; } if (_this->bandwidthLocked) { return; }
_this->setBandwidth(*_in); _this->setBandwidth(*_in);
@ -621,7 +623,7 @@ private:
bool* _out = (bool*)out; bool* _out = (bool*)out;
*_out = _this->squelchEnabled; *_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; bool* _in = (bool*)in;
_this->setSquelchEnabled(*_in); _this->setSquelchEnabled(*_in);
} }
@ -629,7 +631,7 @@ private:
float* _out = (float*)out; float* _out = (float*)out;
*_out = _this->squelchLevel; *_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; float* _in = (float*)in;
_this->setSquelchLevel(*_in); _this->setSquelchLevel(*_in);
} }