fix: rust conn build

This commit is contained in:
Kingtous 2023-02-06 11:53:37 +08:00
parent b412a7122b
commit 11c6008811

View File

@ -398,7 +398,9 @@ impl Connection {
conn.send(msg).await; conn.send(msg).await;
} }
ipc::Data::VoiceCallResponse(accepted) => { ipc::Data::VoiceCallResponse(accepted) => {
conn.start_voice_call().await; if accepted {
conn.start_voice_call().await;
}
} }
ipc::Data::CloseVoiceCall(_reason) => { ipc::Data::CloseVoiceCall(_reason) => {
conn.close_voice_call().await; conn.close_voice_call().await;
@ -1611,19 +1613,17 @@ impl Connection {
true true
} }
pub async fn start_voice_call(&self) { pub async fn start_voice_call(&mut self) {
if let Some(ts) = conn.voice_call_request_timestamp.take() { if let Some(ts) = self.voice_call_request_timestamp.take() {
let msg = new_voice_call_response(ts.get(), accepted); let msg = new_voice_call_response(ts.get(), accepted);
conn.send(msg).await; conn.send(msg).await;
if accepted { // Backup the default input device.
// Backup the default input device. let audio_input_device = Config::get_option("audio-input");
let audio_input_device = Config::get_option("audio-input"); self.audio_input_device_before_voice_call = Some(audio_input_device);
conn.audio_input_device_before_voice_call = Some(audio_input_device); // Switch to default input device
// Switch to default input device let default_sound_device = get_default_sound_input();
let default_sound_device = get_default_sound_input(); if let Some(device) = default_sound_device {
if let Some(device) = default_sound_device { set_sound_input(device);
set_sound_input(device);
}
} }
} else { } else {
log::warn!("Possible a voice call attack."); log::warn!("Possible a voice call attack.");