Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
greptile stuff boiii
Richie McIlroy0eab8aa0cc5f
diff --git a/apps/desktop/src-tauri/src/camera.rs b/apps/desktop/src-tauri/src/camera.rsindex 4d5789a3d..4e577b5ed 100644--- a/apps/desktop/src-tauri/src/camera.rs+++ b/apps/desktop/src-tauri/src/camera.rs@@ -3,6 +3,8 @@ use cap_recording::{FFmpegVideoFrame,feeds::{self, camera::CameraFeed},};+#[cfg(target_os = "macos")]+use cap_utils::macos_qos::{MacOsQosClass, set_current_thread_qos};use ffmpeg::{format::{self, Pixel},frame,@@ -32,14 +34,6 @@ static TOOLBAR_HEIGHT: f32 = 56.0;static GPU_SURFACE_SCALE: u32 = 2;-#[cfg(target_os = "macos")]-const QOS_CLASS_USER_INTERACTIVE: u32 = 0x21;--#[cfg(target_os = "macos")]-unsafe extern "C" {- fn pthread_set_qos_class_self_np(qos_class: u32, relative_priority: i32) -> i32;-}-pub const MIN_CAMERA_SIZE: f32 = 150.0;pub const MAX_CAMERA_SIZE: f32 = 600.0;pub const DEFAULT_CAMERA_SIZE: f32 = 230.0;@@ -269,8 +263,11 @@ impl CameraPreviewManager {thread::spawn(move || {#[cfg(target_os = "macos")]- unsafe {- pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);+ {+ let result = set_current_thread_qos(MacOsQosClass::UserInteractive);+ if result != 0 {+ warn!(result, "pthread_set_qos_class_self_np failed");+ }}LocalSet::new().block_on(&rt,diff --git a/apps/desktop/src-tauri/src/lib.rs b/apps/desktop/src-tauri/src/lib.rsindex 914cc8ecb..bde211807 100644--- a/apps/desktop/src-tauri/src/lib.rs+++ b/apps/desktop/src-tauri/src/lib.rs@@ -760,14 +760,20 @@ async fn set_camera_input(if native_preview_active {#[allow(deprecated)]- let _ = camera_feed+ let result = camera_feed.ask(feeds::camera::RemoveSender(camera_ws_sender)).await;+ if let Err(err) = result {+ warn!(error = %err, "Failed to remove camera sender");+ }} else {#[allow(deprecated)]- let _ = camera_feed+ let result = camera_feed.ask(feeds::camera::AddSender(camera_ws_sender)).await;+ if let Err(err) = result {+ warn!(error = %err, "Failed to add camera sender");+ }}let mut attempts = 0;@@ -3427,18 +3433,15 @@ async fn refresh_camera_feed(state: MutableState<'_, App>) -> Result<(), String>let camera_ws_sender = app.camera_ws_sender.clone();let camera_preview_sender = app.camera_preview.sender();- let native_preview_active = app.camera_preview.is_initialized();drop(app);if let Some(sender) = camera_preview_sender {- if native_preview_active {- #[allow(deprecated)]- camera_feed- .ask(feeds::camera::RemoveSender(camera_ws_sender))- .await- .map_err(|err| format!("error removing camera ws sender: {err}"))?;- }+ #[allow(deprecated)]+ camera_feed+ .ask(feeds::camera::RemoveSender(camera_ws_sender))+ .await+ .map_err(|err| format!("error removing camera ws sender: {err}"))?;camera_feed.ask(feeds::camera::AddSender(sender))diff --git a/apps/desktop/src-tauri/src/recording.rs b/apps/desktop/src-tauri/src/recording.rsindex ac2f07f70..d2077f5e0 100644--- a/apps/desktop/src-tauri/src/recording.rs+++ b/apps/desktop/src-tauri/src/recording.rs@@ -1561,6 +1561,7 @@ wherepub async fn stop_recording(app: AppHandle, state: MutableState<'_, App>) -> Result<(), String> {let mut state = state.write().await;let Some(current_recording) = state.clear_current_recording() else {+ warn!("Stop recording requested without active recording");return Ok(());};diff --git a/apps/media-server/src/routes/video.ts b/apps/media-server/src/routes/video.tsindex 6bf5f2616..c2dbe4267 100644--- a/apps/media-server/src/routes/video.ts+++ b/apps/media-server/src/routes/video.ts@@ -1149,7 +1149,11 @@ async function downloadSegmentsBatchTracked(function sendCurrentJobWebhook(jobId: string): void {const job = getJob(jobId);- if (job) sendWebhook(job);+ if (!job) {+ console.warn(`[mux-segments] Job ${jobId} not found for webhook`);+ return;+ }+ sendWebhook(job);}async function muxSegmentsAsync(diff --git a/crates/recording/src/output_pipeline/macos.rs b/crates/recording/src/output_pipeline/macos.rsindex 3876e3a70..9eeb81500 100644--- a/crates/recording/src/output_pipeline/macos.rs+++ b/crates/recording/src/output_pipeline/macos.rs@@ -9,6 +9,7 @@ use anyhow::anyhow;use cap_enc_avfoundation::QueueFrameError;use cap_media_info::{AudioInfo, VideoInfo};use cap_timestamp::Timestamp;+use cap_utils::macos_qos::{MacOsQosClass, set_current_thread_qos};use cidre::arc;use std::{path::PathBuf,@@ -31,17 +32,11 @@ const DISK_SPACE_MIN_START_MB: u64 = 500;const DISK_SPACE_CRITICAL_MB: u64 = 200;const DISK_SPACE_CHECK_INTERVAL: Duration = Duration::from_secs(10);-#[cfg(target_os = "macos")]-const QOS_CLASS_USER_INITIATED: u32 = 0x19;--#[cfg(target_os = "macos")]-unsafe extern "C" {- fn pthread_set_qos_class_self_np(qos_class: u32, relative_priority: i32) -> i32;-}--#[cfg(target_os = "macos")]fn boost_encoder_thread_qos() {- unsafe { pthread_set_qos_class_self_np(QOS_CLASS_USER_INITIATED, 0) };+ let result = set_current_thread_qos(MacOsQosClass::UserInitiated);+ if result != 0 {+ warn!(result, "pthread_set_qos_class_self_np failed");+ }}fn get_available_disk_space_mb(path: &std::path::Path) -> Option<u64> {diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rsindex b99740fe3..c5210822b 100644--- a/crates/utils/src/lib.rs+++ b/crates/utils/src/lib.rs@@ -10,6 +10,8 @@ use aho_corasick::{AhoCorasickBuilder, MatchKind};use tracing::Instrument;pub mod disk_space;+#[cfg(target_os = "macos")]+pub mod macos_qos;/// Wrapper around tokio::spawn that inherits the current tracing subscriber and span.pub fn spawn_actor<F>(future: F) -> tokio::task::JoinHandle<F::Output>diff --git a/crates/utils/src/macos_qos.rs b/crates/utils/src/macos_qos.rsnew file mode 100644index 000000000..c2a5fab66--- /dev/null+++ b/crates/utils/src/macos_qos.rs@@ -0,0 +1,18 @@+#[derive(Clone, Copy, Debug)]+pub enum MacOsQosClass {+ UserInteractive,+ UserInitiated,+}++impl MacOsQosClass {+ fn as_raw(self) -> libc::qos_class_t {+ match self {+ Self::UserInteractive => libc::QOS_CLASS_USER_INTERACTIVE,+ Self::UserInitiated => libc::QOS_CLASS_USER_INITIATED,+ }+ }+}++pub fn set_current_thread_qos(qos_class: MacOsQosClass) -> i32 {+ unsafe { libc::pthread_set_qos_class_self_np(qos_class.as_raw(), 0) }+}diff --git a/packages/env/build.ts b/packages/env/build.tsindex f52ddc6b3..db1d04570 100644--- a/packages/env/build.ts+++ b/packages/env/build.ts@@ -28,10 +28,9 @@ const create = () =>},});-// Environment variables that are needed in the build process, and may be incorrect on the client.-// Some are only provided by `NEXT_PUBLIC`, but others can be provdied at runtimeexport const buildEnv = new Proxy({} as typeof _env, {get(_, key) {+ if (typeof key !== "string") return undefined;if (!_env) _env = create();return _env[key as keyof typeof _env];