From 627d8ee83f0f99ec7ca8b6c08095d0fa17577e16 Mon Sep 17 00:00:00 2001 From: Gregory Simon Date: Thu, 1 Aug 2024 13:06:49 -0700 Subject: [PATCH] Workaround of AudioEffect crashing on Lenovo tablets (#7309) Android 14 on Lenovo tablets does not intialize this AudioEffect. Catch this exception and continue playback. --- .../service/internal/ExoPlayerWrapper.java | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java index 43f1f31ab..8a5c60b5d 100644 --- a/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java +++ b/playback/service/src/main/java/de/danoeh/antennapod/playback/service/internal/ExoPlayerWrapper.java @@ -274,14 +274,22 @@ public class ExoPlayerWrapper { public void setVolume(float v, float v1) { if (v > 1) { exoPlayer.setVolume(1f); - if (loudnessEnhancer != null) { - loudnessEnhancer.setEnabled(true); - loudnessEnhancer.setTargetGain((int) (1000 * (v - 1))); + try { + if (loudnessEnhancer != null) { + loudnessEnhancer.setEnabled(true); + loudnessEnhancer.setTargetGain((int) (1000 * (v - 1))); + } + } catch (Exception e) { + Log.d(TAG, e.toString()); } } else { exoPlayer.setVolume(v); - if (loudnessEnhancer != null) { - loudnessEnhancer.setEnabled(false); + try { + if (loudnessEnhancer != null) { + loudnessEnhancer.setEnabled(false); + } + } catch (Exception e) { + Log.d(TAG, e.toString()); } } }