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 #define LOG_TAG "APM::AudioPolicyEngine/VolumeGroup"
18 //#define LOG_NDEBUG 0
19
20 #include "VolumeGroup.h"
21 #include <media/TypeConverter.h>
22 #include <utils/String8.h>
23 #include <cstdint>
24 #include <string>
25
26 #include <log/log.h>
27
28
29 namespace android {
30
31 //
32 // VolumeGroup implementation
33 //
VolumeGroup(const std::string & name,int indexMin,int indexMax)34 VolumeGroup::VolumeGroup(const std::string &name, int indexMin, int indexMax) :
35 mName(name), mId(static_cast<volume_group_t>(HandleGenerator<uint32_t>::getNextHandle())),
36 mGroupVolumeCurves(VolumeCurves(indexMin, indexMax))
37 {
38 }
39
dump(String8 * dst,int spaces) const40 void VolumeGroup::dump(String8 *dst, int spaces) const
41 {
42 dst->appendFormat("\n%*s-%s (id: %d)\n", spaces, "", mName.c_str(), mId);
43 mGroupVolumeCurves.dump(dst, spaces + 2, true);
44 mGroupVolumeCurves.dump(dst, spaces + 2, false);
45 dst->appendFormat("\n");
46 }
47
add(const sp<VolumeCurve> & curve)48 void VolumeGroup::add(const sp<VolumeCurve> &curve)
49 {
50 mGroupVolumeCurves.add(curve);
51 }
52
addSupportedAttributes(const audio_attributes_t & attr)53 void VolumeGroup::addSupportedAttributes(const audio_attributes_t &attr)
54 {
55 mGroupVolumeCurves.addAttributes(attr);
56 }
57
addSupportedStream(audio_stream_type_t stream)58 void VolumeGroup::addSupportedStream(audio_stream_type_t stream)
59 {
60 mGroupVolumeCurves.addStreamType(stream);
61 }
62
63 //
64 // VolumeGroupMap implementation
65 //
dump(String8 * dst,int spaces) const66 void VolumeGroupMap::dump(String8 *dst, int spaces) const
67 {
68 dst->appendFormat("\n%*sVolume Groups dump:", spaces, "");
69 for (const auto &iter : *this) {
70 iter.second->dump(dst, spaces + 2);
71 }
72 }
73
74 } // namespace android
75
76