1 /*
2  * Copyright (C) 2015 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 
17 #pragma once
18 
19 #include <utils/Errors.h>
20 #include <utils/RefBase.h>
21 #include <system/audio.h>
22 
23 namespace android {
24 
25 class AudioGain: public RefBase
26 {
27 public:
28     AudioGain(int index, bool useInChannelMask);
~AudioGain()29     virtual ~AudioGain() {}
30 
setMode(audio_gain_mode_t mode)31     void setMode(audio_gain_mode_t mode) { mGain.mode = mode; }
getMode()32     const audio_gain_mode_t &getMode() const { return mGain.mode; }
33 
setChannelMask(audio_channel_mask_t mask)34     void setChannelMask(audio_channel_mask_t mask) { mGain.channel_mask = mask; }
getChannelMask()35     const audio_channel_mask_t &getChannelMask() const { return mGain.channel_mask; }
36 
setMinValueInMb(int minValue)37     void setMinValueInMb(int minValue) { mGain.min_value = minValue; }
getMinValueInMb()38     int getMinValueInMb() const { return mGain.min_value; }
39 
setMaxValueInMb(int maxValue)40     void setMaxValueInMb(int maxValue) { mGain.max_value = maxValue; }
getMaxValueInMb()41     int getMaxValueInMb() const { return mGain.max_value; }
42 
setDefaultValueInMb(int defaultValue)43     void setDefaultValueInMb(int defaultValue) { mGain.default_value = defaultValue; }
getDefaultValueInMb()44     int getDefaultValueInMb() const { return mGain.default_value; }
45 
setStepValueInMb(uint32_t stepValue)46     void setStepValueInMb(uint32_t stepValue) { mGain.step_value = stepValue; }
getStepValueInMb()47     int getStepValueInMb() const { return mGain.step_value; }
48 
setMinRampInMs(uint32_t minRamp)49     void setMinRampInMs(uint32_t minRamp) { mGain.min_ramp_ms = minRamp; }
getMinRampInMs()50     int getMinRampInMs() const { return mGain.min_ramp_ms; }
51 
setMaxRampInMs(uint32_t maxRamp)52     void setMaxRampInMs(uint32_t maxRamp) { mGain.max_ramp_ms = maxRamp; }
getMaxRampInMs()53     int getMaxRampInMs() const { return mGain.max_ramp_ms; }
54 
55     // TODO: remove dump from here (split serialization)
56     void dump(int fd, int spaces, int index) const;
57 
58     void getDefaultConfig(struct audio_gain_config *config);
59     status_t checkConfig(const struct audio_gain_config *config);
60 
getGain()61     const struct audio_gain &getGain() const { return mGain; }
62 
63 private:
64     int               mIndex;
65     struct audio_gain mGain;
66     bool              mUseInChannelMask;
67 };
68 
69 }; // namespace android
70