Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix(native): properly cleanup resource when activating device failed (#11380)

pengx17abfbf0771249
diff --git a/packages/frontend/native/media_capture/src/macos/tap_audio.rs b/packages/frontend/native/media_capture/src/macos/tap_audio.rs
index 63ac22780f..be0b9ed0e5 100644
--- a/packages/frontend/native/media_capture/src/macos/tap_audio.rs
+++ b/packages/frontend/native/media_capture/src/macos/tap_audio.rs
@@ -225,6 +225,8 @@ impl AggregateDevice {
// Start the device to activate it
let status = unsafe { AudioDeviceStart(device_id, dummy_proc_id) };
if status != 0 {
+ // Clean up the IO proc if AudioDeviceStart fails
+ let _ = unsafe { AudioDeviceDestroyIOProcID(device_id, dummy_proc_id) };
return Err(CoreAudioError::AudioDeviceStartFailed(status).into());
}