fix the 440->441 samples issue and pass a noop callback for release#848
fix the 440->441 samples issue and pass a noop callback for release#848xianshijing-lk merged 6 commits intomainfrom
Conversation
📝 WalkthroughWalkthroughThese changes modify audio source queue initialization across Rust and C++ components, adjusting queue size calculation order, introducing explicit zero-initialization of struct members, and adding a no-op callback for fast-path handling when no buffering is needed. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
⏰ 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). (10)
✏️ Tip: You can disable this entire section by setting Comment |
| // Pass null ctx + null callback; C++ ignores them in direct mode | ||
| let data: &[i16] = frame.data.as_ref(); | ||
| // Use a valid no-op callback instead of null for safety | ||
| // In release mode, transmuting null pointers can cause UB |
ac6eb83 to
b092a2d
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@examples/local_video/src/list_devices.rs`:
- Around line 104-111: The formatter error is due to the multi-line expression
building fps_text from fps_list; reformat the block (or run cargo fmt --package
local_video) so the chained iterator/map/collect/join call meets rustfmt style:
locate the fps_text assignment that references fps_list, the iterator .map(|fps|
fps.to_string()).collect::<Vec<String>>().join(", "), and re-run rustfmt (cargo
fmt) or adjust line breaks to match rustfmt expectations.
🧹 Nitpick comments (1)
examples/local_video/Cargo.toml (1)
46-52: Consider removing the top-levelobjc2dependency.
objc2is only needed for macOS, but it's declared twice: once at the top level (line 46) and again under[target.'cfg(target_os = "macos")'.dependencies](line 52). The top-level declaration will pull inobjc2on all platforms unnecessarily.♻️ Suggested fix: Remove redundant top-level objc2
bytemuck = { version = "1.16", features = ["derive"] } -objc2 = { version = "0.6.0", features = ["relax-sign-encoding"] } - nokhwa = { version = "0.10", default-features = false, features = ["output-threaded"] } [target.'cfg(target_os = "macos")'.dependencies] nokhwa = { version = "0.10", default-features = false, features = ["input-avfoundation", "output-threaded"] } objc2 = { version = "0.6.0", features = ["relax-sign-encoding"] }
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (2)
examples/local_video/Cargo.tomlexamples/local_video/src/list_devices.rs
🧰 Additional context used
🪛 GitHub Actions: Rust Formatting
examples/local_video/src/list_devices.rs
[error] 104-108: cargo fmt -- --check failed: formatting difference detected in list_devices.rs; expected single-line join expression (currently multi-line) after refactor. Run 'cargo fmt' to fix formatting.
⏰ 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). (14)
- GitHub Check: Build (aarch64-pc-windows-msvc)
- GitHub Check: Build (armv7-linux-androideabi)
- GitHub Check: Build (aarch64-linux-android)
- GitHub Check: Build (aarch64-unknown-linux-gnu)
- GitHub Check: Build (x86_64-pc-windows-msvc)
- GitHub Check: Build (x86_64-linux-android)
- GitHub Check: Build (aarch64-apple-ios)
- GitHub Check: Build (x86_64-unknown-linux-gnu)
- GitHub Check: Build (aarch64-apple-ios-sim)
- GitHub Check: Build (x86_64-apple-darwin)
- GitHub Check: Build (aarch64-apple-darwin)
- GitHub Check: Test (x86_64-apple-darwin)
- GitHub Check: Test (x86_64-unknown-linux-gnu)
- GitHub Check: Test (x86_64-pc-windows-msvc)
🔇 Additional comments (4)
examples/local_video/src/list_devices.rs (2)
30-43: LGTM! Good portability improvement.The refactoring to use only Nokhwa public APIs instead of platform-specific bindings like
nokhwa_bindings_macosis a solid approach for cross-platform support. The defensive.clone()on the camera index is appropriate.
48-67: LGTM! FourCC enumeration with fallback is well-structured.The logic correctly tries FourCC-based queries first and falls back to generic camera formats when unavailable. Sorting and deduping the FPS lists ensures consistent output.
examples/local_video/Cargo.toml (2)
7-8: LGTM! Feature gate for desktop binaries.The empty
desktopfeature serves as a clean opt-in gate for the desktop-specific binaries. This is a reasonable pattern to prevent accidental compilation on unsupported platforms.
48-58: LGTM! Per-target nokhwa configuration is well-structured.The pattern of declaring a base
nokhwadependency withoutput-threadedand then overriding with platform-specific input features (input-avfoundation,input-v4l,input-msmf) is correct. Cargo merges features from both declarations, ensuring each platform gets the appropriate input backend.
✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.
b092a2d to
a3cd2be
Compare
this PR does:
3
Summary by CodeRabbit
Bug Fixes
✏️ Tip: You can customize this high-level summary in your review settings.