From 29b9651ebdcaaa837518de4167ea5d20e5af68e3 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 18 Oct 2022 15:47:56 +0200 Subject: [PATCH] Use `CFRelease` instead of a custom `LKRelease` --- .../Sources/LiveKitBridge/LiveKitBridge.swift | 5 ----- crates/live_kit_client/src/live_kit_client.rs | 14 ++++++-------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift index dadc2fdb10..c7ce2178ab 100644 --- a/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift +++ b/crates/live_kit_client/LiveKitBridge/Sources/LiveKitBridge/LiveKitBridge.swift @@ -55,11 +55,6 @@ class LKVideoRenderer: NSObject, VideoRenderer { } } -@_cdecl("LKRelease") -public func LKRelease(ptr: UnsafeRawPointer) { - let _ = Unmanaged.fromOpaque(ptr).takeRetainedValue() -} - @_cdecl("LKRoomDelegateCreate") public func LKRoomDelegateCreate(data: UnsafeRawPointer, onDidSubscribeToRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString, UnsafeRawPointer) -> Void, onDidUnsubscribeFromRemoteVideoTrack: @escaping @convention(c) (UnsafeRawPointer, CFString, CFString) -> Void) -> UnsafeMutableRawPointer { let delegate = LKRoomDelegate(data: data, onDidSubscribeToRemoteVideoTrack: onDidSubscribeToRemoteVideoTrack, onDidUnsubscribeFromRemoteVideoTrack: onDidUnsubscribeFromRemoteVideoTrack) diff --git a/crates/live_kit_client/src/live_kit_client.rs b/crates/live_kit_client/src/live_kit_client.rs index 07075dcee8..8eaa9a6f6a 100644 --- a/crates/live_kit_client/src/live_kit_client.rs +++ b/crates/live_kit_client/src/live_kit_client.rs @@ -1,7 +1,7 @@ use anyhow::{anyhow, Context, Result}; use core_foundation::{ array::{CFArray, CFArrayRef}, - base::{CFRetain, TCFType}, + base::{CFRelease, CFRetain, TCFType}, string::{CFString, CFStringRef}, }; use futures::{ @@ -18,8 +18,6 @@ use std::{ pub type Sid = String; extern "C" { - fn LKRelease(object: *const c_void); - fn LKRoomDelegateCreate( callback_data: *mut c_void, on_did_subscribe_to_remote_video_track: extern "C" fn( @@ -198,7 +196,7 @@ impl Drop for Room { fn drop(&mut self) { unsafe { LKRoomDisconnect(self.native_room); - LKRelease(self.native_room); + CFRelease(self.native_room); } } } @@ -257,7 +255,7 @@ impl RoomDelegate { impl Drop for RoomDelegate { fn drop(&mut self) { unsafe { - LKRelease(self.native_delegate); + CFRelease(self.native_delegate); let _ = Weak::from_raw(self.weak_room); } } @@ -273,7 +271,7 @@ impl LocalVideoTrack { impl Drop for LocalVideoTrack { fn drop(&mut self) { - unsafe { LKRelease(self.0) } + unsafe { CFRelease(self.0) } } } @@ -336,7 +334,7 @@ impl RemoteVideoTrack { impl Drop for RemoteVideoTrack { fn drop(&mut self) { - unsafe { LKRelease(self.native_track) } + unsafe { CFRelease(self.native_track) } } } @@ -358,7 +356,7 @@ impl MacOSDisplay { impl Drop for MacOSDisplay { fn drop(&mut self) { - unsafe { LKRelease(self.0) } + unsafe { CFRelease(self.0) } } }