1d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent/*
2d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * Copyright (C) 2015 The Android Open Source Project
3d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent *
4d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * Licensed under the Apache License, Version 2.0 (the "License");
5d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * you may not use this file except in compliance with the License.
6d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * You may obtain a copy of the License at
7d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent *
8d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent *      http://www.apache.org/licenses/LICENSE-2.0
9d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent *
10d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * Unless required by applicable law or agreed to in writing, software
11d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * distributed under the License is distributed on an "AS IS" BASIS,
12d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * See the License for the specific language governing permissions and
14d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent * limitations under the License.
15d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent */
16d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
17d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#define LOG_TAG "APM::AudioSourceDescriptor"
18d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent//#define LOG_NDEBUG 0
19d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
20d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <utils/Log.h>
21d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <utils/String8.h>
22d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <media/AudioPolicyHelper.h>
23d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <HwModule.h>
24d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <AudioGain.h>
25d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <AudioSourceDescriptor.h>
26d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <DeviceDescriptor.h>
27d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <IOProfile.h>
28d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent#include <AudioOutputDescriptor.h>
29d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
30d60560af7cb559762593161c8202459cc01fb0f5Eric Laurentnamespace android {
31d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
32d60560af7cb559762593161c8202459cc01fb0f5Eric Laurentstatus_t AudioSourceDescriptor::dump(int fd)
33d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent{
34d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    const size_t SIZE = 256;
35d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    char buffer[SIZE];
36d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    String8 result;
37d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
38d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    snprintf(buffer, SIZE, "mStream: %d\n", audio_attributes_to_stream_type(&mAttributes));
39d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    result.append(buffer);
40d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    snprintf(buffer, SIZE, "mDevice:\n");
41d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    result.append(buffer);
42d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    write(fd, result.string(), result.size());
43d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    mDevice->dump(fd, 2 , 0);
44d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    return NO_ERROR;
45d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent}
46d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
47d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
48d60560af7cb559762593161c8202459cc01fb0f5Eric Laurentstatus_t AudioSourceCollection::dump(int fd) const
49d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent{
50d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    const size_t SIZE = 256;
51d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    char buffer[SIZE];
52d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
53d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    snprintf(buffer, SIZE, "\nAudio sources dump:\n");
54d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    write(fd, buffer, strlen(buffer));
55d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    for (size_t i = 0; i < size(); i++) {
56d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent        snprintf(buffer, SIZE, "- Source %d dump:\n", keyAt(i));
57d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent        write(fd, buffer, strlen(buffer));
58d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent        valueAt(i)->dump(fd);
59d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    }
60d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
61d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent    return NO_ERROR;
62d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent}
63d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent
64d60560af7cb559762593161c8202459cc01fb0f5Eric Laurent}; //namespace android
65