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 #define LOG_TAG "APM::AudioCollections"
18 //#define LOG_NDEBUG 0
19
20 #include "AudioCollections.h"
21 #include "AudioRoute.h"
22 #include "HwModule.h"
23 #include "PolicyAudioPort.h"
24
25 namespace android {
26
findByTagName(const PolicyAudioPortVector & policyAudioPortVector,const std::string & tagName)27 sp<PolicyAudioPort> findByTagName(const PolicyAudioPortVector& policyAudioPortVector,
28 const std::string &tagName)
29 {
30 for (const auto& port : policyAudioPortVector) {
31 if (port->getTagName() == tagName) {
32 return port;
33 }
34 }
35 return nullptr;
36 }
37
dumpAudioRouteVector(const AudioRouteVector & audioRouteVector,String8 * dst,int spaces)38 void dumpAudioRouteVector(const AudioRouteVector& audioRouteVector, String8 *dst, int spaces)
39 {
40 if (audioRouteVector.isEmpty()) {
41 return;
42 }
43 dst->appendFormat("\n%*sAudio Routes (%zu):\n", spaces, "", audioRouteVector.size());
44 for (size_t i = 0; i < audioRouteVector.size(); i++) {
45 dst->appendFormat("%*s- Route %zu:\n", spaces, "", i + 1);
46 audioRouteVector.itemAt(i)->dump(dst, 4);
47 }
48 }
49
50 } // namespace android
51