blob: 02e8fa760eb8e92775754e6013356cf293d91068 [file] [log] [blame]
Shunkai Yao51202502022-12-12 06:11:46 +00001/*
2 * Copyright (C) 2022 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 "DeviceHalAidl"
18
Mikhail Naganov31d46652023-01-10 18:29:25 +000019#include <mediautils/TimeCheck.h>
20#include <utils/Log.h>
Shunkai Yao51202502022-12-12 06:11:46 +000021
Mikhail Naganov31d46652023-01-10 18:29:25 +000022#include <aidl/android/hardware/audio/core/StreamDescriptor.h>
23
24#include "DeviceHalAidl.h"
25#include "StreamHalAidl.h"
26
27using ::aidl::android::hardware::audio::core::StreamDescriptor;
28
29namespace android {
30
31status_t DeviceHalAidl::getSupportedDevices(uint32_t*) {
32 // Obsolete.
33 return INVALID_OPERATION;
Shunkai Yao51202502022-12-12 06:11:46 +000034}
35
36status_t DeviceHalAidl::initCheck() {
Mikhail Naganov31d46652023-01-10 18:29:25 +000037 if (mModule == nullptr) return NO_INIT;
38 // HAL modules are already initialized by the time they are published to the SM.
Shunkai Yao51202502022-12-12 06:11:46 +000039 return OK;
40}
41
42status_t DeviceHalAidl::setVoiceVolume(float volume) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000043 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000044 mVoiceVolume = volume;
45 ALOGE("%s not implemented yet %f", __func__, volume);
46 return OK;
47}
48
49status_t DeviceHalAidl::setMasterVolume(float volume) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000050 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000051 mMasterVolume = volume;
52 ALOGE("%s not implemented yet %f", __func__, volume);
53 return OK;
54}
55
56status_t DeviceHalAidl::getMasterVolume(float *volume) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000057 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000058 *volume = mMasterVolume;
59 ALOGE("%s not implemented yet %f", __func__, *volume);
60 return OK;
61}
62
Mikhail Naganov31d46652023-01-10 18:29:25 +000063status_t DeviceHalAidl::setMode(audio_mode_t mode __unused) {
64 TIME_CHECK();
65 if (!mModule) return NO_INIT;
66 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +000067 return OK;
68}
69
70status_t DeviceHalAidl::setMicMute(bool state) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000071 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000072 mMicMute = state;
73 ALOGE("%s not implemented yet %d", __func__, state);
74 return OK;
75}
Mikhail Naganov31d46652023-01-10 18:29:25 +000076
Shunkai Yao51202502022-12-12 06:11:46 +000077status_t DeviceHalAidl::getMicMute(bool *state) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000078 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000079 *state = mMicMute;
80 ALOGE("%s not implemented yet %d", __func__, *state);
81 return OK;
82}
Mikhail Naganov31d46652023-01-10 18:29:25 +000083
Shunkai Yao51202502022-12-12 06:11:46 +000084status_t DeviceHalAidl::setMasterMute(bool state) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000085 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000086 mMasterMute = state;
87 ALOGE("%s not implemented yet %d", __func__, state);
88 return OK;
89}
Mikhail Naganov31d46652023-01-10 18:29:25 +000090
Shunkai Yao51202502022-12-12 06:11:46 +000091status_t DeviceHalAidl::getMasterMute(bool *state) {
Mikhail Naganov31d46652023-01-10 18:29:25 +000092 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +000093 *state = mMasterMute;
94 ALOGE("%s not implemented yet %d", __func__, *state);
95 return OK;
96}
97
Mikhail Naganov31d46652023-01-10 18:29:25 +000098status_t DeviceHalAidl::setParameters(const String8& kvPairs __unused) {
99 TIME_CHECK();
100 if (!mModule) return NO_INIT;
101 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000102 return OK;
103}
104
Mikhail Naganov31d46652023-01-10 18:29:25 +0000105status_t DeviceHalAidl::getParameters(const String8& keys __unused, String8 *values) {
106 TIME_CHECK();
107 values->clear();
108 if (!mModule) return NO_INIT;
109 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000110 return OK;
111}
112
Mikhail Naganov31d46652023-01-10 18:29:25 +0000113status_t DeviceHalAidl::getInputBufferSize(
114 const struct audio_config* config __unused, size_t* size __unused) {
115 TIME_CHECK();
116 if (!mModule) return NO_INIT;
117 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000118 return OK;
119}
120
Mikhail Naganov31d46652023-01-10 18:29:25 +0000121status_t DeviceHalAidl::openOutputStream(
122 audio_io_handle_t handle __unused, audio_devices_t devices __unused,
123 audio_output_flags_t flags __unused, struct audio_config* config,
124 const char* address __unused,
125 sp<StreamOutHalInterface>* outStream) {
126 if (!outStream || !config) {
127 return BAD_VALUE;
128 }
129 TIME_CHECK();
130 if (!mModule) return NO_INIT;
131 config->sample_rate = 48000;
132 config->format = AUDIO_FORMAT_PCM_24_BIT_PACKED;
133 config->channel_mask = AUDIO_CHANNEL_OUT_STEREO;
134 StreamDescriptor descriptor;
135 descriptor.frameSizeBytes = audio_bytes_per_sample(config->format) *
136 audio_channel_count_from_out_mask(config->channel_mask);
137 descriptor.bufferSizeFrames = 600;
138 *outStream = sp<StreamOutHalAidl>::make(descriptor, nullptr);
Shunkai Yao51202502022-12-12 06:11:46 +0000139 return OK;
140}
141
Mikhail Naganov31d46652023-01-10 18:29:25 +0000142status_t DeviceHalAidl::openInputStream(
143 audio_io_handle_t handle __unused, audio_devices_t devices __unused,
144 struct audio_config* config, audio_input_flags_t flags __unused,
145 const char* address __unused, audio_source_t source __unused,
146 audio_devices_t outputDevice __unused,
147 const char* outputDeviceAddress __unused,
148 sp<StreamInHalInterface>* inStream) {
149 if (!inStream || !config) {
150 return BAD_VALUE;
151 }
152 TIME_CHECK();
153 if (!mModule) return NO_INIT;
154 config->sample_rate = 48000;
155 config->format = AUDIO_FORMAT_PCM_24_BIT_PACKED;
156 config->channel_mask = AUDIO_CHANNEL_IN_STEREO;
157 StreamDescriptor descriptor;
158 descriptor.frameSizeBytes = audio_bytes_per_sample(config->format) *
159 audio_channel_count_from_out_mask(config->channel_mask);
160 descriptor.bufferSizeFrames = 600;
161 *inStream = sp<StreamInHalAidl>::make(descriptor, nullptr);
Shunkai Yao51202502022-12-12 06:11:46 +0000162 return OK;
163}
164
165status_t DeviceHalAidl::supportsAudioPatches(bool* supportsPatches) {
166 *supportsPatches = true;
167 return OK;
168}
169
Mikhail Naganov31d46652023-01-10 18:29:25 +0000170status_t DeviceHalAidl::createAudioPatch(unsigned int num_sources __unused,
171 const struct audio_port_config* sources __unused,
172 unsigned int num_sinks __unused,
173 const struct audio_port_config* sinks __unused,
174 audio_patch_handle_t* patch __unused) {
175 TIME_CHECK();
176 if (!mModule) return NO_INIT;
177 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000178 return OK;
179}
180
Mikhail Naganov31d46652023-01-10 18:29:25 +0000181status_t DeviceHalAidl::releaseAudioPatch(audio_patch_handle_t patch __unused) {
182 TIME_CHECK();
183 if (!mModule) return NO_INIT;
184 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000185 return OK;
186}
187
Mikhail Naganov31d46652023-01-10 18:29:25 +0000188status_t DeviceHalAidl::getAudioPort(struct audio_port* port __unused) {
189 TIME_CHECK();
190 ALOGE("%s not implemented yet", __func__);
191 return INVALID_OPERATION;
192}
193
194status_t DeviceHalAidl::getAudioPort(struct audio_port_v7 *port __unused) {
195 TIME_CHECK();
196 ALOGE("%s not implemented yet", __func__);
197 return INVALID_OPERATION;
198}
199
200status_t DeviceHalAidl::setAudioPortConfig(const struct audio_port_config* config __unused) {
201 TIME_CHECK();
202 if (!mModule) return NO_INIT;
203 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000204 return OK;
205}
206
207status_t DeviceHalAidl::getMicrophones(
Mikhail Naganov31d46652023-01-10 18:29:25 +0000208 std::vector<audio_microphone_characteristic_t>* microphones __unused) {
209 TIME_CHECK();
210 if (!mModule) return NO_INIT;
211 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000212 return OK;
213}
214
Mikhail Naganov31d46652023-01-10 18:29:25 +0000215status_t DeviceHalAidl::addDeviceEffect(audio_port_handle_t device __unused,
216 sp<EffectHalInterface> effect) {
Shunkai Yao51202502022-12-12 06:11:46 +0000217 if (!effect) {
218 return BAD_VALUE;
219 }
Mikhail Naganov31d46652023-01-10 18:29:25 +0000220 TIME_CHECK();
221 if (!mModule) return NO_INIT;
222 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000223 return OK;
224}
Mikhail Naganov31d46652023-01-10 18:29:25 +0000225status_t DeviceHalAidl::removeDeviceEffect(audio_port_handle_t device __unused,
Shunkai Yao51202502022-12-12 06:11:46 +0000226 sp<EffectHalInterface> effect) {
227 if (!effect) {
228 return BAD_VALUE;
229 }
Mikhail Naganov31d46652023-01-10 18:29:25 +0000230 TIME_CHECK();
231 if (!mModule) return NO_INIT;
232 ALOGE("%s not implemented yet", __func__);
Shunkai Yao51202502022-12-12 06:11:46 +0000233 return OK;
234}
235
236status_t DeviceHalAidl::getMmapPolicyInfos(
237 media::audio::common::AudioMMapPolicyType policyType __unused,
238 std::vector<media::audio::common::AudioMMapPolicyInfo>* policyInfos __unused) {
Mikhail Naganov31d46652023-01-10 18:29:25 +0000239 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +0000240 ALOGE("%s not implemented yet", __func__);
241 return OK;
242}
243
244int32_t DeviceHalAidl::getAAudioMixerBurstCount() {
Mikhail Naganov31d46652023-01-10 18:29:25 +0000245 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +0000246 ALOGE("%s not implemented yet", __func__);
247 return OK;
248}
249
250int32_t DeviceHalAidl::getAAudioHardwareBurstMinUsec() {
Mikhail Naganov31d46652023-01-10 18:29:25 +0000251 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +0000252 ALOGE("%s not implemented yet", __func__);
253 return OK;
254}
255
256error::Result<audio_hw_sync_t> DeviceHalAidl::getHwAvSync() {
Mikhail Naganov31d46652023-01-10 18:29:25 +0000257 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +0000258 ALOGE("%s not implemented yet", __func__);
259 return base::unexpected(INVALID_OPERATION);
260}
261
262status_t DeviceHalAidl::dump(int __unused, const Vector<String16>& __unused) {
263 ALOGE("%s not implemented yet", __func__);
264 return OK;
265};
266
Mikhail Naganov31d46652023-01-10 18:29:25 +0000267int32_t DeviceHalAidl::supportsBluetoothVariableLatency(bool* supports __unused) {
268 TIME_CHECK();
Shunkai Yao51202502022-12-12 06:11:46 +0000269 ALOGE("%s not implemented yet", __func__);
270 return INVALID_OPERATION;
271}
Mikhail Naganov31d46652023-01-10 18:29:25 +0000272
273} // namespace android