feat(equalizer): stabilize audio effects and improve state persistence#1073
feat(equalizer): stabilize audio effects and improve state persistence#1073theovilardo merged 1 commit intomasterfrom
Conversation
- **Core Audio**:
- Implement `onAudioSessionIdChanged` in `DualPlayerEngine` to track and update the active audio session ID.
- Standardize the number of equalizer bands to 10 across the repository and UI.
- Clamp `LoudnessEnhancer` gain to a stable range of 0–1000 mB (10dB) to ensure cross-device consistency.
- **State Management**:
- Add a synchronous flush of equalizer and audio effect settings in `EqualizerViewModel.onCleared()` to prevent data loss from debounced updates when the screen is dismissed.
- Improve data normalization in `UserPreferencesRepository` for equalizer bands and loudness strength.
- **Equalizer Engine**:
- Refactor `EqualizerManager` to better synchronize effect states (Bass Boost, Virtualizer, Loudness) when re-attaching to a new audio session.
- Ensure target gain is applied before enabling `LoudnessEnhancer` to prevent audio spikes.
- **UI**:
- Update `EqualizerScreen` slider ranges to match the new 1000 mB limit for Loudness.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 751dca9d53
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| kotlinx.coroutines.runBlocking { | ||
| val latest = _uiState.value |
There was a problem hiding this comment.
Move onCleared flush off the main thread
onCleared() runs on the main thread, and this new runBlocking path performs a sequence of DataStore writes synchronously before returning. On slower storage or when DataStore is contended, dismissing the equalizer screen can block the UI thread long enough to cause visible jank or ANR-risk behavior; this flush should be moved off-main (or batched into one write) instead of blocking lifecycle teardown.
Useful? React with 👍 / 👎.
Core Audio:
onAudioSessionIdChangedinDualPlayerEngineto track and update the active audio session ID.LoudnessEnhancergain to a stable range of 0–1000 mB (10dB) to ensure cross-device consistency.State Management:
EqualizerViewModel.onCleared()to prevent data loss from debounced updates when the screen is dismissed.UserPreferencesRepositoryfor equalizer bands and loudness strength.Equalizer Engine:
EqualizerManagerto better synchronize effect states (Bass Boost, Virtualizer, Loudness) when re-attaching to a new audio session.LoudnessEnhancerto prevent audio spikes.UI:
EqualizerScreenslider ranges to match the new 1000 mB limit for Loudness.