Fix segfault with remote track publications
co-authored-by: antonio <antonio@zed.dev>
This commit is contained in:
parent
5ffe74f47e
commit
05c97ed355
1 changed files with 17 additions and 3 deletions
|
@ -219,7 +219,7 @@ impl Room {
|
||||||
let tx =
|
let tx =
|
||||||
unsafe { Box::from_raw(tx as *mut oneshot::Sender<Result<LocalTrackPublication>>) };
|
unsafe { Box::from_raw(tx as *mut oneshot::Sender<Result<LocalTrackPublication>>) };
|
||||||
if error.is_null() {
|
if error.is_null() {
|
||||||
let _ = tx.send(Ok(LocalTrackPublication(publication)));
|
let _ = tx.send(Ok(LocalTrackPublication::new(publication)));
|
||||||
} else {
|
} else {
|
||||||
let error = unsafe { CFString::wrap_under_get_rule(error).to_string() };
|
let error = unsafe { CFString::wrap_under_get_rule(error).to_string() };
|
||||||
let _ = tx.send(Err(anyhow!(error)));
|
let _ = tx.send(Err(anyhow!(error)));
|
||||||
|
@ -245,7 +245,7 @@ impl Room {
|
||||||
let tx =
|
let tx =
|
||||||
unsafe { Box::from_raw(tx as *mut oneshot::Sender<Result<LocalTrackPublication>>) };
|
unsafe { Box::from_raw(tx as *mut oneshot::Sender<Result<LocalTrackPublication>>) };
|
||||||
if error.is_null() {
|
if error.is_null() {
|
||||||
let _ = tx.send(Ok(LocalTrackPublication(publication)));
|
let _ = tx.send(Ok(LocalTrackPublication::new(publication)));
|
||||||
} else {
|
} else {
|
||||||
let error = unsafe { CFString::wrap_under_get_rule(error).to_string() };
|
let error = unsafe { CFString::wrap_under_get_rule(error).to_string() };
|
||||||
let _ = tx.send(Err(anyhow!(error)));
|
let _ = tx.send(Err(anyhow!(error)));
|
||||||
|
@ -344,7 +344,7 @@ impl Room {
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|native_track_publication| {
|
.map(|native_track_publication| {
|
||||||
let native_track_publication = *native_track_publication;
|
let native_track_publication = *native_track_publication;
|
||||||
Arc::new(RemoteTrackPublication(native_track_publication))
|
Arc::new(RemoteTrackPublication::new(native_track_publication))
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -564,6 +564,13 @@ impl Drop for LocalVideoTrack {
|
||||||
pub struct LocalTrackPublication(*const c_void);
|
pub struct LocalTrackPublication(*const c_void);
|
||||||
|
|
||||||
impl LocalTrackPublication {
|
impl LocalTrackPublication {
|
||||||
|
pub fn new(native_track_publication: *const c_void) -> Self {
|
||||||
|
unsafe {
|
||||||
|
CFRetain(native_track_publication);
|
||||||
|
}
|
||||||
|
Self(native_track_publication)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_mute(&self, muted: bool) -> impl Future<Output = Result<()>> {
|
pub fn set_mute(&self, muted: bool) -> impl Future<Output = Result<()>> {
|
||||||
let (tx, rx) = futures::channel::oneshot::channel();
|
let (tx, rx) = futures::channel::oneshot::channel();
|
||||||
|
|
||||||
|
@ -599,6 +606,13 @@ impl Drop for LocalTrackPublication {
|
||||||
pub struct RemoteTrackPublication(*const c_void);
|
pub struct RemoteTrackPublication(*const c_void);
|
||||||
|
|
||||||
impl RemoteTrackPublication {
|
impl RemoteTrackPublication {
|
||||||
|
pub fn new(native_track_publication: *const c_void) -> Self {
|
||||||
|
unsafe {
|
||||||
|
CFRetain(native_track_publication);
|
||||||
|
}
|
||||||
|
Self(native_track_publication)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn set_enabled(&self, enabled: bool) -> impl Future<Output = Result<()>> {
|
pub fn set_enabled(&self, enabled: bool) -> impl Future<Output = Result<()>> {
|
||||||
let (tx, rx) = futures::channel::oneshot::channel();
|
let (tx, rx) = futures::channel::oneshot::channel();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue