Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/voice/ctrlm_voice_obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/voice/ctrlm_voice_obj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions src/voice/ctrlm_voice_obj_generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Loading