1a198a29250acb7c3e918f1566727190966bb336fEric Laurent/* 2a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Copyright (C) 2014 The Android Open Source Project 3a198a29250acb7c3e918f1566727190966bb336fEric Laurent * 4a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Licensed under the Apache License, Version 2.0 (the "License"); 5a198a29250acb7c3e918f1566727190966bb336fEric Laurent * you may not use this file except in compliance with the License. 6a198a29250acb7c3e918f1566727190966bb336fEric Laurent * You may obtain a copy of the License at 7a198a29250acb7c3e918f1566727190966bb336fEric Laurent * 8a198a29250acb7c3e918f1566727190966bb336fEric Laurent * http://www.apache.org/licenses/LICENSE-2.0 9a198a29250acb7c3e918f1566727190966bb336fEric Laurent * 10a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Unless required by applicable law or agreed to in writing, software 11a198a29250acb7c3e918f1566727190966bb336fEric Laurent * distributed under the License is distributed on an "AS IS" BASIS, 12a198a29250acb7c3e918f1566727190966bb336fEric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a198a29250acb7c3e918f1566727190966bb336fEric Laurent * See the License for the specific language governing permissions and 14a198a29250acb7c3e918f1566727190966bb336fEric Laurent * limitations under the License. 15a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 16a198a29250acb7c3e918f1566727190966bb336fEric Laurent 17a198a29250acb7c3e918f1566727190966bb336fEric Laurentpackage android.media; 18a198a29250acb7c3e918f1566727190966bb336fEric Laurent 19a198a29250acb7c3e918f1566727190966bb336fEric Laurent/** 20a198a29250acb7c3e918f1566727190966bb336fEric Laurent * The AudioGainConfig is used by APIs setting or getting values on a given gain 21a198a29250acb7c3e918f1566727190966bb336fEric Laurent * controller. It contains a valid configuration (value, channels...) for a gain controller 22a198a29250acb7c3e918f1566727190966bb336fEric Laurent * exposed by an audio port. 23a198a29250acb7c3e918f1566727190966bb336fEric Laurent * @see AudioGain 24a198a29250acb7c3e918f1566727190966bb336fEric Laurent * @see AudioPort 25a198a29250acb7c3e918f1566727190966bb336fEric Laurent * @hide 26a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 27a198a29250acb7c3e918f1566727190966bb336fEric Laurentpublic class AudioGainConfig { 28a198a29250acb7c3e918f1566727190966bb336fEric Laurent AudioGain mGain; 29a198a29250acb7c3e918f1566727190966bb336fEric Laurent private final int mIndex; 30a198a29250acb7c3e918f1566727190966bb336fEric Laurent private final int mMode; 31a198a29250acb7c3e918f1566727190966bb336fEric Laurent private final int mChannelMask; 32a198a29250acb7c3e918f1566727190966bb336fEric Laurent private final int mValues[]; 33a198a29250acb7c3e918f1566727190966bb336fEric Laurent private final int mRampDurationMs; 34a198a29250acb7c3e918f1566727190966bb336fEric Laurent 35a198a29250acb7c3e918f1566727190966bb336fEric Laurent AudioGainConfig(int index, AudioGain gain, int mode, int channelMask, 36a198a29250acb7c3e918f1566727190966bb336fEric Laurent int[] values, int rampDurationMs) { 37a198a29250acb7c3e918f1566727190966bb336fEric Laurent mIndex = index; 38a198a29250acb7c3e918f1566727190966bb336fEric Laurent mGain = gain; 39a198a29250acb7c3e918f1566727190966bb336fEric Laurent mMode = mode; 40a198a29250acb7c3e918f1566727190966bb336fEric Laurent mChannelMask = channelMask; 41a198a29250acb7c3e918f1566727190966bb336fEric Laurent mValues = values; 42a198a29250acb7c3e918f1566727190966bb336fEric Laurent mRampDurationMs = rampDurationMs; 43a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 44a198a29250acb7c3e918f1566727190966bb336fEric Laurent 45a198a29250acb7c3e918f1566727190966bb336fEric Laurent /** 46a198a29250acb7c3e918f1566727190966bb336fEric Laurent * get the index of the parent gain. 47a198a29250acb7c3e918f1566727190966bb336fEric Laurent * frameworks use only. 48a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 49a198a29250acb7c3e918f1566727190966bb336fEric Laurent int index() { 50a198a29250acb7c3e918f1566727190966bb336fEric Laurent return mIndex; 51a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 52a198a29250acb7c3e918f1566727190966bb336fEric Laurent 53a198a29250acb7c3e918f1566727190966bb336fEric Laurent /** 54a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Bit field indicating requested modes of operation. See {@link AudioGain#MODE_JOINT}, 55a198a29250acb7c3e918f1566727190966bb336fEric Laurent * {@link AudioGain#MODE_CHANNELS}, {@link AudioGain#MODE_RAMP} 56a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 57a198a29250acb7c3e918f1566727190966bb336fEric Laurent public int mode() { 58a198a29250acb7c3e918f1566727190966bb336fEric Laurent return mMode; 59a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 60a198a29250acb7c3e918f1566727190966bb336fEric Laurent 61a198a29250acb7c3e918f1566727190966bb336fEric Laurent /** 62a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Indicates for which channels the gain is set. 63a198a29250acb7c3e918f1566727190966bb336fEric Laurent * See {@link AudioFormat#CHANNEL_OUT_STEREO}, {@link AudioFormat#CHANNEL_OUT_MONO} ... 64a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 65a198a29250acb7c3e918f1566727190966bb336fEric Laurent public int channelMask() { 66a198a29250acb7c3e918f1566727190966bb336fEric Laurent return mChannelMask; 67a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 68a198a29250acb7c3e918f1566727190966bb336fEric Laurent 69a198a29250acb7c3e918f1566727190966bb336fEric Laurent /** 70a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Gain values for each channel in the order of bits set in 71a198a29250acb7c3e918f1566727190966bb336fEric Laurent * channelMask() from LSB to MSB 72a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 73a198a29250acb7c3e918f1566727190966bb336fEric Laurent public int[] values() { 74a198a29250acb7c3e918f1566727190966bb336fEric Laurent return mValues; 75a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 76a198a29250acb7c3e918f1566727190966bb336fEric Laurent 77a198a29250acb7c3e918f1566727190966bb336fEric Laurent /** 78a198a29250acb7c3e918f1566727190966bb336fEric Laurent * Ramp duration in milliseconds. N/A if mode() does not 79a198a29250acb7c3e918f1566727190966bb336fEric Laurent * specify MODE_RAMP. 80a198a29250acb7c3e918f1566727190966bb336fEric Laurent */ 81a198a29250acb7c3e918f1566727190966bb336fEric Laurent public int rampDurationMs() { 82a198a29250acb7c3e918f1566727190966bb336fEric Laurent return mRampDurationMs; 83a198a29250acb7c3e918f1566727190966bb336fEric Laurent } 84a198a29250acb7c3e918f1566727190966bb336fEric Laurent} 85