-
Notifications
You must be signed in to change notification settings - Fork 313
Add mic-detection #751
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
Add mic-detection #751
Conversation
""" WalkthroughA new microphone detection subsystem is introduced with platform-specific implementations for macOS and Windows. The Changes
Sequence Diagram(s)sequenceDiagram
participant App
participant Detector
participant MicDetector
participant PlatformDetector (macOS/Windows)
App->>Detector: start()
Detector->>MicDetector: start(callback)
MicDetector->>PlatformDetector: start(callback)
alt macOS
PlatformDetector-->>PlatformDetector: Listen for audio device changes
PlatformDetector->>callback: Notify on mic usage or device change
else Windows
PlatformDetector-->>PlatformDetector: (No-op)
end
Assessment against linked issues
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
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: 5
🧹 Nitpick comments (1)
crates/detect/src/mic/windows.rs (1)
1-7
: Document the stub implementation.The Windows implementation provides stub methods which is acceptable for initial development. However, consider adding documentation to clarify this is a placeholder.
Apply this diff to improve documentation:
+/// Windows stub implementation for microphone detection. +/// TODO: Implement actual microphone detection for Windows platform. #[derive(Default)] pub struct Detector {} impl crate::Observer for Detector { + /// Stub implementation - no microphone detection on Windows yet. fn start(&mut self, f: crate::DetectCallback) {} + /// Stub implementation - no cleanup needed. fn stop(&mut self) {} }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
crates/detect/src/lib.rs
(2 hunks)crates/detect/src/mic/macos.rs
(1 hunks)crates/detect/src/mic/mod.rs
(1 hunks)crates/detect/src/mic/windows.rs
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
crates/detect/src/mic/windows.rs (3)
crates/detect/src/mic/mod.rs (2)
start
(17-19)stop
(20-22)crates/detect/src/lib.rs (4)
start
(22-22)start
(65-68)stop
(23-23)stop
(70-73)crates/detect/src/mic/macos.rs (2)
start
(13-52)stop
(53-53)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: ci
🔇 Additional comments (2)
crates/detect/src/lib.rs (1)
3-3
: LGTM! Module addition is correctly structured.The mic module is properly added and re-exported following the same pattern as existing modules.
Also applies to: 8-8
crates/detect/src/mic/mod.rs (1)
1-23
: Excellent platform abstraction design!The conditional compilation approach cleanly separates platform-specific implementations while providing a unified interface through
MicDetector
. The delegation pattern is well-implemented.
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: 2
🧹 Nitpick comments (1)
crates/detect/src/mic/macos.rs (1)
55-63
: Only “start-using” events are emitted – no symmetrical “stop-using” notification
device_listener
calls the callback only whenis_running != 0
, i.e. when the mic starts being used.
When the value toggles back to0
nothing is sent, so consumers cannot know that microphone usage ended.Consider emitting a second event (or passing a boolean) so downstream logic can react symmetrically:
let state = is_running != 0; if let Ok(guard) = callback.lock() { (*guard)(format!("microphone_in_use:{state}")); }This will make the API far more useful.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
crates/detect/src/lib.rs
(3 hunks)crates/detect/src/mic/macos.rs
(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- crates/detect/src/lib.rs
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: ci
🔇 Additional comments (1)
crates/detect/src/mic/macos.rs (1)
214-216
: Verify thatBackgroundTask::stop()
actually terminates the spawned thread
stop()
merely delegates tobackground.stop()
, but the thread created instart()
is detached (std::thread::spawn
) and holds native Core Audio resources.
Please ensureBackgroundTask
:
- signals the thread to exit,
- joins it, and
- guarantees listeners are removed exactly once.
If that is not the case, we risk leaking a thread or removing listeners twice (use-after-free).
Resolves #675
Summary by CodeRabbit