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