-
Notifications
You must be signed in to change notification settings - Fork 739
query for continuity camera properly #962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughUpdated AVFoundation camera device type collection to safely handle optional types and add macOS 14+ continuity camera support. Replaced unsafe unwrap with guarded checks for external and continuity_camera, and retained external_unknown for older paths. No public APIs changed. Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant Enumerator as DeviceEnumerator
participant AVF as AVFoundation
App->>Enumerator: enumerate_device_types()
Enumerator->>AVF: query available device types
alt macOS >= 14
AVF-->>Enumerator: optional external()
Note right of Enumerator: If Some, push external
AVF-->>Enumerator: optional continuity_camera()
Note right of Enumerator: If Some, push continuity_camera
else macOS < 14 or not available
Enumerator->>Enumerator: push external_unknown()
end
Enumerator-->>App: device types list
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
crates/camera-avfoundation/src/lib.rs (2)
21-26
: Good move replacing unwrap with guarded availability; add a fallback if both Option lookups fail on 14+This prevents panics and properly probes weakly-linked symbols. To avoid returning no external devices on macOS 14+ if both calls unexpectedly return None (e.g., symbol resolution edge cases), add a local fallback to external_unknown() when neither were added. Also add a brief SAFETY note for future readers.
- if let Some(typ) = unsafe { av::CaptureDeviceType::external() } { - device_types.push(typ); - } - if let Some(typ) = unsafe { av::CaptureDeviceType::continuity_camera() } { - device_types.push(typ); - } + // SAFETY: Calls are gated by macOS 14.0 availability; functions return None if the symbol + // is not present at runtime due to weak-linking. + let mut added_any = false; + if let Some(ty) = unsafe { av::CaptureDeviceType::external() } { + device_types.push(ty); + added_any = true; + } + if let Some(ty) = unsafe { av::CaptureDeviceType::continuity_camera() } { + device_types.push(ty); + added_any = true; + } + if !added_any { + device_types.push(av::CaptureDeviceType::external_unknown()); + }
28-28
: Pre-14 fallback looks rightPushing external_unknown() for macOS < 14 keeps discovery working without relying on newer symbols. Consider a tiny comment to document why this branch doesn’t attempt external()/continuity_camera().
- device_types.push(av::CaptureDeviceType::external_unknown()); + // Pre-14: use the generic external type because newer symbols may not exist. + device_types.push(av::CaptureDeviceType::external_unknown());
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
crates/camera-avfoundation/src/lib.rs
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build Desktop (x86_64-pc-windows-msvc, windows-latest)
- GitHub Check: Build Desktop (aarch64-apple-darwin, macos-latest)
- GitHub Check: Analyze (rust)
Summary by CodeRabbit
New Features
Bug Fixes
Chores