Skip to content

Commit 91c8ce8

Browse files
committed
fix(pulseaudio): recover poisoned locks
1 parent 31ee599 commit 91c8ce8

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

src/host/pulseaudio/stream.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,13 @@ impl Stream {
219219
let error_callback_clone = error_callback.clone();
220220
std::thread::spawn(move || {
221221
if let Err(e) = block_on(stream_clone.play_all()) {
222-
error_callback_clone.lock().unwrap()(StreamError::from(BackendSpecificError {
223-
description: e.to_string(),
224-
}));
222+
error_callback_clone
223+
.lock()
224+
.unwrap_or_else(|e| e.into_inner())(StreamError::from(
225+
BackendSpecificError {
226+
description: e.to_string(),
227+
},
228+
));
225229
}
226230
});
227231

@@ -239,9 +243,11 @@ impl Stream {
239243
let timing_info = match block_on(stream_clone.timing_info()) {
240244
Ok(timing_info) => timing_info,
241245
Err(e) => {
242-
error_callback.lock().unwrap()(StreamError::from(BackendSpecificError {
243-
description: e.to_string(),
244-
}));
246+
error_callback.lock().unwrap_or_else(|e| e.into_inner())(StreamError::from(
247+
BackendSpecificError {
248+
description: e.to_string(),
249+
},
250+
));
245251
break;
246252
}
247253
};

0 commit comments

Comments
 (0)