• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <android-base/stringprintf.h>
21 
22 #include "AudioCollections.h"
23 #include "AudioRoute.h"
24 #include "HwModule.h"
25 #include "PolicyAudioPort.h"
26 
27 namespace android {
28 
findByTagName(const PolicyAudioPortVector & policyAudioPortVector,const std::string & tagName)29 sp<PolicyAudioPort> findByTagName(const PolicyAudioPortVector& policyAudioPortVector,
30                                   const std::string &tagName)
31 {
32     for (const auto& port : policyAudioPortVector) {
33         if (port->getTagName() == tagName) {
34             return port;
35         }
36     }
37     return nullptr;
38 }
39 
dumpAudioRouteVector(const AudioRouteVector & audioRouteVector,String8 * dst,int spaces)40 void dumpAudioRouteVector(const AudioRouteVector& audioRouteVector, String8 *dst, int spaces)
41 {
42     if (audioRouteVector.isEmpty()) {
43         return;
44     }
45     dst->appendFormat("%*s- Audio Routes (%zu):\n", spaces - 2, "", audioRouteVector.size());
46     for (size_t i = 0; i < audioRouteVector.size(); i++) {
47         const std::string prefix = base::StringPrintf("%*s %zu. ", spaces, "", i + 1);
48         dst->append(prefix.c_str());
49         audioRouteVector.itemAt(i)->dump(dst, prefix.size());
50     }
51 }
52 
53 } // namespace android
54