Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 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 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 17 | #define LOG_TAG "AudioPolicyClientImpl" |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 18 | //#define LOG_NDEBUG 0 |
| 19 | |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 20 | #include "AudioPolicyService.h" |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 21 | |
Ytai Ben-Tsvi | 74cd6b0 | 2019-10-25 10:06:40 -0700 | [diff] [blame] | 22 | #include <utils/Log.h> |
| 23 | |
| 24 | #include "BinderProxy.h" |
| 25 | |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 26 | namespace android { |
| 27 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 28 | /* implementation of the client interface from the policy manager */ |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 29 | |
Mikhail Naganov | 1fba38c | 2023-05-03 17:45:36 -0700 | [diff] [blame] | 30 | status_t AudioPolicyService::AudioPolicyClient::getAudioPolicyConfig( |
| 31 | media::AudioPolicyConfig *config) |
| 32 | { |
| 33 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 34 | if (af == 0) { |
| 35 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 36 | return AUDIO_MODULE_HANDLE_NONE; |
| 37 | } |
| 38 | |
| 39 | return af->getAudioPolicyConfig(config); |
| 40 | } |
| 41 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 42 | audio_module_handle_t AudioPolicyService::AudioPolicyClient::loadHwModule(const char *name) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 43 | { |
| 44 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 45 | if (af == 0) { |
| 46 | ALOGW("%s: could not get AudioFlinger", __func__); |
Glenn Kasten | a13cde9 | 2016-03-28 15:26:02 -0700 | [diff] [blame] | 47 | return AUDIO_MODULE_HANDLE_NONE; |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 48 | } |
| 49 | |
| 50 | return af->loadHwModule(name); |
| 51 | } |
| 52 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 53 | status_t AudioPolicyService::AudioPolicyClient::openOutput(audio_module_handle_t module, |
| 54 | audio_io_handle_t *output, |
Eric Laurent | f1f22e7 | 2021-07-13 14:04:14 +0200 | [diff] [blame] | 55 | audio_config_t *halConfig, |
| 56 | audio_config_base_t *mixerConfig, |
jiabin | 4381040 | 2019-10-24 14:58:31 -0700 | [diff] [blame] | 57 | const sp<DeviceDescriptorBase>& device, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 58 | uint32_t *latencyMs, |
| 59 | audio_output_flags_t flags) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 60 | { |
| 61 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 62 | if (af == 0) { |
| 63 | ALOGW("%s: could not get AudioFlinger", __func__); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 64 | return PERMISSION_DENIED; |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 65 | } |
Ytai Ben-Tsvi | 50e016a | 2020-11-12 14:26:12 -0800 | [diff] [blame] | 66 | |
| 67 | media::OpenOutputRequest request; |
| 68 | media::OpenOutputResponse response; |
| 69 | |
| 70 | request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 71 | request.halConfig = VALUE_OR_RETURN_STATUS( |
| 72 | legacy2aidl_audio_config_t_AudioConfig(*halConfig, false /*isInput*/)); |
| 73 | request.mixerConfig = VALUE_OR_RETURN_STATUS( |
| 74 | legacy2aidl_audio_config_base_t_AudioConfigBase(*mixerConfig, false /*isInput*/)); |
Ytai Ben-Tsvi | 50e016a | 2020-11-12 14:26:12 -0800 | [diff] [blame] | 75 | request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_DeviceDescriptorBase(device)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 76 | request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_output_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 50e016a | 2020-11-12 14:26:12 -0800 | [diff] [blame] | 77 | |
| 78 | status_t status = af->openOutput(request, &response); |
| 79 | if (status == OK) { |
| 80 | *output = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_io_handle_t(response.output)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 81 | *halConfig = VALUE_OR_RETURN_STATUS( |
| 82 | aidl2legacy_AudioConfig_audio_config_t(response.config, false /*isInput*/)); |
Ytai Ben-Tsvi | 50e016a | 2020-11-12 14:26:12 -0800 | [diff] [blame] | 83 | *latencyMs = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(response.latencyMs)); |
Eric Laurent | 0d13fea | 2022-11-04 17:12:08 +0100 | [diff] [blame] | 84 | |
| 85 | audio_config_base_t config = {.sample_rate = halConfig->sample_rate, |
| 86 | .channel_mask = halConfig->channel_mask, |
| 87 | .format = halConfig->format, |
| 88 | }; |
| 89 | mAudioPolicyService->registerOutput(*output, config, flags); |
Ytai Ben-Tsvi | 50e016a | 2020-11-12 14:26:12 -0800 | [diff] [blame] | 90 | } |
| 91 | return status; |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 92 | } |
| 93 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 94 | audio_io_handle_t AudioPolicyService::AudioPolicyClient::openDuplicateOutput( |
| 95 | audio_io_handle_t output1, |
| 96 | audio_io_handle_t output2) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 97 | { |
| 98 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 99 | if (af == 0) { |
| 100 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 101 | return 0; |
| 102 | } |
| 103 | return af->openDuplicateOutput(output1, output2); |
| 104 | } |
| 105 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 106 | status_t AudioPolicyService::AudioPolicyClient::closeOutput(audio_io_handle_t output) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 107 | { |
| 108 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 109 | if (af == 0) { |
| 110 | return PERMISSION_DENIED; |
| 111 | } |
Eric Laurent | 0d13fea | 2022-11-04 17:12:08 +0100 | [diff] [blame] | 112 | mAudioPolicyService->unregisterOutput(output); |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 113 | return af->closeOutput(output); |
| 114 | } |
| 115 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 116 | status_t AudioPolicyService::AudioPolicyClient::suspendOutput(audio_io_handle_t output) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 117 | { |
| 118 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 119 | if (af == 0) { |
| 120 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 121 | return PERMISSION_DENIED; |
| 122 | } |
| 123 | |
| 124 | return af->suspendOutput(output); |
| 125 | } |
| 126 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 127 | status_t AudioPolicyService::AudioPolicyClient::restoreOutput(audio_io_handle_t output) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 128 | { |
| 129 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 130 | if (af == 0) { |
| 131 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 132 | return PERMISSION_DENIED; |
| 133 | } |
| 134 | |
| 135 | return af->restoreOutput(output); |
| 136 | } |
| 137 | |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 138 | status_t AudioPolicyService::AudioPolicyClient::openInput(audio_module_handle_t module, |
| 139 | audio_io_handle_t *input, |
| 140 | audio_config_t *config, |
| 141 | audio_devices_t *device, |
| 142 | const String8& address, |
| 143 | audio_source_t source, |
| 144 | audio_input_flags_t flags) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 145 | { |
| 146 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 147 | if (af == 0) { |
| 148 | ALOGW("%s: could not get AudioFlinger", __func__); |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 149 | return PERMISSION_DENIED; |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 150 | } |
| 151 | |
Ytai Ben-Tsvi | 12a0b84 | 2020-11-05 13:47:32 -0800 | [diff] [blame] | 152 | AudioDeviceTypeAddr deviceTypeAddr(*device, address.c_str()); |
| 153 | |
| 154 | media::OpenInputRequest request; |
| 155 | request.module = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_module_handle_t_int32_t(module)); |
| 156 | request.input = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(*input)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 157 | request.config = VALUE_OR_RETURN_STATUS( |
| 158 | legacy2aidl_audio_config_t_AudioConfig(*config, true /*isInput*/)); |
Ytai Ben-Tsvi | 12a0b84 | 2020-11-05 13:47:32 -0800 | [diff] [blame] | 159 | request.device = VALUE_OR_RETURN_STATUS(legacy2aidl_AudioDeviceTypeAddress(deviceTypeAddr)); |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 160 | request.source = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_source_t_AudioSource(source)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 161 | request.flags = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_input_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 12a0b84 | 2020-11-05 13:47:32 -0800 | [diff] [blame] | 162 | |
| 163 | media::OpenInputResponse response; |
| 164 | status_t status = af->openInput(request, &response); |
| 165 | if (status == OK) { |
| 166 | *input = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_module_handle_t(response.input)); |
| 167 | } |
| 168 | return status; |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 169 | } |
| 170 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 171 | status_t AudioPolicyService::AudioPolicyClient::closeInput(audio_io_handle_t input) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 172 | { |
| 173 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 174 | if (af == 0) { |
| 175 | return PERMISSION_DENIED; |
| 176 | } |
| 177 | |
| 178 | return af->closeInput(input); |
| 179 | } |
| 180 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 181 | status_t AudioPolicyService::AudioPolicyClient::setStreamVolume(audio_stream_type_t stream, |
| 182 | float volume, audio_io_handle_t output, |
| 183 | int delay_ms) |
| 184 | { |
| 185 | return mAudioPolicyService->setStreamVolume(stream, volume, output, |
| 186 | delay_ms); |
| 187 | } |
| 188 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 189 | void AudioPolicyService::AudioPolicyClient::setParameters(audio_io_handle_t io_handle, |
| 190 | const String8& keyValuePairs, |
| 191 | int delay_ms) |
| 192 | { |
Tomasz Wasilczyk | 8f36f6e | 2023-08-15 20:59:35 +0000 | [diff] [blame] | 193 | mAudioPolicyService->setParameters(io_handle, keyValuePairs.c_str(), delay_ms); |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 194 | } |
| 195 | |
| 196 | String8 AudioPolicyService::AudioPolicyClient::getParameters(audio_io_handle_t io_handle, |
| 197 | const String8& keys) |
| 198 | { |
| 199 | String8 result = AudioSystem::getParameters(io_handle, keys); |
| 200 | return result; |
| 201 | } |
| 202 | |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 203 | status_t AudioPolicyService::AudioPolicyClient::setVoiceVolume(float volume, int delay_ms) |
| 204 | { |
| 205 | return mAudioPolicyService->setVoiceVolume(volume, delay_ms); |
| 206 | } |
| 207 | |
Glenn Kasten | d848eb4 | 2016-03-08 13:42:11 -0800 | [diff] [blame] | 208 | status_t AudioPolicyService::AudioPolicyClient::moveEffects(audio_session_t session, |
Eric Laurent | dce54a1 | 2014-03-10 12:19:46 -0700 | [diff] [blame] | 209 | audio_io_handle_t src_output, |
| 210 | audio_io_handle_t dst_output) |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 211 | { |
| 212 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 213 | if (af == 0) { |
| 214 | return PERMISSION_DENIED; |
| 215 | } |
| 216 | |
| 217 | return af->moveEffects(session, src_output, dst_output); |
| 218 | } |
| 219 | |
Eric Laurent | b20cf7d | 2019-04-05 19:37:34 -0700 | [diff] [blame] | 220 | void AudioPolicyService::AudioPolicyClient::setEffectSuspended(int effectId, |
| 221 | audio_session_t sessionId, |
| 222 | bool suspended) |
| 223 | { |
| 224 | mAudioPolicyService->setEffectSuspended(effectId, sessionId, suspended); |
| 225 | } |
| 226 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 227 | status_t AudioPolicyService::AudioPolicyClient::createAudioPatch(const struct audio_patch *patch, |
| 228 | audio_patch_handle_t *handle, |
| 229 | int delayMs) |
| 230 | { |
| 231 | return mAudioPolicyService->clientCreateAudioPatch(patch, handle, delayMs); |
| 232 | } |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 233 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 234 | status_t AudioPolicyService::AudioPolicyClient::releaseAudioPatch(audio_patch_handle_t handle, |
| 235 | int delayMs) |
| 236 | { |
| 237 | return mAudioPolicyService->clientReleaseAudioPatch(handle, delayMs); |
| 238 | } |
Eric Laurent | 2d388ec | 2014-03-07 13:25:54 -0800 | [diff] [blame] | 239 | |
Eric Laurent | e1715a4 | 2014-05-20 11:30:42 -0700 | [diff] [blame] | 240 | status_t AudioPolicyService::AudioPolicyClient::setAudioPortConfig( |
| 241 | const struct audio_port_config *config, |
| 242 | int delayMs) |
| 243 | { |
| 244 | return mAudioPolicyService->clientSetAudioPortConfig(config, delayMs); |
| 245 | } |
| 246 | |
Eric Laurent | b52c152 | 2014-05-20 11:27:36 -0700 | [diff] [blame] | 247 | void AudioPolicyService::AudioPolicyClient::onAudioPortListUpdate() |
| 248 | { |
| 249 | mAudioPolicyService->onAudioPortListUpdate(); |
| 250 | } |
| 251 | |
| 252 | void AudioPolicyService::AudioPolicyClient::onAudioPatchListUpdate() |
| 253 | { |
| 254 | mAudioPolicyService->onAudioPatchListUpdate(); |
| 255 | } |
| 256 | |
Jean-Michel Trivi | de80105 | 2015-04-14 19:10:14 -0700 | [diff] [blame] | 257 | void AudioPolicyService::AudioPolicyClient::onDynamicPolicyMixStateUpdate( |
| 258 | String8 regId, int32_t state) |
| 259 | { |
| 260 | mAudioPolicyService->onDynamicPolicyMixStateUpdate(regId, state); |
| 261 | } |
| 262 | |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 263 | void AudioPolicyService::AudioPolicyClient::onRecordingConfigurationUpdate( |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 264 | int event, |
| 265 | const record_client_info_t *clientInfo, |
| 266 | const audio_config_base_t *clientConfig, |
| 267 | std::vector<effect_descriptor_t> clientEffects, |
| 268 | const audio_config_base_t *deviceConfig, |
| 269 | std::vector<effect_descriptor_t> effects, |
| 270 | audio_patch_handle_t patchHandle, |
| 271 | audio_source_t source) |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 272 | { |
Jean-Michel Trivi | ac4e429 | 2016-12-22 11:39:31 -0800 | [diff] [blame] | 273 | mAudioPolicyService->onRecordingConfigurationUpdate(event, clientInfo, |
Eric Laurent | a9f8665 | 2018-11-28 17:23:11 -0800 | [diff] [blame] | 274 | clientConfig, clientEffects, deviceConfig, effects, patchHandle, source); |
Jean-Michel Trivi | 2f4fe9f | 2015-12-04 16:20:59 -0800 | [diff] [blame] | 275 | } |
| 276 | |
François Gaffie | cfe1732 | 2018-11-07 13:41:29 +0100 | [diff] [blame] | 277 | void AudioPolicyService::AudioPolicyClient::onAudioVolumeGroupChanged(volume_group_t group, |
| 278 | int flags) |
| 279 | { |
| 280 | mAudioPolicyService->onAudioVolumeGroupChanged(group, flags); |
| 281 | } |
| 282 | |
Jean-Michel Trivi | 9a6b9ad | 2020-10-22 16:46:43 -0700 | [diff] [blame] | 283 | void AudioPolicyService::AudioPolicyClient::onRoutingUpdated() |
| 284 | { |
| 285 | mAudioPolicyService->onRoutingUpdated(); |
| 286 | } |
| 287 | |
Jean-Michel Trivi | 78f2b30 | 2022-04-15 18:18:41 +0000 | [diff] [blame] | 288 | void AudioPolicyService::AudioPolicyClient::onVolumeRangeInitRequest() |
| 289 | { |
| 290 | mAudioPolicyService->onVolumeRangeInitRequest(); |
| 291 | } |
| 292 | |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 293 | audio_unique_id_t AudioPolicyService::AudioPolicyClient::newAudioUniqueId(audio_unique_id_use_t use) |
Eric Laurent | de3f839 | 2014-07-27 18:38:22 -0700 | [diff] [blame] | 294 | { |
Glenn Kasten | eeecb98 | 2016-02-26 10:44:04 -0800 | [diff] [blame] | 295 | return AudioSystem::newAudioUniqueId(use); |
Eric Laurent | de3f839 | 2014-07-27 18:38:22 -0700 | [diff] [blame] | 296 | } |
| 297 | |
Ytai Ben-Tsvi | 1ef846b | 2020-03-26 09:41:15 -0700 | [diff] [blame] | 298 | void AudioPolicyService::AudioPolicyClient::setSoundTriggerCaptureState(bool active) |
| 299 | { |
| 300 | mAudioPolicyService->mCaptureStateNotifier.setCaptureState(active); |
Ytai Ben-Tsvi | 74cd6b0 | 2019-10-25 10:06:40 -0700 | [diff] [blame] | 301 | } |
| 302 | |
jiabin | b4fed19 | 2020-09-22 14:45:40 -0700 | [diff] [blame] | 303 | status_t AudioPolicyService::AudioPolicyClient::getAudioPort(struct audio_port_v7 *port) |
| 304 | { |
| 305 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 306 | if (af == 0) { |
| 307 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 308 | return PERMISSION_DENIED; |
| 309 | } |
| 310 | return af->getAudioPort(port); |
| 311 | } |
| 312 | |
jiabin | f042b9b | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 313 | status_t AudioPolicyService::AudioPolicyClient::updateSecondaryOutputs( |
| 314 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 315 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 316 | if (af == nullptr) { |
| 317 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 318 | return PERMISSION_DENIED; |
| 319 | } |
| 320 | return af->updateSecondaryOutputs(trackSecondaryOutputs); |
| 321 | } |
| 322 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 323 | status_t AudioPolicyService::AudioPolicyClient::setDeviceConnectedState( |
jiabin | 872de70 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 324 | const struct audio_port_v7 *port, media::DeviceConnectedState state) { |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 325 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 326 | if (af == nullptr) { |
| 327 | ALOGW("%s: could not get AudioFlinger", __func__); |
| 328 | return PERMISSION_DENIED; |
| 329 | } |
jiabin | 872de70 | 2023-04-27 22:04:31 +0000 | [diff] [blame] | 330 | return af->setDeviceConnectedState(port, state); |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 331 | } |
| 332 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 333 | status_t AudioPolicyService::AudioPolicyClient::invalidateTracks( |
| 334 | const std::vector<audio_port_handle_t>& portIds) { |
| 335 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 336 | if (af == 0) { |
| 337 | return PERMISSION_DENIED; |
| 338 | } |
| 339 | |
| 340 | return af->invalidateTracks(portIds); |
| 341 | } |
| 342 | |
jiabin | 12537fc | 2023-10-12 17:56:08 +0000 | [diff] [blame] | 343 | status_t AudioPolicyService::AudioPolicyClient::getAudioMixPort( |
| 344 | const struct audio_port_v7 *devicePort, |
| 345 | struct audio_port_v7 *port) { |
| 346 | sp<IAudioFlinger> af = AudioSystem::get_audio_flinger(); |
| 347 | if (af == 0) { |
| 348 | return PERMISSION_DENIED; |
| 349 | } |
| 350 | return af->getAudioMixPort(devicePort, port); |
| 351 | } |
| 352 | |
Mikhail Naganov | 1b2a794 | 2017-12-08 10:18:09 -0800 | [diff] [blame] | 353 | } // namespace android |