summaryrefslogtreecommitdiff
path: root/model/src
diff options
context:
space:
mode:
authorMatej Drobnič <services+github@matejdro.com>2023-12-29 17:15:21 +0100
committerGitHub <noreply@github.com>2023-12-29 17:15:21 +0100
commitf476086114a56d214558f37b066849150a141390 (patch)
treeb1b19c004915e7a953e2b416d9cd27dd5efd607e /model/src
parent58081fe5bf7d9ad28f089cf10b2c17bfcfc8bbc7 (diff)
downloadAntennaPod-f476086114a56d214558f37b066849150a141390.zip
Check if volume boost effect is supported on the device (#6808)
Diffstat (limited to 'model/src')
-rw-r--r--model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java b/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java
index e71c5ad36..a9b1089f2 100644
--- a/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java
+++ b/model/src/main/java/de/danoeh/antennapod/model/feed/VolumeAdaptionSetting.java
@@ -1,5 +1,10 @@
package de.danoeh.antennapod.model.feed;
+import android.media.audiofx.AudioEffect;
+
+import androidx.annotation.Nullable;
+import androidx.annotation.VisibleForTesting;
+
public enum VolumeAdaptionSetting {
OFF(0, 1.0f),
LIGHT_REDUCTION(1, 0.5f),
@@ -32,4 +37,29 @@ public enum VolumeAdaptionSetting {
public float getAdaptionFactor() {
return adaptionFactor;
}
+
+ @Nullable
+ private static Boolean boostSupported = null;
+
+ public static boolean isBoostSupported() {
+ if (boostSupported != null) {
+ return boostSupported;
+ }
+ final AudioEffect.Descriptor[] audioEffects = AudioEffect.queryEffects();
+ if (audioEffects != null) {
+ for (AudioEffect.Descriptor effect : audioEffects) {
+ if (effect.type.equals(AudioEffect.EFFECT_TYPE_LOUDNESS_ENHANCER)) {
+ boostSupported = true;
+ return boostSupported;
+ }
+ }
+ }
+ boostSupported = false;
+ return boostSupported;
+ }
+
+ @VisibleForTesting
+ public static void setBoostSupported(@Nullable Boolean boostSupported) {
+ VolumeAdaptionSetting.boostSupported = boostSupported;
+ }
}