fix(audio): replace Mutex unwrap with poisoned-mutex recovery (TODO-006)
Replace 42 .lock().unwrap() calls with .unwrap_or_else(|e| e.into_inner()) across 7 files. Poisoned mutex recovery prevents panics in realtime audio callbacks. Add SAFETY comment to WebRtcFallbackVad Send impl (TODO-007).
This commit is contained in:
@@ -549,7 +549,7 @@ impl IosVoiceUnit {
|
||||
let unit_arc2 = Arc::clone(&unit_arc);
|
||||
|
||||
dispatch2::DispatchQueue::main().exec_async(move || {
|
||||
let mut guard = unit_arc2.lock().unwrap();
|
||||
let mut guard = unit_arc2.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let unit = guard.as_mut().unwrap();
|
||||
let _ = tx.send(op(unit));
|
||||
});
|
||||
@@ -559,7 +559,7 @@ impl IosVoiceUnit {
|
||||
Err(_) => Err("vpio lifecycle: main thread channel closed unexpectedly".to_string()),
|
||||
};
|
||||
|
||||
self.unit = unit_arc.lock().unwrap().take();
|
||||
self.unit = unit_arc.lock().unwrap_or_else(|e| e.into_inner()).take();
|
||||
result.map_err(AudioError::Backend)
|
||||
}
|
||||
|
||||
@@ -1072,7 +1072,7 @@ impl IosVoiceUnit {
|
||||
let unit_arc2 = unit_arc.clone();
|
||||
|
||||
dispatch2::DispatchQueue::main().exec_async(move || {
|
||||
let mut guard = unit_arc2.lock().unwrap();
|
||||
let mut guard = unit_arc2.lock().unwrap_or_else(|e| e.into_inner());
|
||||
let u = guard.as_mut().unwrap();
|
||||
let result = u
|
||||
.initialize()
|
||||
@@ -1094,7 +1094,7 @@ impl IosVoiceUnit {
|
||||
}
|
||||
}
|
||||
|
||||
unit = unit_arc.lock().unwrap().take().unwrap();
|
||||
unit = unit_arc.lock().unwrap_or_else(|e| e.into_inner()).take().unwrap();
|
||||
}
|
||||
|
||||
info!(
|
||||
|
||||
Reference in New Issue
Block a user