diff --git a/crates/chanora_audio/src/engine.rs b/crates/chanora_audio/src/engine.rs index 376ee23..4da1443 100644 --- a/crates/chanora_audio/src/engine.rs +++ b/crates/chanora_audio/src/engine.rs @@ -395,6 +395,22 @@ enum IosVoiceBackend { #[cfg(any(target_os = "ios", target_os = "macos"))] impl IosVoiceBackend { + fn restart(&mut self) -> Result<(), AudioError> { + #[cfg(target_os = "ios")] + { + match self { + Self::Vpio(unit) => unit.restart(), + Self::Raw(unit) => unit.restart(), + } + } + #[cfg(target_os = "macos")] + { + match self { + Self::Vpio(_unit) => Ok(()), + } + } + } + fn pause(&mut self) -> Result<(), AudioError> { #[cfg(target_os = "ios")] { @@ -1404,21 +1420,11 @@ impl AudioEngine { pub fn ios_restart_voice_unit(&self) -> Result<(), AudioError> { #[cfg(any(target_os = "ios", target_os = "macos"))] { - let backend = open_ios_voice_backend(crate::mobile_voice_backend::VoiceAudioParams { - handler: self.audio_handler.clone(), - output_gain: self.output_gain.clone(), - output_muted: self.output_muted.clone(), - voice_out_tx: self.voice_out_tx.clone(), - transmit_active: self.transmit_gate.flag_arc(), - frames_sent: self.frames_sent.clone(), - mic_gain: self.mic_gain, - voice_activity_selector: self.voice_activity_selector.clone(), - audio_processing_config: self.audio_processing_config.clone(), - audio_processing_stats: self.audio_processing_stats.clone(), - })?; let mut guard = self._ios_voice_backend.lock().unwrap(); - *guard = Some(backend); - Ok(()) + let backend = guard + .as_mut() + .ok_or_else(|| AudioError::Backend("ios voice backend not running".to_string()))?; + backend.restart() } #[cfg(not(any(target_os = "ios", target_os = "macos")))] {