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 "AudioPort.h"
22 #include "AudioRoute.h"
23 #include "HwModule.h"
24 #include "AudioGain.h"
25
26 namespace android {
27
findByTagName(const String8 & tagName) const28 sp<AudioPort> AudioPortVector::findByTagName(const String8 &tagName) const
29 {
30 for (const auto& port : *this) {
31 if (port->getTagName() == tagName) {
32 return port;
33 }
34 }
35 return nullptr;
36 }
37
dump(int fd,int spaces) const38 status_t AudioRouteVector::dump(int fd, int spaces) const
39 {
40 if (isEmpty()) {
41 return NO_ERROR;
42 }
43 const size_t SIZE = 256;
44 char buffer[SIZE];
45
46 snprintf(buffer, SIZE, "\n%*sAudio Routes (%zu):\n", spaces, "", size());
47 write(fd, buffer, strlen(buffer));
48 for (size_t i = 0; i < size(); i++) {
49 snprintf(buffer, SIZE, "%*s- Route %zu:\n", spaces, "", i + 1);
50 write(fd, buffer, strlen(buffer));
51 itemAt(i)->dump(fd, 4);
52 }
53 return NO_ERROR;
54 }
55
56 } // namespace android
57