-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix: Various fixes to sound card initialization messages etc. #459
Conversation
- Add robust audio device validation with hardware device filtering - Implement device testing mechanism to ensure capture device functionality - Improve device selection process with more detailed error handling - Add platform-specific device detection logic for Linux, Windows, and macOS - Prevent selection of null/discard audio devices
- Remove disabled state for audio source selection - Update tooltip to clarify sound card capture option - Simplify device option selection logic
… device matching - Add restart requirement notice for audio source changes - Implement more robust device selection with case-insensitive matching - Update option selection to better reflect current audio capture source
…io capture - Update WaitGroup management in audio capture and analysis routines - Simplify goroutine startup and synchronization patterns - Add more explicit logging for audio capture and FFmpeg process management - Remove redundant WaitGroup increments in goroutine calls
WalkthroughThis update refactors concurrency management and improves audio processing. The WaitGroup handling in clip cleanup and analysis buffer monitoring is adjusted so that goroutines self-manage their completion. The audio capture module introduces new functions for hardware device validation and selection while refining the FFmpeg logging and process management. The user interface for audio settings is updated with clearer labels and tooltips for sound card capture options. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as AudioSettings UI
participant Capture as CaptureAudio
participant Validator as ValidateAudioDevice
participant Hardware as getHardwareDevices/TestCaptureDevice
participant FFmpeg as FFmpegProcess
UI->>Capture: Select audio source
Capture->>Validator: Validate audio device
Validator->>Hardware: Retrieve hardware devices
Hardware-->>Validator: Return hardware list
Validator->>Capture: Return validated device
Capture->>FFmpeg: Start audio capture process
FFmpeg-->>Capture: Log process start and stop
sequenceDiagram
participant Monitor as startClipCleanupMonitor
participant Cleanup as clipCleanupMonitor
participant WG as WaitGroup
Monitor->>WG: (wg.Add) Begin goroutine
Monitor->>Cleanup: Start cleanup monitor
Cleanup->>WG: defer wg.Done() on completion
WG-->>Monitor: Confirm goroutine completion
Possibly related PRs
Poem
✨ Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 0
🧹 Nitpick comments (4)
internal/myaudio/capture.go (4)
348-357
: Hardware device identification approach.The OS-specific logic is straightforward. However, you might consider edge cases for advanced virtual devices or special device naming conventions. Otherwise, this is clear and maintainable for typical device enumeration.
374-399
: Testing capture device startup.The function thoroughly tests if the device can be initialized, started, and stopped. It would be helpful to log or return the underlying error for easier troubleshooting.
+ log.Printf("ℹ️ Attempting to initialize and start capture device: %s", info.Name()) device, err := malgo.InitDevice(ctx.Context, deviceConfig, malgo.DeviceCallbacks{}) if err != nil { return false } ...
401-459
: Comprehensive audio device validation.Your cross-platform backend selection and device filtering provide robust checks. Consider logging the name of the successfully validated device to assist with debugging or user feedback.
628-628
: Quit signal debug log.This debug log clarifies the quit signal handling, which can be invaluable when diagnosing shutdown issues. Just ensure it doesn’t overly clutter production logs.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
internal/analysis/realtime.go
(3 hunks)internal/myaudio/analysis_buffer.go
(1 hunks)internal/myaudio/capture.go
(8 hunks)internal/myaudio/ffmpeg_input.go
(3 hunks)views/settings/audioSettings.html
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: unit-tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
🔇 Additional comments (16)
internal/myaudio/capture.go (7)
51-52
: Ensure callers handle empty slice returns gracefully.Returning an empty slice instead of nil is a good practice to avoid nil checks, but please confirm that all consumers of this function properly handle an empty list scenario.
57-57
: Consistent return strategy on error.Returning both the slice (even if empty) and an error is consistent with the pattern established above. This strategy helps maintain safer downstream usage.
70-70
: Aligned error handling.Similar to line 57, this ensures a consistent behavior when device enumeration fails, reducing the possibility of unexpected nil slices.
75-79
: Logical exclusion of discard/null device.Skipping the “Discard all samples” device avoids unintended usage of a null sink, which can prevent confusion and unintended silent captures.
323-330
: Early exit on invalid audio device.Validating and exiting early when the device is invalid prevents further processing complexities. This is a clean approach for fail-fast error handling.
359-372
: Filtering hardware devices.The filtering logic is well-structured, ensuring you only retain valid hardware devices. The overall approach is simple and effective.
543-546
: Proper WaitGroup usage for goroutine.Ensuring
wg.Add(1)
before launching the goroutine and deferringwg.Done()
fosters correct concurrency management and prevents race conditions.internal/myaudio/analysis_buffer.go (1)
282-285
: Improved goroutine tracking.Adding
wg.Add(1)
before the deferredwg.Done()
ensures the WaitGroup accurately tracks this monitor’s lifespan, preventing premature termination.internal/analysis/realtime.go (2)
206-210
: Isolated goroutine lifecycle for clip cleanup.Wrapping
clipCleanupMonitor
in its own goroutine withdefer wg.Done()
streamlines synchronization. This separation enhances clarity and avoids cluttering the function signature.
266-266
: Parameter removal for direct lifecycle management.Removing the WaitGroup parameter from
clipCleanupMonitor
centralizes concurrency handling in the caller, simplifying function usage.internal/myaudio/ffmpeg_input.go (3)
183-183
: LGTM! Clear process termination message.The added log message clearly indicates when an FFmpeg process stops normally, improving visibility of process lifecycle.
368-368
: LGTM! Enhanced FFmpeg startup logging.The changes improve FFmpeg process startup visibility by:
- Using consistent log format with emoji for command start.
- Adding a success confirmation message.
Also applies to: 374-375
309-309
: LGTM! Simplified audio level calculation.Removed the sourceName parameter from calculateAudioLevel call, simplifying the function interface.
views/settings/audioSettings.html (3)
126-126
: LGTM! Clear restart requirement.Added clear indication that audio source changes require application restart, improving user experience.
136-136
: LGTM! Improved audio source selection.The changes enhance the audio source selection by:
- Adding a "No sound card capture" option for deployments without sound cards.
- Improving the selection logic to handle device names more robustly.
Also applies to: 139-141
149-149
: LGTM! Updated tooltip text.Updated tooltip text to reflect the new "No sound card capture" option, providing clear guidance to users.
This PR contains fixes for application startup messages related to sound cart initialization, messages for failed sound card initialization are now less dramatic etc.
Also it is now possible to enable both local sound card analysis and RTSP analysis, UI no longer disables sound card selecton menu when RTSP URLs are configured. For deployments without any sound cards UI now has "No sound card capture" selection.