diff --git a/src/voice/ctrlm_voice_obj.cpp b/src/voice/ctrlm_voice_obj.cpp index c3d4e981..71724db2 100644 --- a/src/voice/ctrlm_voice_obj.cpp +++ b/src/voice/ctrlm_voice_obj.cpp @@ -588,18 +588,6 @@ bool ctrlm_voice_t::voice_configure_config_file_json(json_t *obj_voice, json_t * // Update routes this->voice_sdk_update_routes(); - if(this->local_mic) { - // Read privacy mode state from the DB in case power cycle lost HW GPIO state - if(this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_DISABLED) { - XLOGD_INFO("voice is disabled, skip privacy"); - } else { - bool privacy_enabled = this->voice_is_privacy_enabled(); - if(privacy_enabled != this->vsdk_is_privacy_enabled()) { - privacy_enabled ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); - } - } - } - // Set init message if read from DB if(!init.empty()) { this->voice_init_set(init.c_str(), false); @@ -3729,6 +3717,27 @@ void ctrlm_voice_t::voice_privacy_disable(bool update_vsdk) { } } +void ctrlm_voice_t::voice_update_privacy() { + if(!this->local_mic) { + return; + } + sem_wait(&this->device_status_semaphore); + bool mic_disabled = (this->device_status[CTRLM_VOICE_DEVICE_MICROPHONE] & CTRLM_VOICE_DEVICE_STATUS_DISABLED) != 0; + sem_post(&this->device_status_semaphore); + // If the mic is disabled, preserve the existing ctrlm/DB privacy state. + if(mic_disabled) { + XLOGD_INFO("voice is disabled, skip privacy"); + return; + } + + // Refresh ctrlm/DB privacy state from the VSDK after route/input updates. + const bool privacy_vsdk = this->vsdk_is_privacy_enabled(); + const bool privacy_ctrlm = this->voice_is_privacy_enabled(); + if(privacy_vsdk != privacy_ctrlm) { + privacy_vsdk ? this->voice_privacy_enable(false) : this->voice_privacy_disable(false); + } + } + void ctrlm_voice_t::voice_device_enable(ctrlm_voice_device_t device, bool db_write, bool *update_routes) { sem_wait(&this->device_status_semaphore); if((this->device_status[device] & CTRLM_VOICE_DEVICE_STATUS_DISABLED) == 0x00) { // if device IS NOT disabled diff --git a/src/voice/ctrlm_voice_obj.h b/src/voice/ctrlm_voice_obj.h index b7368631..8900a403 100644 --- a/src/voice/ctrlm_voice_obj.h +++ b/src/voice/ctrlm_voice_obj.h @@ -644,6 +644,7 @@ class ctrlm_voice_t { bool voice_is_privacy_enabled(void); void voice_privacy_enable(bool update_vsdk); void voice_privacy_disable(bool update_vsdk); + void voice_update_privacy(); void voice_device_update_set_active(void); void voice_device_update_set_inactive(void); diff --git a/src/voice/ctrlm_voice_obj_generic.cpp b/src/voice/ctrlm_voice_obj_generic.cpp index 4cb35f99..73d08763 100644 --- a/src/voice/ctrlm_voice_obj_generic.cpp +++ b/src/voice/ctrlm_voice_obj_generic.cpp @@ -394,6 +394,10 @@ void ctrlm_voice_generic_t::voice_sdk_update_routes() { if(!xrsr_route(routes)) { XLOGD_ERROR("failed to set routes"); } + + //Updating routes means updating inputs and outputs, so refresh the privacy setting in case inputs changed + this->voice_update_privacy(); + } void ctrlm_voice_generic_t::query_strings_updated() {