summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorSteve Kondik <steve@cyngn.com>2016-03-06 05:31:05 -0800
committerSteve Kondik <shade@chemlab.org>2016-03-08 17:34:31 -0800
commit9957394df71db6f01802091858216582c58eab67 (patch)
treee5d0749c23553360f303c732b2401e3068dbb8db /media
parente4bc68603b42ae01b22aebcb80b2d2c17d7b9158 (diff)
downloadframeworks_base-9957394df71db6f01802091858216582c58eab67.zip
frameworks_base-9957394df71db6f01802091858216582c58eab67.tar.gz
frameworks_base-9957394df71db6f01802091858216582c58eab67.tar.bz2
audiosystem: Add API for listening to effect session events
* This API will allow attaching a global listener which will notify the application when audio effect sessions are attached or removed on a stream. This requires that the policy is configured to automatically attach a set of effects. Change-Id: Iaf1ca133765045322b005d4148e2c4e86a9c3913
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioSystem.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 927cd87..8bf1604 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -268,6 +268,54 @@ public class AudioSystem
}
+ /**
+ * Handles events for the audio policy manager about effect sessions
+ * @see android.media.audiopolicy.AudioPolicy
+ */
+ public interface EffectSessionCallback
+ {
+ void onSessionAdded(int stream, int sessionId);
+
+ void onSessionRemoved(int stream, int sessionId);
+ }
+
+ //keep in sync with include/media/AudioPolicy.h
+ private final static int AUDIO_OUTPUT_SESSION_EFFECTS_UPDATE = 10;
+
+ private static EffectSessionCallback sEffectSessionCallback;
+
+ public static void setEffectSessionCallback(EffectSessionCallback cb)
+ {
+ synchronized (AudioSystem.class) {
+ sEffectSessionCallback = cb;
+ native_register_effect_session_callback();
+ }
+ }
+
+ private static void effectSessionCallbackFromNative(int event, int stream, int sessionId, boolean added)
+ {
+ EffectSessionCallback cb = null;
+ synchronized (AudioSystem.class) {
+ if (sEffectSessionCallback != null) {
+ cb = sEffectSessionCallback;
+ }
+ }
+ if (cb != null) {
+ switch(event) {
+ case AUDIO_OUTPUT_SESSION_EFFECTS_UPDATE:
+ if (added) {
+ cb.onSessionAdded(stream, sessionId);
+ } else {
+ cb.onSessionRemoved(stream, sessionId);
+ }
+ break;
+ default:
+ Log.e(TAG, "effectSessionCallbackFromNative: unknown event " + event);
+ }
+ }
+ }
+
+
/*
* Error codes used by public APIs (AudioTrack, AudioRecord, AudioManager ...)
* Must be kept in sync with frameworks/base/core/jni/android_media_AudioErrors.h
@@ -648,6 +696,8 @@ public class AudioSystem
// declare this instance as having a dynamic policy callback handler
private static native final void native_register_dynamic_policy_callback();
+ private static native final void native_register_effect_session_callback();
+
// must be kept in sync with value in include/system/audio.h
public static final int AUDIO_HW_SYNC_INVALID = 0;