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