blob: fed86c9983d48dbef0540439260554e0ebfb3e4c [file] [log] [blame]
Eric Laurent73e26b62015-04-27 16:55:58 -07001/*
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#ifndef ANDROID_AUDIO_IO_DESCRIPTOR_H
18#define ANDROID_AUDIO_IO_DESCRIPTOR_H
19
20namespace android {
21
22enum audio_io_config_event {
23 AUDIO_OUTPUT_OPENED,
24 AUDIO_OUTPUT_CLOSED,
25 AUDIO_OUTPUT_CONFIG_CHANGED,
26 AUDIO_INPUT_OPENED,
27 AUDIO_INPUT_CLOSED,
28 AUDIO_INPUT_CONFIG_CHANGED,
29};
30
31// audio input/output descriptor used to cache output configurations in client process to avoid
32// frequent calls through IAudioFlinger
33class AudioIoDescriptor : public RefBase {
34public:
35 AudioIoDescriptor() :
Eric Laurent296fb132015-05-01 11:38:42 -070036 mIoHandle(AUDIO_IO_HANDLE_NONE),
Eric Laurent73e26b62015-04-27 16:55:58 -070037 mSamplingRate(0), mFormat(AUDIO_FORMAT_DEFAULT), mChannelMask(AUDIO_CHANNEL_NONE),
Glenn Kasten4a8308b2016-04-18 14:10:01 -070038 mFrameCount(0), mFrameCountHAL(0), mLatency(0)
Eric Laurent296fb132015-05-01 11:38:42 -070039 {
40 memset(&mPatch, 0, sizeof(struct audio_patch));
41 }
Eric Laurent73e26b62015-04-27 16:55:58 -070042
43 virtual ~AudioIoDescriptor() {}
44
Eric Laurent296fb132015-05-01 11:38:42 -070045 audio_port_handle_t getDeviceId() {
46 if (mPatch.num_sources != 0 && mPatch.num_sinks != 0) {
47 if (mPatch.sources[0].type == AUDIO_PORT_TYPE_MIX) {
48 // this is an output mix
49 // FIXME: the API only returns the first device in case of multiple device selection
50 return mPatch.sinks[0].id;
51 } else {
52 // this is an input mix
53 return mPatch.sources[0].id;
54 }
55 }
56 return AUDIO_PORT_HANDLE_NONE;
57 }
58
Glenn Kasten2c073da2016-02-26 09:14:08 -080059 audio_io_handle_t mIoHandle;
60 struct audio_patch mPatch;
61 uint32_t mSamplingRate;
62 audio_format_t mFormat;
63 audio_channel_mask_t mChannelMask;
64 size_t mFrameCount;
Glenn Kasten4a8308b2016-04-18 14:10:01 -070065 size_t mFrameCountHAL;
Glenn Kasten2c073da2016-02-26 09:14:08 -080066 uint32_t mLatency; // only valid for output
Eric Laurent73e26b62015-04-27 16:55:58 -070067};
68
69
70}; // namespace android
71
72#endif /*ANDROID_AUDIO_IO_DESCRIPTOR_H*/