dolby: Make effect calls exception-safe across audioserver lifecycles - #27
Open
rajdeep-3305 wants to merge 1 commit into
Open
dolby: Make effect calls exception-safe across audioserver lifecycles#27rajdeep-3305 wants to merge 1 commit into
rajdeep-3305 wants to merge 1 commit into
Conversation
- when audioserver crashes or restarts, native AudioEffect handles become uninitialized - catch exceptions in AudioEffect getters/setters, recreate lost effects cleanly in checkEffect(), and prevent crashes in DolbyEffectService callbacks Change-Id: I9e5089f507a1f7e8e4257d180d6684d23cd380ae Signed-off-by: rajdeep-3305 <rajdeepbiswas3305@gmail.com>
There was a problem hiding this comment.
🟡 Changes recommended
A swallowed exception path in DolbyAudioEffect.setIntParam() can cause Java-side enabled state to be updated even when the native parameter write fails, leading to inconsistent effect state.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR hardens Dolby audio effect interactions against audioserver crashes/restarts by making effect accessors and service callbacks more resilient and by attempting to recreate lost AudioEffect handles within the repository.
Changes:
- Wrap
AudioPlaybackCallbackstate-apply logic in atry/catchto prevent service crashes. - Make
DolbyRepository.checkEffect()return a success flag and attempt effect recreation when control is lost or checks throw. - Add exception handling around
DolbyAudioEffectgetters/setters and parameter I/O to avoid crashes from invalid native handles.
File summaries
| File | Description |
|---|---|
| LunarisDolby/src/org/lunaris/dolby/service/DolbyEffectService.kt | Guards playback callback to prevent crashes when applying saved state. |
| LunarisDolby/src/org/lunaris/dolby/data/DolbyRepository.kt | Adds boolean effect-health check with recreation path; wraps restore/apply flows with exception safety. |
| LunarisDolby/src/org/lunaris/dolby/audio/DolbyAudioEffect.kt | Adds exception handling around parameter reads/writes to avoid failures from invalid native effect handles. |
Review details
Suppressed comments (1)
LunarisDolby/src/org/lunaris/dolby/data/DolbyRepository.kt:72
- Same as above: swallowing exceptions from
dolbyEffect.release()during the error-path recreation makes effect lifecycle failures invisible in logs. Logging the exception will help confirm whether the old handle was still valid.
DolbyConstants.dlog(TAG, "Error checking effect: ${e.message}, recreating")
try { dolbyEffect.release() } catch (_: Exception) {}
try {
dolbyEffect = createDolbyEffect()
restoreSavedProfileIfNeeded()
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+53
to
+56
| checkStatus(setParameter(EFFECT_PARAM_CPDP_VALUES, buf)) | ||
| } catch (e: Exception) { | ||
| DolbyConstants.dlog(TAG, "setIntParam($param, $value) failed: ${e.message}") | ||
| } |
| if (!dolbyEffect.hasControl()) { | ||
| DolbyConstants.dlog(TAG, "Lost audio effect control, recreating") | ||
| dolbyEffect.release() | ||
| try { dolbyEffect.release() } catch (_: Exception) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change-Id: I9e5089f507a1f7e8e4257d180d6684d23cd380ae