Home | History | Annotate | Download | only in include
      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);
     29     virtual ~AudioGain() {}
     30 
     31     void setMode(audio_gain_mode_t mode) { mGain.mode = mode; }
     32     const audio_gain_mode_t &getMode() const { return mGain.mode; }
     33 
     34     void setChannelMask(audio_channel_mask_t mask) { mGain.channel_mask = mask; }
     35     const audio_channel_mask_t &getChannelMask() const { return mGain.channel_mask; }
     36 
     37     void setMinValueInMb(int minValue) { mGain.min_value = minValue; }
     38     int getMinValueInMb() const { return mGain.min_value; }
     39 
     40     void setMaxValueInMb(int maxValue) { mGain.max_value = maxValue; }
     41     int getMaxValueInMb() const { return mGain.max_value; }
     42 
     43     void setDefaultValueInMb(int defaultValue) { mGain.default_value = defaultValue; }
     44     int getDefaultValueInMb() const { return mGain.default_value; }
     45 
     46     void setStepValueInMb(uint32_t stepValue) { mGain.step_value = stepValue; }
     47     int getStepValueInMb() const { return mGain.step_value; }
     48 
     49     void setMinRampInMs(uint32_t minRamp) { mGain.min_ramp_ms = minRamp; }
     50     int getMinRampInMs() const { return mGain.min_ramp_ms; }
     51 
     52     void setMaxRampInMs(uint32_t maxRamp) { mGain.max_ramp_ms = maxRamp; }
     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 
     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