Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

Merge remote-tracking branch 'origin/main' into perf/gpui-hotkey-mic-check

Aatman Jain (AJ)7c09181dc683
diff --cc apps/desktop-gpui/src/hotkeys.rs
index 1a01f750a,4154ced24..e3062a61d
--- a/apps/desktop-gpui/src/hotkeys.rs
+++ b/apps/desktop-gpui/src/hotkeys.rs
@@@ -706,24 -796,10 +796,22 @@@ fn dispatch(action: HotkeyAction, cx: &
}
}
+fn microphone_available(name: &str) -> bool {
+ use cap_recording::feeds::microphone::MicrophoneFeed;
+
+ if cfg!(target_os = "macos") {
+ MicrophoneFeed::list_names()
+ .iter()
+ .any(|device| device == name)
+ } else {
+ MicrophoneFeed::list().contains_key(name)
+ }
+}
+
/// `start_recording_from_hotkey` + the `RequestStartRecording` listener
/// (`hotkeys.rs:158-177`, `lib.rs:5529-5551` over there): confirm a start
- /// without a working microphone, then record the store's
- /// `recording_settings.target` -- whatever either app recorded last -- with
- /// the primary display as the fallback. Mic/camera come off the main window's
- /// current selections through its ordinary start path.
+ /// without a working microphone, then record. Mic/camera come off the main
+ /// window's current selections through its ordinary start path.
///
/// The mode is set through [`app_windows::set_recording_mode`] first, so the
/// pill, the tray tick and the shared store all follow the hotkey; the Tauri
@@@ -754,12 -825,26 +837,27 @@@ fn start_from_hotkey(mode: Mode, cx: &m
});
cx.spawn(async move |cx| {
- // The availability probe the Tauri confirm runs, on the background
- // executor because it enumerates CoreAudio devices. On macOS that is a
+ // Window and display lookups enumerate the system, so they run off
+ // the main thread along with the microphone probe below.
+ let target = cx
+ .background_executor()
+ .spawn(async move {
+ pick_hotkey_target(armed, stored, target_is_live, || {
+ scap_targets::Display::get_containing_cursor()
+ .unwrap_or_else(scap_targets::Display::primary)
+ .id()
+ })
+ })
+ .await;
+ if !confirm {
+ cx.update(|cx| start_now(main, mode, target, cx));
+ return;
+ }
- // `MicrophoneFeed::list().contains_key(name)` -- the exact
- // availability probe the Tauri confirm runs (`hotkeys.rs:126-135`
- // over there). No selection means no microphone, which needs no
- // enumeration to know.
++ // The availability probe the Tauri confirm runs. On macOS that is a
+ // name match (`microphone_available_for_confirmation` over there):
+ // `MicrophoneFeed::list()` reads every input device's configuration,
+ // which held the hotkey start for over 100 ms. No selection means no
+ // microphone, which needs no enumeration to know.
let available = match mic_name {
Some(name) => {
cx.background_executor()