Catch crash when device does not support LoudnessEnhancer properly (#7390)

This commit is contained in:
ByteHamster 2024-09-08 12:06:20 +02:00 committed by GitHub
parent f32d5ccb30
commit 5ea92f68b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -399,11 +399,15 @@ public class ExoPlayerWrapper {
LoudnessEnhancer newEnhancer = new LoudnessEnhancer(audioStreamId);
LoudnessEnhancer oldEnhancer = this.loudnessEnhancer;
if (oldEnhancer != null) {
newEnhancer.setEnabled(oldEnhancer.getEnabled());
if (oldEnhancer.getEnabled()) {
newEnhancer.setTargetGain((int) oldEnhancer.getTargetGain());
try {
newEnhancer.setEnabled(oldEnhancer.getEnabled());
if (oldEnhancer.getEnabled()) {
newEnhancer.setTargetGain((int) oldEnhancer.getTargetGain());
}
oldEnhancer.release();
} catch (Exception e) {
Log.d(TAG, e.toString());
}
oldEnhancer.release();
}
this.loudnessEnhancer = newEnhancer;