summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-04-07 12:48:20 -0700
committerSteve Kondik <steve@cyngn.com>2016-04-08 19:25:53 +0000
commitef31a6d32fce02e63aab83893ca406d0bdda375e (patch)
tree53ddd3e0ce64edae7fd820b34d96c232f965287c /src
parent5f4e0f47d56bbdcf060ac250ef000cba6e63090d (diff)
downloadandroid_packages_apps_AudioFX-ef31a6d32fce02e63aab83893ca406d0bdda375e.tar.gz
android_packages_apps_AudioFX-ef31a6d32fce02e63aab83893ca406d0bdda375e.tar.bz2
android_packages_apps_AudioFX-ef31a6d32fce02e63aab83893ca406d0bdda375e.zip
audiofx: Update for new session callback mechanism
* Session callbacks now fire for *all* audio sessions. Additional information is now passed to allow us to make a call on whether we should load effects for this stream. * The current restrictions for session callbacks will attach effects if the stream type is STREAM_MUSIC, the stream is deep buffer or compress offload, and the stream is not mono. We also receive the UID, but this is not yet used. Additional constraints can be defined later. Change-Id: I61b508dfe9191e9e2c4311e80a2e16dab99481e2
Diffstat (limited to 'src')
-rw-r--r--src/com/cyngn/audiofx/service/AudioFxService.java7
-rw-r--r--src/com/cyngn/audiofx/service/SessionManager.java16
2 files changed, 18 insertions, 5 deletions
diff --git a/src/com/cyngn/audiofx/service/AudioFxService.java b/src/com/cyngn/audiofx/service/AudioFxService.java
index 35089ef..414a642 100644
--- a/src/com/cyngn/audiofx/service/AudioFxService.java
+++ b/src/com/cyngn/audiofx/service/AudioFxService.java
@@ -75,6 +75,11 @@ public class AudioFxService extends Service {
public static final int REVERB_CHANGED = 0x20;
public static final int ALL_CHANGED = 0xFF;
+ // flags from audio.h, used by session callbacks
+ static final int AUDIO_OUTPUT_FLAG_FAST = 0x4;
+ static final int AUDIO_OUTPUT_FLAG_DEEP_BUFFER = 0x8;
+ static final int AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD = 0x10;
+
private static final int TILE_ID = 555;
private Locale mLastLocale;
@@ -181,7 +186,7 @@ public class AudioFxService extends Service {
Log.i(TAG, String.format("New audio session: %d package: %s contentType=%s",
sessionId, pkg, contentType));
}
- mSessionManager.onSessionAdded(AudioManager.STREAM_MUSIC, sessionId);
+ mSessionManager.onSessionAdded(AudioManager.STREAM_MUSIC, sessionId, -1, -1, -1);
} else if (action.equals(AudioEffect.ACTION_CLOSE_AUDIO_EFFECT_CONTROL_SESSION)) {
diff --git a/src/com/cyngn/audiofx/service/SessionManager.java b/src/com/cyngn/audiofx/service/SessionManager.java
index a4fa3f2..acbdca8 100644
--- a/src/com/cyngn/audiofx/service/SessionManager.java
+++ b/src/com/cyngn/audiofx/service/SessionManager.java
@@ -44,7 +44,7 @@ class SessionManager extends AudioOutputChangeListener implements AudioSystem.Ef
private static final String TAG = "AudioFxService";
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
-
+
private final Context mContext;
/**
@@ -105,16 +105,24 @@ class SessionManager extends AudioOutputChangeListener implements AudioSystem.Ef
/**
* Callback which listens for session updates from AudioPolicyManager. This is a
- * feature added by CM which notifies when *default* sessions are created or
+ * feature added by CM which notifies when sessions are created or
* destroyed on a particular stream. This is independent of the standard control
* intents and should not conflict with them. This feature may not be available on
* all devices.
+ *
+ * Default logic is to do our best to only attach to music streams. We never attach
+ * to low-latency streams automatically, and we don't attach to mono streams by default
+ * either since these are usually notifications/ringtones/etc.
*/
@Override
- public void onSessionAdded(int stream, int sessionId) {
+ public void onSessionAdded(int stream, int sessionId, int flags, int channelMask, int uid) {
if (stream == AudioManager.STREAM_MUSIC &&
+ ((flags < 0) || (flags & AudioFxService.AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) > 0 ||
+ (flags & AudioFxService.AUDIO_OUTPUT_FLAG_DEEP_BUFFER) > 0) &&
+ (channelMask < 0 || channelMask > 1) &&
!mHandler.hasMessages(MSG_ADD_SESSION, sessionId)) {
- if (DEBUG) Log.i(TAG, String.format("New audio session: %d", sessionId));
+ if (DEBUG) Log.i(TAG, String.format("New audio session: %d [flags=%d channelMask=%d uid=%d]",
+ sessionId, flags, channelMask, uid));
mHandler.obtainMessage(MSG_ADD_SESSION, sessionId).sendToTarget();
}
}