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