summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoman Birg <roman@cyngn.com>2016-08-12 11:10:05 -0700
committerRoman Birg <roman@cyngn.com>2016-08-23 18:01:57 +0000
commitb01d7927cca7387b17d6b338f0e9a0a286e32c69 (patch)
tree76a04d15c191ac8829ee2fb882f386bbf5464d9c
parentc5812df023693994ac3628c0fdb48e64178d24ee (diff)
downloadandroid_packages_apps_AudioFX-b01d7927cca7387b17d6b338f0e9a0a286e32c69.tar.gz
android_packages_apps_AudioFX-b01d7927cca7387b17d6b338f0e9a0a286e32c69.tar.bz2
android_packages_apps_AudioFX-b01d7927cca7387b17d6b338f0e9a0a286e32c69.zip
ModioFX: split backend implementations
Change-Id: Ib6f345000b25a17a5c7520ea47355f1d96936522 Signed-off-by: Roman Birg <roman@cyngn.com>
-rw-r--r--.gitignore1
-rw-r--r--Android.mk9
-rw-r--r--src/com/cyngn/audiofx/Constants.java6
-rw-r--r--src/com/cyngn/audiofx/backends/AndroidEffects.java3
-rw-r--r--src/com/cyngn/audiofx/backends/EffectsFactory.java78
-rw-r--r--src/com/cyngn/audiofx/backends/IEffectFactory.java16
-rw-r--r--src/com/cyngn/audiofx/service/DevicePreferenceManager.java8
-rw-r--r--src/com/cyngn/audiofx/service/SessionManager.java3
-rw-r--r--src_effects/com/cyngn/audiofx/backends/EffectsFactory.java35
9 files changed, 72 insertions, 87 deletions
diff --git a/.gitignore b/.gitignore
index e43b0f9..259e997 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
.DS_Store
+src_effects_priv
diff --git a/Android.mk b/Android.mk
index 3504844..dbe43f2 100644
--- a/Android.mk
+++ b/Android.mk
@@ -8,6 +8,13 @@ LOCAL_OVERRIDES_PACKAGES := DSPManager AudioFX
LOCAL_SRC_FILES := $(call all-java-files-under, src)
+ifeq ($(wildcard $(LOCAL_PATH)/src_effects_priv),)
+LOCAL_SRC_FILES += $(call all-java-files-under, src_effects)
+else
+$(warning *** including private implementations of effects ***)
+LOCAL_SRC_FILES += $(call all-java-files-under, src_effects_priv)
+endif
+
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4 org.cyanogenmod.platform.sdk
LOCAL_PROGUARD_ENABLED := disabled
@@ -25,8 +32,6 @@ LOCAL_PRIVILEGED_MODULE := true
# Sign the package when not using test-keys
ifneq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/target/product/security/testkey)
LOCAL_CERTIFICATE := cyngn-app
-else
-$(warning *** SIGNING MODIOFX WITH TEST KEY ***)
endif
include $(BUILD_PACKAGE)
diff --git a/src/com/cyngn/audiofx/Constants.java b/src/com/cyngn/audiofx/Constants.java
index b38b0cd..c1d5475 100644
--- a/src/com/cyngn/audiofx/Constants.java
+++ b/src/com/cyngn/audiofx/Constants.java
@@ -24,8 +24,14 @@ import java.util.List;
public class Constants {
+ // current pref version, bump to rebuild prefs
public static final int CURRENT_PREFS_INT_VERSION = 2;
+ // effect type identifiers
+ public static final int EFFECT_TYPE_ANDROID = 1;
+ public static final int EFFECT_TYPE_MAXXAUDIO = 2;
+ public static final int EFFECT_TYPE_DTS = 3;
+
// global settings
public static final String AUDIOFX_GLOBAL_FILE = "global";
diff --git a/src/com/cyngn/audiofx/backends/AndroidEffects.java b/src/com/cyngn/audiofx/backends/AndroidEffects.java
index 77af1c9..090eb73 100644
--- a/src/com/cyngn/audiofx/backends/AndroidEffects.java
+++ b/src/com/cyngn/audiofx/backends/AndroidEffects.java
@@ -8,7 +8,6 @@ import android.media.audiofx.Virtualizer;
import android.util.Log;
import com.cyngn.audiofx.Constants;
-import com.cyngn.audiofx.activity.MasterConfigControl;
/**
* EffectSet which comprises standard Android effects
@@ -170,7 +169,7 @@ class AndroidEffects extends EffectSetWithAndroidEq {
@Override
public int getBrand() {
- return EffectsFactory.ANDROID;
+ return Constants.EFFECT_TYPE_ANDROID;
}
private void setParameterSafe(AudioEffect e, int p, short v) {
diff --git a/src/com/cyngn/audiofx/backends/EffectsFactory.java b/src/com/cyngn/audiofx/backends/EffectsFactory.java
deleted file mode 100644
index 6057255..0000000
--- a/src/com/cyngn/audiofx/backends/EffectsFactory.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package com.cyngn.audiofx.backends;
-
-import android.content.Context;
-import android.media.AudioDeviceInfo;
-import android.util.Log;
-
-import java.io.File;
-
-/**
- * Creates an EffectSet appropriate for the current device
- *
- * Currently handles basic Android effects and MaxxAudio. Extend for DTS in the future.
- */
-public class EffectsFactory {
-
- private static final String TAG = "AudioFx-EffectsFactory";
-
- private static int sBrand = -1; // cached value to not hit io every time we need a new effect
-
- public static final int ANDROID = 1;
- public static final int MAXXAUDIO = 2;
- public static final int DTS = 3;
-
- public static EffectSet createEffectSet(Context context, int sessionId,
- AudioDeviceInfo currentDevice) {
- EffectSet effects = null;
- int brand = getBrand();
-
- // dts?
- if (brand == DTS) {
- try {
- effects = new DtsEffects(context, sessionId, currentDevice);
- } catch (Exception e) {
- Log.e(TAG, "Unable to create DTS effects!", e);
- effects = null;
- }
- return effects;
- } else if (brand == MAXXAUDIO) {
- // try MaxxAudio next, this will throw an exception if unavailable
- try {
- effects = new MaxxAudioEffects(sessionId, currentDevice);
- } catch (Exception e) {
- Log.e(TAG, "Unable to create MaxxAudio effects!", e);
- effects = null;
- }
- return effects;
- }
-
- // if this throws, we're screwed, don't bother to recover. these
- // are the standard effects that every android device must have,
- // and if they don't exist we have bigger problems.
- return new AndroidEffects(sessionId, currentDevice);
- }
-
- public static int getBrand() {
- if (sBrand == -1) {
- sBrand = getBrandInternal();
- }
- return sBrand;
- }
-
- private static int getBrandInternal() {
- if (hasDts()) {
- return DTS;
- } else if (hasMaxxAudio()) {
- return MAXXAUDIO;
- }
- return ANDROID;
- }
-
- private static boolean hasDts() {
- return new File("***REMOVED***").exists();
- }
-
- private static boolean hasMaxxAudio() {
- return new File("***REMOVED***").exists();
- }
-}
diff --git a/src/com/cyngn/audiofx/backends/IEffectFactory.java b/src/com/cyngn/audiofx/backends/IEffectFactory.java
new file mode 100644
index 0000000..8e629b8
--- /dev/null
+++ b/src/com/cyngn/audiofx/backends/IEffectFactory.java
@@ -0,0 +1,16 @@
+package com.cyngn.audiofx.backends;
+
+import android.content.Context;
+import android.media.AudioDeviceInfo;
+
+interface IEffectFactory {
+
+ /**
+ * Create a new EffectSet based on current stream parameters.
+ * @param context context to create the effect with
+ * @param sessionId session id to attach the effect to
+ * @param currentDevice current device that the effect should initially setup for
+ * @return an {@link EffectSet}
+ */
+ EffectSet createEffectSet(Context context, int sessionId, AudioDeviceInfo currentDevice);
+}
diff --git a/src/com/cyngn/audiofx/service/DevicePreferenceManager.java b/src/com/cyngn/audiofx/service/DevicePreferenceManager.java
index 11d4de5..928209e 100644
--- a/src/com/cyngn/audiofx/service/DevicePreferenceManager.java
+++ b/src/com/cyngn/audiofx/service/DevicePreferenceManager.java
@@ -118,7 +118,7 @@ class DevicePreferenceManager implements AudioOutputChangeListener.AudioOutputCh
}
return;
}
- EffectSet temp = EffectsFactory.createEffectSet(mContext, 0, null);
+ EffectSet temp = new EffectsFactory().createEffectSet(mContext, 0, null);
final int numBands = temp.getNumEqualizerBands();
final int numPresets = temp.getNumEqualizerPresets();
@@ -168,8 +168,8 @@ class DevicePreferenceManager implements AudioOutputChangeListener.AudioOutputCh
editor.putBoolean(AUDIOFX_GLOBAL_HAS_VIRTUALIZER, temp.hasVirtualizer());
editor.putBoolean(AUDIOFX_GLOBAL_HAS_BASSBOOST, temp.hasBassBoost());
- editor.putBoolean(AUDIOFX_GLOBAL_HAS_MAXXAUDIO, temp.getBrand() == EffectsFactory.MAXXAUDIO);
- editor.putBoolean(AUDIOFX_GLOBAL_HAS_DTS, temp.getBrand() == EffectsFactory.DTS);
+ editor.putBoolean(AUDIOFX_GLOBAL_HAS_MAXXAUDIO, temp.getBrand() == Constants.EFFECT_TYPE_MAXXAUDIO);
+ editor.putBoolean(AUDIOFX_GLOBAL_HAS_DTS, temp.getBrand() == Constants.EFFECT_TYPE_DTS);
editor.commit();
temp.release();
@@ -208,7 +208,7 @@ class DevicePreferenceManager implements AudioOutputChangeListener.AudioOutputCh
final SharedPreferences globalPrefs = Constants.getGlobalPrefs(mContext);
- // Nothing to see here for DTS
+ // Nothing to see here for EFFECT_TYPE_DTS
if (globalPrefs.getBoolean(AUDIOFX_GLOBAL_HAS_DTS, false)) {
return;
}
diff --git a/src/com/cyngn/audiofx/service/SessionManager.java b/src/com/cyngn/audiofx/service/SessionManager.java
index 2a60cc2..c744686 100644
--- a/src/com/cyngn/audiofx/service/SessionManager.java
+++ b/src/com/cyngn/audiofx/service/SessionManager.java
@@ -309,7 +309,8 @@ class SessionManager implements AudioOutputChangeListener.AudioOutputChangedCall
session = mAudioSessionsL.get(sessionId);
if (session == null) {
try {
- session = EffectsFactory.createEffectSet(mContext, sessionId, mCurrentDevice);
+ session = new EffectsFactory()
+ .createEffectSet(mContext, sessionId, mCurrentDevice);
} catch (Exception e) {
Log.e(TAG, "couldn't create effects for session id: " + sessionId, e);
break;
diff --git a/src_effects/com/cyngn/audiofx/backends/EffectsFactory.java b/src_effects/com/cyngn/audiofx/backends/EffectsFactory.java
new file mode 100644
index 0000000..e33f5f5
--- /dev/null
+++ b/src_effects/com/cyngn/audiofx/backends/EffectsFactory.java
@@ -0,0 +1,35 @@
+package com.cyngn.audiofx.backends;
+
+import com.cyngn.audiofx.Constants;
+
+import android.content.Context;
+import android.media.AudioDeviceInfo;
+
+/**
+ * Creates an EffectSet appropriate for the current device
+ */
+public class EffectsFactory implements IEffectFactory {
+
+ private static final String TAG = "AudioFx-EffectsFactory";
+
+ private static int sBrand = -1; // cached value to not hit io every time we need a new effect
+
+ public EffectSet createEffectSet(Context context, int sessionId,
+ AudioDeviceInfo currentDevice) {
+ // if this throws, we're screwed, don't bother to recover. these
+ // are the standard effects that every android device must have,
+ // and if they don't exist we have bigger problems.
+ return new AndroidEffects(sessionId, currentDevice);
+ }
+
+ public static int getBrand() {
+ if (sBrand == -1) {
+ sBrand = getBrandInternal();
+ }
+ return sBrand;
+ }
+
+ private static int getBrandInternal() {
+ return Constants.EFFECT_TYPE_ANDROID;
+ }
+}