Skip to content

dolby: Make effect calls exception-safe across audioserver lifecycles - #27

Open
rajdeep-3305 wants to merge 1 commit into
Pong-Development:16from
rajdeep-3305:16
Open

dolby: Make effect calls exception-safe across audioserver lifecycles#27
rajdeep-3305 wants to merge 1 commit into
Pong-Development:16from
rajdeep-3305:16

Conversation

@rajdeep-3305

Copy link
Copy Markdown
  • 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

- 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>
Copilot AI lite review requested due to automatic review settings September 2, 2026 04:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 AudioPlaybackCallback state-apply logic in a try/catch to 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 DolbyAudioEffect getters/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) {}
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.

2 participants