From 3a24199a0fe9479802ff6096d82cb3745efa1f1f Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 19 May 2014 19:33:26 -0700 Subject: AudioManager: add audio port gain control Implement AudioManager.setAudioPortGain() API. Bug: 14815883. Change-Id: Ib54bd1fd1392c474f4767a00228b0a617c51ec5e --- media/java/android/media/AudioManager.java | 9 ++++++++- media/java/android/media/AudioPort.java | 3 +++ media/java/android/media/AudioSystem.java | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'media') diff --git a/media/java/android/media/AudioManager.java b/media/java/android/media/AudioManager.java index e6988b6..2f8a17b 100644 --- a/media/java/android/media/AudioManager.java +++ b/media/java/android/media/AudioManager.java @@ -3087,7 +3087,14 @@ public class AudioManager { * @hide */ public int setAudioPortGain(AudioPort port, AudioGainConfig gain) { - return ERROR_INVALID_OPERATION; + if (port == null || gain == null) { + return ERROR_BAD_VALUE; + } + AudioPortConfig activeConfig = port.activeConfig(); + AudioPortConfig config = new AudioPortConfig(port, activeConfig.samplingRate(), + activeConfig.channelMask(), activeConfig.format(), gain); + config.mConfigMask = AudioPortConfig.GAIN; + return AudioSystem.setAudioPortConfig(config); } /** diff --git a/media/java/android/media/AudioPort.java b/media/java/android/media/AudioPort.java index 9aeddef..fbd5022 100644 --- a/media/java/android/media/AudioPort.java +++ b/media/java/android/media/AudioPort.java @@ -133,6 +133,9 @@ public class AudioPort { * Get the gain descriptor at a given index */ AudioGain gain(int index) { + if (index < mGains.length) { + return null; + } return mGains[index]; } diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java index 47a884b..af7a3e1 100644 --- a/media/java/android/media/AudioSystem.java +++ b/media/java/android/media/AudioSystem.java @@ -465,5 +465,6 @@ public class AudioSystem AudioPortConfig[] sources, AudioPortConfig[] sinks); public static native int releaseAudioPatch(AudioPatch patch); public static native int listAudioPatches(ArrayList patches, int[] generation); + public static native int setAudioPortConfig(AudioPortConfig config); } -- cgit v1.1