-
-
Notifications
You must be signed in to change notification settings - Fork 43
fix: handle null sound source by clearing audio context #1410
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
base: main
Are you sure you want to change the base?
Conversation
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
Pull Request Overview
This PR fixes an exception that occurs when attempting to play audio without a configured SoundSource. Instead of throwing an exception, the code now clears the audio context and returns early.
Key Changes:
- Replaced exception throwing with a safe early-return pattern when SoundSource is null
- Added context clearing to ensure clean state when no sound source is available
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| var soundSource = GetSoundSource(); | ||
| if (soundSource == null) throw new Exception("Sound source is not available"); | ||
| if (soundSource == null) | ||
| { |
Copilot
AI
Nov 9, 2025
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.
[nitpick] Consider adding a comment explaining why the context is cleared when the sound source is null, as this behavior change from throwing an exception may not be immediately obvious to maintainers.
| { | |
| { | |
| // If there is no sound source, clear the context to ensure no audio is produced. | |
| // This is intentional: previously this may have thrown an exception, but now we | |
| // explicitly clear the context to avoid errors and undefined behavior. |
|
No TODO comments were found. |
Minimum allowed line rate is |
SoundSourceが設定されていない状態で再生すると例外が発生するのを修正
Note
Handle null sound source in
Sound.Composeby clearing theAudioContextand returning instead of throwing an exception.Written by Cursor Bugbot for commit 18fa5dd. This will update automatically on new commits. Configure here.