-
Notifications
You must be signed in to change notification settings - Fork 3
fix: audio interruption on android #51
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
Conversation
Co-authored-by: Sahil Kumar <xdsahil@gmail.com>
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 pull request fixes audio interruption handling on Android by consolidating audio focus management through AudioSwitch and adding permission checks to prevent crashes related to telephony state monitoring.
- Deprecated unused audio attribute parameters (
androidAudioAttributesUsageTypeandandroidAudioAttributesContentType) that are no longer needed with the new AudioSwitch-based approach - Implemented a forwarding listener pattern to allow dynamic audio focus listener updates without recreating AudioSwitch
- Added comprehensive permission checking and error handling for telephony state monitoring to prevent SecurityExceptions
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/src/native/factory_impl.dart | Deprecated audio attribute parameters and removed their usage in method call arguments |
| lib/src/helper.dart | Added regainAndroidAudioFocus() helper method for manually requesting audio focus |
| android/src/main/java/io/getstream/webrtc/flutter/audio/AudioSwitchManager.java | Introduced ForwardingAudioFocusChangeListener pattern and setAudioFocusChangeListener() method for dynamic listener management |
| android/src/main/java/io/getstream/webrtc/flutter/audio/AudioFocusManager.java | Refactored to use AudioSwitch for focus changes, added permission checking, improved thread safety with interruption state tracking, and added try-catch for telephony registration |
| android/src/main/java/io/getstream/webrtc/flutter/MethodCallHandlerImpl.java | Removed deprecated audio attribute parameter handling, added regainAndroidAudioFocus case, and cleanup in dispose method |
| CHANGELOG.md | Documented the audio focus improvements and new API |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Use AudioSwitch for focus change listener to have a single source of focus truth.
Check phone state permissions to avoid crashes