fix: handle missing audio output config - #453
Conversation
📝 WalkthroughWalkthroughFixes a startup crash when no audio output device is available. ChangesAudio Output Error Handling and UI Display
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/hooks/src/use_player_controller.rs`:
- Around line 1388-1389: The server and YouTube playback error handling in the
async branch lacks the same error propagation that was fixed for local playback.
In the error handling block around line 805 where errors from
player.write().play or player.write().crossfade_to are caught in the if let
Err(e) = result pattern, the code currently only logs and returns without
setting self.playback_error. Apply the same error visibility fix used for local
playback by setting self.playback_error with the error details in the server/YT
error branch, using the same format:
self.playback_error.set(Some(format!("Playback failed:\n{e}"))) to ensure server
and YouTube playback failures are user-visible.
In `@crates/player/src/player.rs`:
- Around line 256-272: The Player constructor in the new method currently
handles missing device and missing output config gracefully by returning
Self::unavailable, but downstream operations like build_output_stream and play
calls are not protected with error handling, causing panics on audio backend
failures. Wrap the stream building and playback starting logic in error handling
to catch any failures that occur after device and config initialization, and
return Self::unavailable with an appropriate error message for these cases as
well, ensuring all initialization failures are treated as recoverable rather
than causing panics.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b8a8a4e4-f680-4f1d-b329-49213cf85d8f
📒 Files selected for processing (3)
crates/hooks/src/use_player_controller.rscrates/kopuz/src/main.rscrates/player/src/player.rs
Summary
Testing
rustfmt --check --edition 2024 crates/player/src/player.rs crates/hooks/src/use_player_controller.rs crates/kopuz/src/main.rsgit diff --checkcargo checkFixes #447
Summary by CodeRabbit