1 /*
2  * Copyright (C) 2018 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 <VolumeCurve.h>
20 #include <system/audio.h>
21 #include <utils/RefBase.h>
22 #include <HandleGenerator.h>
23 #include <string>
24 #include <vector>
25 #include <map>
26 #include <utils/Errors.h>
27 
28 namespace android {
29 
30 class VolumeGroup : public virtual RefBase, private HandleGenerator<uint32_t>
31 {
32 public:
33     VolumeGroup(const std::string &name, int indexMin, int indexMax);
getName()34     std::string getName() const { return mName; }
getId()35     volume_group_t getId() const { return mId; }
36 
37     void add(const sp<VolumeCurve> &curve);
38 
getVolumeCurves()39     VolumeCurves *getVolumeCurves() { return &mGroupVolumeCurves; }
40 
41     void addSupportedAttributes(const audio_attributes_t &attr);
getSupportedAttributes()42     AttributesVector getSupportedAttributes() const { return mGroupVolumeCurves.getAttributes(); }
43 
44     void addSupportedStream(audio_stream_type_t stream);
getStreamTypes()45     StreamTypeVector getStreamTypes() const { return mGroupVolumeCurves.getStreamTypes(); }
46 
47     void dump(String8 *dst, int spaces = 0) const;
48 
49 private:
50     const std::string mName;
51     const volume_group_t mId;
52     VolumeCurves mGroupVolumeCurves;
53 };
54 
55 class VolumeGroupMap : public std::map<volume_group_t, sp<VolumeGroup> >
56 {
57 public:
58     void dump(String8 *dst, int spaces = 0) const;
59 };
60 
61 } // namespace android
62