Skip to content

Fix audio notification crash and missing file types in settings#1

Open
kaokao221 wants to merge 2 commits intomasterfrom
fix-audio-crash-and-settings-15160178287493207890
Open

Fix audio notification crash and missing file types in settings#1
kaokao221 wants to merge 2 commits intomasterfrom
fix-audio-crash-and-settings-15160178287493207890

Conversation

@kaokao221
Copy link
Member

  • Wrapped _sharedAudioPlaybackDevice.Rent() in AudioService.cs with a try-catch block to handle ObjectDisposedException, preventing crashes during rapid re-initialization or concurrent access.
  • Populated AudioFileTypes in NotificationSettingsPage.axaml.cs with common audio extensions (*.wav, *.mp3, *.ogg, *.flac, *.m4a, *.wma, *.aac) and FilePickerFileTypes.All to allow users to select custom sound files.

PR created automatically by Jules for task 15160178287493207890 started by @kaokao221

This change addresses a critical bug where the application would crash when attempting to play a notification sound due to a race condition in `AudioService.cs` when renting a shared `AudioPlaybackDevice`. It adds a `try-catch` block for `ObjectDisposedException` to safely handle disposed devices and re-initialize them.

Additionally, it fixes an issue where users could not select custom notification sound files because the `AudioFileTypes` list in `NotificationSettingsPage.axaml.cs` was empty. Common audio file extensions and an "All files" option have been added.

Fixes ClassIsland#1485

Co-authored-by: kaokao221 <88539021+kaokao221@users.noreply.github.com>
@google-labs-jules
Copy link

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

This commit addresses a critical application crash (Access Violation) caused by rapid initialization and disposal of the audio device (miniaudio backend) when playing notification sounds.

Changes:
- Implemented a debounce mechanism in `AudioService.cs` using `System.Threading.Timer` to keep the shared `AudioPlaybackDevice` alive for 5 seconds after the last use. This prevents rapid re-initialization cycles that were triggering the native crash.
- Added a `try-catch` block for `ObjectDisposedException` when renting the audio device as an additional safety measure.
- Populated `AudioFileTypes` in `NotificationSettingsPage.axaml.cs` with common audio file extensions (*.wav, *.mp3, *.ogg, *.flac, *.m4a, *.wma, *.aac) and `FilePickerFileTypes.All` to allow users to select custom sound files, fixing an issue where the file picker filter was empty.

Fixes ClassIsland#1485

Co-authored-by: kaokao221 <88539021+kaokao221@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant