diff --git a/crates/livekit_client/src/lib.rs b/crates/livekit_client/src/lib.rs index 055aa3704e06f25a21c69294343539289d8acb49..be008d8db5108fb087415edb9d2de91bad19ab97 100644 --- a/crates/livekit_client/src/lib.rs +++ b/crates/livekit_client/src/lib.rs @@ -9,45 +9,55 @@ use rodio::DeviceTrait as _; mod record; pub use record::CaptureInput; -#[cfg(not(any( - test, - feature = "test-support", - all(target_os = "windows", target_env = "gnu"), - target_os = "freebsd" -)))] +#[cfg(any( + rust_analyzer, + not(any( + test, + feature = "test-support", + all(target_os = "windows", target_env = "gnu"), + target_os = "freebsd" + )) +))] mod livekit_client; -#[cfg(not(any( - test, - feature = "test-support", - all(target_os = "windows", target_env = "gnu"), - target_os = "freebsd" -)))] +#[cfg(any( + rust_analyzer, + not(any( + test, + feature = "test-support", + all(target_os = "windows", target_env = "gnu"), + target_os = "freebsd" + )) +))] pub use livekit_client::*; -// If you need proper LSP in livekit_client you've got to comment -// - the cfg blocks above -// - the mods: mock_client & test and their conditional blocks -// - the pub use mock_client::* and their conditional blocks - -#[cfg(any( - test, - feature = "test-support", - all(target_os = "windows", target_env = "gnu"), - target_os = "freebsd" +#[cfg(all( + not(rust_analyzer), + any( + test, + feature = "test-support", + all(target_os = "windows", target_env = "gnu"), + target_os = "freebsd" + ) ))] mod mock_client; -#[cfg(any( - test, - feature = "test-support", - all(target_os = "windows", target_env = "gnu"), - target_os = "freebsd" +#[cfg(all( + not(rust_analyzer), + any( + test, + feature = "test-support", + all(target_os = "windows", target_env = "gnu"), + target_os = "freebsd" + ) ))] pub mod test; -#[cfg(any( - test, - feature = "test-support", - all(target_os = "windows", target_env = "gnu"), - target_os = "freebsd" +#[cfg(all( + not(rust_analyzer), + any( + test, + feature = "test-support", + all(target_os = "windows", target_env = "gnu"), + target_os = "freebsd" + ) ))] pub use mock_client::*; diff --git a/crates/livekit_client/src/livekit_client/playback.rs b/crates/livekit_client/src/livekit_client/playback.rs index 31fd13461f6f3e08e7489f28af9eb21d25b15585..2d41fd4eefe2cd9751deb453383c124efb00f6da 100644 --- a/crates/livekit_client/src/livekit_client/playback.rs +++ b/crates/livekit_client/src/livekit_client/playback.rs @@ -551,7 +551,9 @@ impl libwebrtc::native::audio_mixer::AudioMixerSource for AudioMixerSource { pub fn play_remote_video_track( track: &crate::RemoteVideoTrack, + executor: &BackgroundExecutor, ) -> impl Stream + use<> { + let executor = executor.clone(); #[cfg(target_os = "macos")] { let mut pool = None; @@ -563,7 +565,7 @@ pub fn play_remote_video_track( pool = create_buffer_pool(frame.buffer.width(), frame.buffer.height()).log_err(); } let pool = pool.clone(); - async move { + executor.spawn(async move { if frame.buffer.width() < 10 && frame.buffer.height() < 10 { // when the remote stops sharing, we get an 8x8 black image. // In a lil bit, the unpublish will come through and close the view, @@ -572,13 +574,14 @@ pub fn play_remote_video_track( } video_frame_buffer_from_webrtc(pool?, frame.buffer) - } + }) }) } #[cfg(not(target_os = "macos"))] { - NativeVideoStream::new(track.0.rtc_track()) - .filter_map(|frame| async move { video_frame_buffer_from_webrtc(frame.buffer) }) + NativeVideoStream::new(track.0.rtc_track()).filter_map(move |frame| { + executor.spawn(async move { video_frame_buffer_from_webrtc(frame.buffer) }) + }) } } diff --git a/crates/livekit_client/src/mock_client.rs b/crates/livekit_client/src/mock_client.rs index 7d355749c01ac5f048a2f6142ff09b2ab1e0de69..4c19cb4d57695f86b98c299646a376edb64414b7 100644 --- a/crates/livekit_client/src/mock_client.rs +++ b/crates/livekit_client/src/mock_client.rs @@ -33,6 +33,7 @@ impl Into for RemoteVideoFrame { } pub(crate) fn play_remote_video_track( _track: &crate::RemoteVideoTrack, + _: &gpui::BackgroundExecutor, ) -> impl futures::Stream + use<> { futures::stream::pending() } diff --git a/crates/livekit_client/src/remote_video_track_view.rs b/crates/livekit_client/src/remote_video_track_view.rs index 189806f2138e401e62ad46336e95d8468e3b3732..ef41ec94e180d1a2b8c34527d3ff547e0aa583ba 100644 --- a/crates/livekit_client/src/remote_video_track_view.rs +++ b/crates/livekit_client/src/remote_video_track_view.rs @@ -22,7 +22,7 @@ pub enum RemoteVideoTrackViewEvent { impl RemoteVideoTrackView { pub fn new(track: RemoteVideoTrack, window: &mut Window, cx: &mut Context) -> Self { cx.focus_handle(); - let frames = crate::play_remote_video_track(&track); + let frames = crate::play_remote_video_track(&track, cx.background_executor()); #[cfg(not(target_os = "macos"))] {