Marco Nelissen | 3a34bef | 2011-08-02 13:33:41 -0700 | [diff] [blame] | 1 | /* |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 2 | ** |
| 3 | ** Copyright 2007, The Android Open Source Project |
| 4 | ** |
| 5 | ** Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | ** you may not use this file except in compliance with the License. |
| 7 | ** You may obtain a copy of the License at |
| 8 | ** |
| 9 | ** http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | ** |
| 11 | ** Unless required by applicable law or agreed to in writing, software |
| 12 | ** distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | ** See the License for the specific language governing permissions and |
| 15 | ** limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | #define LOG_TAG "IAudioFlinger" |
Eric Laurent | c2f1f07 | 2009-07-17 12:17:14 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 20 | |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | #include <utils/Log.h> |
| 22 | |
| 23 | #include <stdint.h> |
| 24 | #include <sys/types.h> |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 25 | #include "IAudioFlinger.h" |
Eric Laurent | b1cc36b | 2017-12-11 12:14:16 -0800 | [diff] [blame] | 26 | #include <binder/IPCThreadState.h> |
Mathias Agopian | 7562408 | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 27 | #include <binder/Parcel.h> |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 28 | #include <system/thread_defs.h> |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 29 | |
| 30 | namespace android { |
| 31 | |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 32 | using aidl_utils::statusTFromBinderStatus; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 33 | using binder::Status; |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 34 | using media::audio::common::AudioChannelLayout; |
| 35 | using media::audio::common::AudioFormatDescription; |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 36 | using media::audio::common::AudioMMapPolicyInfo; |
| 37 | using media::audio::common::AudioMMapPolicyType; |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 38 | using media::audio::common::AudioMode; |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 39 | using media::audio::common::AudioStreamType; |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 40 | using media::audio::common::AudioUuid; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 41 | |
Eric Laurent | f75c2fe | 2015-04-02 13:49:15 -0700 | [diff] [blame] | 42 | #define MAX_ITEMS_PER_LIST 1024 |
| 43 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 44 | #define VALUE_OR_RETURN_BINDER(x) \ |
| 45 | ({ \ |
| 46 | auto _tmp = (x); \ |
| 47 | if (!_tmp.ok()) return Status::fromStatusT(_tmp.error()); \ |
| 48 | std::move(_tmp.value()); \ |
| 49 | }) |
| 50 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 51 | #define RETURN_BINDER_IF_ERROR(x) \ |
| 52 | { \ |
| 53 | auto _tmp = (x); \ |
| 54 | if (_tmp != OK) return Status::fromStatusT(_tmp); \ |
| 55 | } |
| 56 | |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 57 | ConversionResult<media::CreateTrackRequest> IAudioFlinger::CreateTrackInput::toAidl() const { |
| 58 | media::CreateTrackRequest aidl; |
| 59 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 60 | // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks. |
| 61 | aidl.config = VALUE_OR_RETURN(legacy2aidl_audio_config_t_AudioConfig( |
| 62 | config, false /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 63 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 64 | aidl.sharedBuffer = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(sharedBuffer)); |
| 65 | aidl.notificationsPerBuffer = VALUE_OR_RETURN(convertIntegral<int32_t>(notificationsPerBuffer)); |
| 66 | aidl.speed = speed; |
| 67 | aidl.audioTrackCallback = audioTrackCallback; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 68 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 69 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 70 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 71 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 72 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 73 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 74 | return aidl; |
| 75 | } |
| 76 | |
| 77 | ConversionResult<IAudioFlinger::CreateTrackInput> |
| 78 | IAudioFlinger::CreateTrackInput::fromAidl(const media::CreateTrackRequest& aidl) { |
| 79 | IAudioFlinger::CreateTrackInput legacy; |
| 80 | legacy.attr = VALUE_OR_RETURN(aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 81 | // Do not be mislead by 'Input'--this is an input to 'createTrack', which creates output tracks. |
| 82 | legacy.config = VALUE_OR_RETURN( |
| 83 | aidl2legacy_AudioConfig_audio_config_t(aidl.config, false /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 84 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 85 | legacy.sharedBuffer = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.sharedBuffer)); |
| 86 | legacy.notificationsPerBuffer = VALUE_OR_RETURN( |
| 87 | convertIntegral<uint32_t>(aidl.notificationsPerBuffer)); |
| 88 | legacy.speed = aidl.speed; |
| 89 | legacy.audioTrackCallback = aidl.audioTrackCallback; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 90 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_output_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 91 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 92 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 93 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 94 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 95 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 96 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 97 | return legacy; |
| 98 | } |
| 99 | |
| 100 | ConversionResult<media::CreateTrackResponse> |
| 101 | IAudioFlinger::CreateTrackOutput::toAidl() const { |
| 102 | media::CreateTrackResponse aidl; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 103 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_output_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 104 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 105 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 106 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 107 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 108 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 109 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
Andy Hung | a2159aa | 2021-07-20 13:01:52 -0700 | [diff] [blame] | 110 | aidl.streamType = VALUE_OR_RETURN( |
| 111 | legacy2aidl_audio_stream_type_t_AudioStreamType(streamType)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 112 | aidl.afFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(afFrameCount)); |
| 113 | aidl.afSampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(afSampleRate)); |
| 114 | aidl.afLatencyMs = VALUE_OR_RETURN(convertIntegral<int32_t>(afLatencyMs)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 115 | aidl.afChannelMask = VALUE_OR_RETURN( |
| 116 | legacy2aidl_audio_channel_mask_t_AudioChannelLayout(afChannelMask, false /*isInput*/)); |
| 117 | aidl.afFormat = VALUE_OR_RETURN( |
| 118 | legacy2aidl_audio_format_t_AudioFormatDescription(afFormat)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 119 | aidl.outputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(outputId)); |
| 120 | aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 121 | aidl.audioTrack = audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 122 | return aidl; |
| 123 | } |
| 124 | |
| 125 | ConversionResult<IAudioFlinger::CreateTrackOutput> |
| 126 | IAudioFlinger::CreateTrackOutput::fromAidl( |
| 127 | const media::CreateTrackResponse& aidl) { |
| 128 | IAudioFlinger::CreateTrackOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 129 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_output_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 130 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 131 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 132 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 133 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 134 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 135 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 136 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
Andy Hung | a2159aa | 2021-07-20 13:01:52 -0700 | [diff] [blame] | 137 | legacy.streamType = VALUE_OR_RETURN( |
| 138 | aidl2legacy_AudioStreamType_audio_stream_type_t(aidl.streamType)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 139 | legacy.afFrameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.afFrameCount)); |
| 140 | legacy.afSampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afSampleRate)); |
| 141 | legacy.afLatencyMs = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.afLatencyMs)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 142 | legacy.afChannelMask = VALUE_OR_RETURN( |
| 143 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(aidl.afChannelMask, |
| 144 | false /*isInput*/)); |
| 145 | legacy.afFormat = VALUE_OR_RETURN( |
| 146 | aidl2legacy_AudioFormatDescription_audio_format_t(aidl.afFormat)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 147 | legacy.outputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.outputId)); |
| 148 | legacy.portId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 149 | legacy.audioTrack = aidl.audioTrack; |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 150 | return legacy; |
| 151 | } |
| 152 | |
| 153 | ConversionResult<media::CreateRecordRequest> |
| 154 | IAudioFlinger::CreateRecordInput::toAidl() const { |
| 155 | media::CreateRecordRequest aidl; |
| 156 | aidl.attr = VALUE_OR_RETURN(legacy2aidl_audio_attributes_t_AudioAttributesInternal(attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 157 | aidl.config = VALUE_OR_RETURN( |
| 158 | legacy2aidl_audio_config_base_t_AudioConfigBase(config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 159 | aidl.clientInfo = VALUE_OR_RETURN(legacy2aidl_AudioClient_AudioClient(clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 160 | aidl.riid = VALUE_OR_RETURN(legacy2aidl_audio_unique_id_t_int32_t(riid)); |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 161 | aidl.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 162 | convertIntegral<int32_t>(maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 163 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 164 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 165 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 166 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 167 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 168 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 169 | return aidl; |
| 170 | } |
| 171 | |
| 172 | ConversionResult<IAudioFlinger::CreateRecordInput> |
| 173 | IAudioFlinger::CreateRecordInput::fromAidl( |
| 174 | const media::CreateRecordRequest& aidl) { |
| 175 | IAudioFlinger::CreateRecordInput legacy; |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 176 | legacy.attr = VALUE_OR_RETURN( |
| 177 | aidl2legacy_AudioAttributesInternal_audio_attributes_t(aidl.attr)); |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 178 | legacy.config = VALUE_OR_RETURN( |
| 179 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.config, true /*isInput*/)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 180 | legacy.clientInfo = VALUE_OR_RETURN(aidl2legacy_AudioClient_AudioClient(aidl.clientInfo)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 181 | legacy.riid = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_unique_id_t(aidl.riid)); |
Eric Laurent | ec376dc | 2021-04-08 20:41:22 +0200 | [diff] [blame] | 182 | legacy.maxSharedAudioHistoryMs = VALUE_OR_RETURN( |
| 183 | convertIntegral<int32_t>(aidl.maxSharedAudioHistoryMs)); |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 184 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_input_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 185 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 186 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 187 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 188 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 189 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 190 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 191 | return legacy; |
| 192 | } |
| 193 | |
| 194 | ConversionResult<media::CreateRecordResponse> |
| 195 | IAudioFlinger::CreateRecordOutput::toAidl() const { |
| 196 | media::CreateRecordResponse aidl; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 197 | aidl.flags = VALUE_OR_RETURN(legacy2aidl_audio_input_flags_t_int32_t_mask(flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 198 | aidl.frameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(frameCount)); |
| 199 | aidl.notificationFrameCount = VALUE_OR_RETURN(convertIntegral<int64_t>(notificationFrameCount)); |
| 200 | aidl.selectedDeviceId = VALUE_OR_RETURN( |
| 201 | legacy2aidl_audio_port_handle_t_int32_t(selectedDeviceId)); |
| 202 | aidl.sessionId = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 203 | aidl.sampleRate = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
| 204 | aidl.inputId = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(inputId)); |
| 205 | aidl.cblk = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(cblk)); |
| 206 | aidl.buffers = VALUE_OR_RETURN(legacy2aidl_NullableIMemory_SharedFileRegion(buffers)); |
| 207 | aidl.portId = VALUE_OR_RETURN(legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 208 | aidl.audioRecord = audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 209 | aidl.serverConfig = VALUE_OR_RETURN( |
| 210 | legacy2aidl_audio_config_base_t_AudioConfigBase(serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 211 | aidl.halConfig = VALUE_OR_RETURN( |
| 212 | legacy2aidl_audio_config_base_t_AudioConfigBase(halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 213 | return aidl; |
| 214 | } |
| 215 | |
| 216 | ConversionResult<IAudioFlinger::CreateRecordOutput> |
| 217 | IAudioFlinger::CreateRecordOutput::fromAidl( |
| 218 | const media::CreateRecordResponse& aidl) { |
| 219 | IAudioFlinger::CreateRecordOutput legacy; |
Andy Hung | 973638a | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 220 | legacy.flags = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_input_flags_t_mask(aidl.flags)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 221 | legacy.frameCount = VALUE_OR_RETURN(convertIntegral<size_t>(aidl.frameCount)); |
| 222 | legacy.notificationFrameCount = VALUE_OR_RETURN( |
| 223 | convertIntegral<size_t>(aidl.notificationFrameCount)); |
| 224 | legacy.selectedDeviceId = VALUE_OR_RETURN( |
| 225 | aidl2legacy_int32_t_audio_port_handle_t(aidl.selectedDeviceId)); |
| 226 | legacy.sessionId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_session_t(aidl.sessionId)); |
| 227 | legacy.sampleRate = VALUE_OR_RETURN(convertIntegral<uint32_t>(aidl.sampleRate)); |
| 228 | legacy.inputId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_io_handle_t(aidl.inputId)); |
| 229 | legacy.cblk = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.cblk)); |
| 230 | legacy.buffers = VALUE_OR_RETURN(aidl2legacy_NullableSharedFileRegion_IMemory(aidl.buffers)); |
| 231 | legacy.portId = VALUE_OR_RETURN(aidl2legacy_int32_t_audio_port_handle_t(aidl.portId)); |
Ytai Ben-Tsvi | 16d8761 | 2020-11-03 16:32:36 -0800 | [diff] [blame] | 232 | legacy.audioRecord = aidl.audioRecord; |
jiabin | b00edc3 | 2021-08-16 16:27:54 +0000 | [diff] [blame] | 233 | legacy.serverConfig = VALUE_OR_RETURN( |
| 234 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.serverConfig, true /*isInput*/)); |
Robert Wu | 310037a | 2022-09-06 21:48:18 +0000 | [diff] [blame] | 235 | legacy.halConfig = VALUE_OR_RETURN( |
| 236 | aidl2legacy_AudioConfigBase_audio_config_base_t(aidl.halConfig, true /*isInput*/)); |
Ytai Ben-Tsvi | 4dfeb62 | 2020-11-02 12:47:30 -0800 | [diff] [blame] | 237 | return legacy; |
| 238 | } |
Eric Laurent | 42896a0 | 2019-09-27 15:40:33 -0700 | [diff] [blame] | 239 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 240 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 241 | // AudioFlingerClientAdapter |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 242 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 243 | AudioFlingerClientAdapter::AudioFlingerClientAdapter( |
| 244 | const sp<media::IAudioFlingerService> delegate) : mDelegate(delegate) {} |
Eric Laurent | 21da647 | 2017-11-09 16:29:26 -0800 | [diff] [blame] | 245 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 246 | status_t AudioFlingerClientAdapter::createTrack(const media::CreateTrackRequest& input, |
| 247 | media::CreateTrackResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 248 | return statusTFromBinderStatus(mDelegate->createTrack(input, &output)); |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 249 | } |
| 250 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 251 | status_t AudioFlingerClientAdapter::createRecord(const media::CreateRecordRequest& input, |
| 252 | media::CreateRecordResponse& output) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 253 | return statusTFromBinderStatus(mDelegate->createRecord(input, &output)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | uint32_t AudioFlingerClientAdapter::sampleRate(audio_io_handle_t ioHandle) const { |
| 257 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 258 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 259 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 260 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->sampleRate(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 261 | return convertIntegral<uint32_t>(aidlRet); |
| 262 | }(); |
| 263 | // Failure is ignored. |
| 264 | return result.value_or(0); |
| 265 | } |
| 266 | |
| 267 | audio_format_t AudioFlingerClientAdapter::format(audio_io_handle_t output) const { |
| 268 | auto result = [&]() -> ConversionResult<audio_format_t> { |
| 269 | int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 270 | AudioFormatDescription aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 271 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->format(outputAidl, &aidlRet))); |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 272 | return aidl2legacy_AudioFormatDescription_audio_format_t(aidlRet); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 273 | }(); |
| 274 | return result.value_or(AUDIO_FORMAT_INVALID); |
| 275 | } |
| 276 | |
| 277 | size_t AudioFlingerClientAdapter::frameCount(audio_io_handle_t ioHandle) const { |
| 278 | auto result = [&]() -> ConversionResult<size_t> { |
| 279 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 280 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 281 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->frameCount(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 282 | return convertIntegral<size_t>(aidlRet); |
| 283 | }(); |
| 284 | // Failure is ignored. |
| 285 | return result.value_or(0); |
| 286 | } |
| 287 | |
| 288 | uint32_t AudioFlingerClientAdapter::latency(audio_io_handle_t output) const { |
| 289 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 290 | int32_t outputAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 291 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 292 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->latency(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 293 | return convertIntegral<uint32_t>(aidlRet); |
| 294 | }(); |
| 295 | // Failure is ignored. |
| 296 | return result.value_or(0); |
| 297 | } |
| 298 | |
| 299 | status_t AudioFlingerClientAdapter::setMasterVolume(float value) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 300 | return statusTFromBinderStatus(mDelegate->setMasterVolume(value)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 301 | } |
| 302 | |
| 303 | status_t AudioFlingerClientAdapter::setMasterMute(bool muted) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 304 | return statusTFromBinderStatus(mDelegate->setMasterMute(muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | float AudioFlingerClientAdapter::masterVolume() const { |
| 308 | auto result = [&]() -> ConversionResult<float> { |
| 309 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 310 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterVolume(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 311 | return aidlRet; |
| 312 | }(); |
| 313 | // Failure is ignored. |
| 314 | return result.value_or(0.f); |
| 315 | } |
| 316 | |
| 317 | bool AudioFlingerClientAdapter::masterMute() const { |
| 318 | auto result = [&]() -> ConversionResult<bool> { |
| 319 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 320 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->masterMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 321 | return aidlRet; |
| 322 | }(); |
| 323 | // Failure is ignored. |
| 324 | return result.value_or(false); |
| 325 | } |
| 326 | |
| 327 | status_t AudioFlingerClientAdapter::setMasterBalance(float balance) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 328 | return statusTFromBinderStatus(mDelegate->setMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | status_t AudioFlingerClientAdapter::getMasterBalance(float* balance) const{ |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 332 | return statusTFromBinderStatus(mDelegate->getMasterBalance(balance)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | status_t AudioFlingerClientAdapter::setStreamVolume(audio_stream_type_t stream, float value, |
| 336 | audio_io_handle_t output) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 337 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 338 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 339 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 340 | return statusTFromBinderStatus(mDelegate->setStreamVolume(streamAidl, value, outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | status_t AudioFlingerClientAdapter::setStreamMute(audio_stream_type_t stream, bool muted) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 344 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 345 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 346 | return statusTFromBinderStatus(mDelegate->setStreamMute(streamAidl, muted)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 347 | } |
| 348 | |
| 349 | float AudioFlingerClientAdapter::streamVolume(audio_stream_type_t stream, |
| 350 | audio_io_handle_t output) const { |
| 351 | auto result = [&]() -> ConversionResult<float> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 352 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 353 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 354 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 355 | float aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 356 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 357 | mDelegate->streamVolume(streamAidl, outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 358 | return aidlRet; |
| 359 | }(); |
| 360 | // Failure is ignored. |
| 361 | return result.value_or(0.f); |
| 362 | } |
| 363 | |
| 364 | bool AudioFlingerClientAdapter::streamMute(audio_stream_type_t stream) const { |
| 365 | auto result = [&]() -> ConversionResult<bool> { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 366 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 367 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
| 368 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 369 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 370 | mDelegate->streamMute(streamAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 371 | return aidlRet; |
| 372 | }(); |
| 373 | // Failure is ignored. |
| 374 | return result.value_or(false); |
| 375 | } |
| 376 | |
| 377 | status_t AudioFlingerClientAdapter::setMode(audio_mode_t mode) { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 378 | AudioMode modeAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_mode_t_AudioMode(mode)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 379 | return statusTFromBinderStatus(mDelegate->setMode(modeAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | status_t AudioFlingerClientAdapter::setMicMute(bool state) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 383 | return statusTFromBinderStatus(mDelegate->setMicMute(state)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | bool AudioFlingerClientAdapter::getMicMute() const { |
| 387 | auto result = [&]() -> ConversionResult<bool> { |
| 388 | bool aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 389 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 390 | mDelegate->getMicMute(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 391 | return aidlRet; |
| 392 | }(); |
| 393 | // Failure is ignored. |
| 394 | return result.value_or(false); |
| 395 | } |
| 396 | |
| 397 | void AudioFlingerClientAdapter::setRecordSilenced(audio_port_handle_t portId, bool silenced) { |
| 398 | auto result = [&]() -> status_t { |
| 399 | int32_t portIdAidl = VALUE_OR_RETURN_STATUS( |
| 400 | legacy2aidl_audio_port_handle_t_int32_t(portId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 401 | return statusTFromBinderStatus(mDelegate->setRecordSilenced(portIdAidl, silenced)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 402 | }(); |
| 403 | // Failure is ignored. |
| 404 | (void) result; |
| 405 | } |
| 406 | |
| 407 | status_t AudioFlingerClientAdapter::setParameters(audio_io_handle_t ioHandle, |
| 408 | const String8& keyValuePairs) { |
| 409 | int32_t ioHandleAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 410 | std::string keyValuePairsAidl = VALUE_OR_RETURN_STATUS( |
| 411 | legacy2aidl_String8_string(keyValuePairs)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 412 | return statusTFromBinderStatus(mDelegate->setParameters(ioHandleAidl, keyValuePairsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | String8 AudioFlingerClientAdapter::getParameters(audio_io_handle_t ioHandle, const String8& keys) |
| 416 | const { |
| 417 | auto result = [&]() -> ConversionResult<String8> { |
| 418 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 419 | std::string keysAidl = VALUE_OR_RETURN(legacy2aidl_String8_string(keys)); |
| 420 | std::string aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 421 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 422 | mDelegate->getParameters(ioHandleAidl, keysAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 423 | return aidl2legacy_string_view_String8(aidlRet); |
| 424 | }(); |
| 425 | // Failure is ignored. |
| 426 | return result.value_or(String8()); |
| 427 | } |
| 428 | |
| 429 | void AudioFlingerClientAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 430 | mDelegate->registerClient(client); |
| 431 | // Failure is ignored. |
| 432 | } |
| 433 | |
| 434 | size_t AudioFlingerClientAdapter::getInputBufferSize(uint32_t sampleRate, audio_format_t format, |
| 435 | audio_channel_mask_t channelMask) const { |
| 436 | auto result = [&]() -> ConversionResult<size_t> { |
| 437 | int32_t sampleRateAidl = VALUE_OR_RETURN(convertIntegral<int32_t>(sampleRate)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 438 | AudioFormatDescription formatAidl = VALUE_OR_RETURN( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 439 | legacy2aidl_audio_format_t_AudioFormatDescription(format)); |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 440 | AudioChannelLayout channelMaskAidl = VALUE_OR_RETURN( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 441 | legacy2aidl_audio_channel_mask_t_AudioChannelLayout(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 442 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 443 | RETURN_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 444 | mDelegate->getInputBufferSize(sampleRateAidl, formatAidl, channelMaskAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 445 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 446 | return convertIntegral<size_t>(aidlRet); |
| 447 | }(); |
| 448 | // Failure is ignored. |
| 449 | return result.value_or(0); |
| 450 | } |
| 451 | |
| 452 | status_t AudioFlingerClientAdapter::openOutput(const media::OpenOutputRequest& request, |
| 453 | media::OpenOutputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 454 | return statusTFromBinderStatus(mDelegate->openOutput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 455 | } |
| 456 | |
| 457 | audio_io_handle_t AudioFlingerClientAdapter::openDuplicateOutput(audio_io_handle_t output1, |
| 458 | audio_io_handle_t output2) { |
| 459 | auto result = [&]() -> ConversionResult<audio_io_handle_t> { |
| 460 | int32_t output1Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output1)); |
| 461 | int32_t output2Aidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(output2)); |
| 462 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 463 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 464 | mDelegate->openDuplicateOutput(output1Aidl, output2Aidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 465 | return aidl2legacy_int32_t_audio_io_handle_t(aidlRet); |
| 466 | }(); |
| 467 | // Failure is ignored. |
| 468 | return result.value_or(0); |
| 469 | } |
| 470 | |
| 471 | status_t AudioFlingerClientAdapter::closeOutput(audio_io_handle_t output) { |
| 472 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 473 | return statusTFromBinderStatus(mDelegate->closeOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 474 | } |
| 475 | |
| 476 | status_t AudioFlingerClientAdapter::suspendOutput(audio_io_handle_t output) { |
| 477 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 478 | return statusTFromBinderStatus(mDelegate->suspendOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 479 | } |
| 480 | |
| 481 | status_t AudioFlingerClientAdapter::restoreOutput(audio_io_handle_t output) { |
| 482 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 483 | return statusTFromBinderStatus(mDelegate->restoreOutput(outputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | status_t AudioFlingerClientAdapter::openInput(const media::OpenInputRequest& request, |
| 487 | media::OpenInputResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 488 | return statusTFromBinderStatus(mDelegate->openInput(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 489 | } |
| 490 | |
| 491 | status_t AudioFlingerClientAdapter::closeInput(audio_io_handle_t input) { |
| 492 | int32_t inputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(input)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 493 | return statusTFromBinderStatus(mDelegate->closeInput(inputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 494 | } |
| 495 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 496 | status_t AudioFlingerClientAdapter::setVoiceVolume(float volume) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 497 | return statusTFromBinderStatus(mDelegate->setVoiceVolume(volume)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | status_t AudioFlingerClientAdapter::getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames, |
| 501 | audio_io_handle_t output) const { |
| 502 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 503 | media::RenderPosition aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 504 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 505 | mDelegate->getRenderPosition(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 506 | if (halFrames != nullptr) { |
| 507 | *halFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.halFrames)); |
| 508 | } |
| 509 | if (dspFrames != nullptr) { |
| 510 | *dspFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.dspFrames)); |
| 511 | } |
| 512 | return OK; |
| 513 | } |
| 514 | |
| 515 | uint32_t AudioFlingerClientAdapter::getInputFramesLost(audio_io_handle_t ioHandle) const { |
| 516 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 517 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 518 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 519 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 520 | mDelegate->getInputFramesLost(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 521 | return convertIntegral<uint32_t>(aidlRet); |
| 522 | }(); |
| 523 | // Failure is ignored. |
| 524 | return result.value_or(0); |
| 525 | } |
| 526 | |
| 527 | audio_unique_id_t AudioFlingerClientAdapter::newAudioUniqueId(audio_unique_id_use_t use) { |
| 528 | auto result = [&]() -> ConversionResult<audio_unique_id_t> { |
| 529 | media::AudioUniqueIdUse useAidl = VALUE_OR_RETURN( |
| 530 | legacy2aidl_audio_unique_id_use_t_AudioUniqueIdUse(use)); |
| 531 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 532 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 533 | mDelegate->newAudioUniqueId(useAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 534 | return aidl2legacy_int32_t_audio_unique_id_t(aidlRet); |
| 535 | }(); |
| 536 | return result.value_or(AUDIO_UNIQUE_ID_ALLOCATE); |
| 537 | } |
| 538 | |
| 539 | void AudioFlingerClientAdapter::acquireAudioSessionId(audio_session_t audioSession, pid_t pid, |
| 540 | uid_t uid) { |
| 541 | [&]() -> status_t { |
| 542 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 543 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 544 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
| 545 | int32_t uidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(uid)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 546 | return statusTFromBinderStatus( |
| 547 | mDelegate->acquireAudioSessionId(audioSessionAidl, pidAidl, uidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 548 | }(); |
| 549 | // Failure is ignored. |
| 550 | } |
| 551 | |
| 552 | void AudioFlingerClientAdapter::releaseAudioSessionId(audio_session_t audioSession, pid_t pid) { |
| 553 | [&]() -> status_t { |
| 554 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 555 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 556 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 557 | return statusTFromBinderStatus( |
| 558 | mDelegate->releaseAudioSessionId(audioSessionAidl, pidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 559 | }(); |
| 560 | // Failure is ignored. |
| 561 | } |
| 562 | |
| 563 | status_t AudioFlingerClientAdapter::queryNumberEffects(uint32_t* numEffects) const { |
| 564 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 565 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 566 | mDelegate->queryNumberEffects(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 567 | if (numEffects != nullptr) { |
| 568 | *numEffects = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet)); |
| 569 | } |
| 570 | return OK; |
| 571 | } |
| 572 | |
| 573 | status_t |
| 574 | AudioFlingerClientAdapter::queryEffect(uint32_t index, effect_descriptor_t* pDescriptor) const { |
| 575 | int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index)); |
| 576 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 577 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 578 | mDelegate->queryEffect(indexAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 579 | if (pDescriptor != nullptr) { |
| 580 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 581 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 582 | } |
| 583 | return OK; |
| 584 | } |
| 585 | |
| 586 | status_t AudioFlingerClientAdapter::getEffectDescriptor(const effect_uuid_t* pEffectUUID, |
| 587 | const effect_uuid_t* pTypeUUID, |
| 588 | uint32_t preferredTypeFlag, |
| 589 | effect_descriptor_t* pDescriptor) const { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 590 | AudioUuid effectUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 591 | legacy2aidl_audio_uuid_t_AudioUuid(*pEffectUUID)); |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 592 | AudioUuid typeUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 593 | legacy2aidl_audio_uuid_t_AudioUuid(*pTypeUUID)); |
| 594 | int32_t preferredTypeFlagAidl = VALUE_OR_RETURN_STATUS( |
| 595 | convertReinterpret<int32_t>(preferredTypeFlag)); |
| 596 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 597 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 598 | mDelegate->getEffectDescriptor(effectUuidAidl, typeUuidAidl, preferredTypeFlagAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 599 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 600 | if (pDescriptor != nullptr) { |
| 601 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 602 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 603 | } |
| 604 | return OK; |
| 605 | } |
| 606 | |
| 607 | status_t AudioFlingerClientAdapter::createEffect(const media::CreateEffectRequest& request, |
| 608 | media::CreateEffectResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 609 | return statusTFromBinderStatus(mDelegate->createEffect(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 610 | } |
| 611 | |
| 612 | status_t |
| 613 | AudioFlingerClientAdapter::moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
| 614 | audio_io_handle_t dstOutput) { |
| 615 | int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session)); |
| 616 | int32_t srcOutputAidl = VALUE_OR_RETURN_STATUS( |
| 617 | legacy2aidl_audio_io_handle_t_int32_t(srcOutput)); |
| 618 | int32_t dstOutputAidl = VALUE_OR_RETURN_STATUS( |
| 619 | legacy2aidl_audio_io_handle_t_int32_t(dstOutput)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 620 | return statusTFromBinderStatus( |
| 621 | mDelegate->moveEffects(sessionAidl, srcOutputAidl, dstOutputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 622 | } |
| 623 | |
| 624 | void AudioFlingerClientAdapter::setEffectSuspended(int effectId, |
| 625 | audio_session_t sessionId, |
| 626 | bool suspended) { |
| 627 | [&]() -> status_t { |
| 628 | int32_t effectIdAidl = VALUE_OR_RETURN_STATUS(convertReinterpret<int32_t>(effectId)); |
| 629 | int32_t sessionIdAidl = VALUE_OR_RETURN_STATUS( |
| 630 | legacy2aidl_audio_session_t_int32_t(sessionId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 631 | return statusTFromBinderStatus( |
| 632 | mDelegate->setEffectSuspended(effectIdAidl, sessionIdAidl, suspended)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 633 | }(); |
| 634 | // Failure is ignored. |
| 635 | } |
| 636 | |
| 637 | audio_module_handle_t AudioFlingerClientAdapter::loadHwModule(const char* name) { |
| 638 | auto result = [&]() -> ConversionResult<audio_module_handle_t> { |
| 639 | std::string nameAidl(name); |
| 640 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 641 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 642 | mDelegate->loadHwModule(nameAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 643 | return aidl2legacy_int32_t_audio_module_handle_t(aidlRet); |
| 644 | }(); |
| 645 | // Failure is ignored. |
| 646 | return result.value_or(0); |
| 647 | } |
| 648 | |
| 649 | uint32_t AudioFlingerClientAdapter::getPrimaryOutputSamplingRate() { |
| 650 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 651 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 652 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 653 | mDelegate->getPrimaryOutputSamplingRate(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 654 | return convertIntegral<uint32_t>(aidlRet); |
| 655 | }(); |
| 656 | // Failure is ignored. |
| 657 | return result.value_or(0); |
| 658 | } |
| 659 | |
| 660 | size_t AudioFlingerClientAdapter::getPrimaryOutputFrameCount() { |
| 661 | auto result = [&]() -> ConversionResult<size_t> { |
| 662 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 663 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 664 | mDelegate->getPrimaryOutputFrameCount(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 665 | return convertIntegral<size_t>(aidlRet); |
| 666 | }(); |
| 667 | // Failure is ignored. |
| 668 | return result.value_or(0); |
| 669 | } |
| 670 | |
| 671 | status_t AudioFlingerClientAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 672 | return statusTFromBinderStatus(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 673 | } |
| 674 | |
| 675 | status_t AudioFlingerClientAdapter::getAudioPort(struct audio_port_v7* port) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 676 | media::AudioPortFw portAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 677 | legacy2aidl_audio_port_v7_AudioPortFw(*port)); |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 678 | media::AudioPortFw aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 679 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 680 | mDelegate->getAudioPort(portAidl, &aidlRet))); |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 681 | *port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPortFw_audio_port_v7(aidlRet)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 682 | return OK; |
| 683 | } |
| 684 | |
| 685 | status_t AudioFlingerClientAdapter::createAudioPatch(const struct audio_patch* patch, |
| 686 | audio_patch_handle_t* handle) { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 687 | media::AudioPatchFw patchAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 688 | legacy2aidl_audio_patch_AudioPatchFw(*patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 689 | int32_t aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t( |
| 690 | AUDIO_PATCH_HANDLE_NONE)); |
| 691 | if (handle != nullptr) { |
| 692 | aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(*handle)); |
| 693 | } |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 694 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 695 | mDelegate->createAudioPatch(patchAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 696 | if (handle != nullptr) { |
| 697 | *handle = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_patch_handle_t(aidlRet)); |
| 698 | } |
| 699 | return OK; |
| 700 | } |
| 701 | |
| 702 | status_t AudioFlingerClientAdapter::releaseAudioPatch(audio_patch_handle_t handle) { |
| 703 | int32_t handleAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(handle)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 704 | return statusTFromBinderStatus(mDelegate->releaseAudioPatch(handleAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 705 | } |
| 706 | |
| 707 | status_t AudioFlingerClientAdapter::listAudioPatches(unsigned int* num_patches, |
| 708 | struct audio_patch* patches) { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 709 | std::vector<media::AudioPatchFw> aidlRet; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 710 | int32_t maxPatches = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*num_patches)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 711 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 712 | mDelegate->listAudioPatches(maxPatches, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 713 | *num_patches = VALUE_OR_RETURN_STATUS(convertIntegral<unsigned int>(aidlRet.size())); |
| 714 | return convertRange(aidlRet.begin(), aidlRet.end(), patches, |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 715 | aidl2legacy_AudioPatchFw_audio_patch); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 716 | } |
| 717 | |
| 718 | status_t AudioFlingerClientAdapter::setAudioPortConfig(const struct audio_port_config* config) { |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 719 | media::AudioPortConfigFw configAidl = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 720 | legacy2aidl_audio_port_config_AudioPortConfigFw(*config)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 721 | return statusTFromBinderStatus(mDelegate->setAudioPortConfig(configAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 722 | } |
| 723 | |
| 724 | audio_hw_sync_t AudioFlingerClientAdapter::getAudioHwSyncForSession(audio_session_t sessionId) { |
| 725 | auto result = [&]() -> ConversionResult<audio_hw_sync_t> { |
| 726 | int32_t sessionIdAidl = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 727 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 728 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 729 | mDelegate->getAudioHwSyncForSession(sessionIdAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 730 | return aidl2legacy_int32_t_audio_hw_sync_t(aidlRet); |
| 731 | }(); |
| 732 | return result.value_or(AUDIO_HW_SYNC_INVALID); |
| 733 | } |
| 734 | |
| 735 | status_t AudioFlingerClientAdapter::systemReady() { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 736 | return statusTFromBinderStatus(mDelegate->systemReady()); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 737 | } |
| 738 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 739 | status_t AudioFlingerClientAdapter::audioPolicyReady() { |
| 740 | return statusTFromBinderStatus(mDelegate->audioPolicyReady()); |
| 741 | } |
| 742 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 743 | size_t AudioFlingerClientAdapter::frameCountHAL(audio_io_handle_t ioHandle) const { |
| 744 | auto result = [&]() -> ConversionResult<size_t> { |
| 745 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 746 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 747 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 748 | mDelegate->frameCountHAL(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 749 | return convertIntegral<size_t>(aidlRet); |
| 750 | }(); |
| 751 | // Failure is ignored. |
| 752 | return result.value_or(0); |
| 753 | } |
| 754 | |
| 755 | status_t |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame^] | 756 | AudioFlingerClientAdapter::getMicrophones(std::vector<media::MicrophoneInfoFw>* microphones) { |
| 757 | std::vector<media::MicrophoneInfoFw> aidlRet; |
| 758 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus(mDelegate->getMicrophones(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 759 | if (microphones != nullptr) { |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame^] | 760 | *microphones = std::move(aidlRet); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 761 | } |
| 762 | return OK; |
| 763 | } |
| 764 | |
| 765 | status_t AudioFlingerClientAdapter::setAudioHalPids(const std::vector<pid_t>& pids) { |
| 766 | std::vector<int32_t> pidsAidl = VALUE_OR_RETURN_STATUS( |
| 767 | convertContainer<std::vector<int32_t>>(pids, legacy2aidl_pid_t_int32_t)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 768 | return statusTFromBinderStatus(mDelegate->setAudioHalPids(pidsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 769 | } |
| 770 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 771 | status_t AudioFlingerClientAdapter::setVibratorInfos( |
| 772 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 773 | return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos)); |
| 774 | } |
| 775 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 776 | status_t AudioFlingerClientAdapter::updateSecondaryOutputs( |
| 777 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 778 | std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos = |
| 779 | VALUE_OR_RETURN_STATUS( |
| 780 | convertContainer<std::vector<media::TrackSecondaryOutputInfo>>( |
| 781 | trackSecondaryOutputs, |
| 782 | legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo)); |
| 783 | return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos)); |
| 784 | } |
| 785 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 786 | status_t AudioFlingerClientAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 787 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *policyInfos) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 788 | return statusTFromBinderStatus(mDelegate->getMmapPolicyInfos(policyType, policyInfos)); |
| 789 | } |
| 790 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 791 | int32_t AudioFlingerClientAdapter::getAAudioMixerBurstCount() { |
| 792 | auto result = [&]() -> ConversionResult<int32_t> { |
| 793 | int32_t aidlRet; |
| 794 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->getAAudioMixerBurstCount(&aidlRet))); |
| 795 | return convertIntegral<int32_t>(aidlRet); |
| 796 | }(); |
| 797 | // Failure is ignored. |
| 798 | return result.value_or(0); |
| 799 | } |
| 800 | |
| 801 | int32_t AudioFlingerClientAdapter::getAAudioHardwareBurstMinUsec() { |
| 802 | auto result = [&]() -> ConversionResult<int32_t> { |
| 803 | int32_t aidlRet; |
| 804 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 805 | mDelegate->getAAudioHardwareBurstMinUsec(&aidlRet))); |
| 806 | return convertIntegral<int32_t>(aidlRet); |
| 807 | }(); |
| 808 | // Failure is ignored. |
| 809 | return result.value_or(0); |
| 810 | } |
| 811 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 812 | status_t AudioFlingerClientAdapter::setDeviceConnectedState( |
| 813 | const struct audio_port_v7 *port, bool connected) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 814 | media::AudioPortFw aidlPort = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 815 | legacy2aidl_audio_port_v7_AudioPortFw(*port)); |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 816 | return statusTFromBinderStatus(mDelegate->setDeviceConnectedState(aidlPort, connected)); |
| 817 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 818 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 819 | status_t AudioFlingerClientAdapter::setRequestedLatencyMode( |
| 820 | audio_io_handle_t output, audio_latency_mode_t mode) { |
| 821 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 822 | media::audio::common::AudioLatencyMode modeAidl = VALUE_OR_RETURN_STATUS( |
| 823 | legacy2aidl_audio_latency_mode_t_AudioLatencyMode(mode)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 824 | return statusTFromBinderStatus(mDelegate->setRequestedLatencyMode(outputAidl, modeAidl)); |
| 825 | } |
| 826 | |
| 827 | status_t AudioFlingerClientAdapter::getSupportedLatencyModes( |
| 828 | audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) { |
| 829 | if (modes == nullptr) { |
| 830 | return BAD_VALUE; |
| 831 | } |
| 832 | |
| 833 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 834 | std::vector<media::audio::common::AudioLatencyMode> modesAidl; |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 835 | |
| 836 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 837 | mDelegate->getSupportedLatencyModes(outputAidl, &modesAidl))); |
| 838 | |
| 839 | *modes = VALUE_OR_RETURN_STATUS( |
| 840 | convertContainer<std::vector<audio_latency_mode_t>>(modesAidl, |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 841 | aidl2legacy_AudioLatencyMode_audio_latency_mode_t)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 842 | |
| 843 | return NO_ERROR; |
| 844 | } |
| 845 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 846 | status_t AudioFlingerClientAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 847 | return statusTFromBinderStatus(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 848 | } |
| 849 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 850 | status_t AudioFlingerClientAdapter::isBluetoothVariableLatencyEnabled(bool* enabled) { |
| 851 | if (enabled == nullptr) { |
| 852 | return BAD_VALUE; |
| 853 | } |
| 854 | |
| 855 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 856 | mDelegate->isBluetoothVariableLatencyEnabled(enabled))); |
| 857 | |
| 858 | return NO_ERROR; |
| 859 | } |
| 860 | |
| 861 | status_t AudioFlingerClientAdapter::supportsBluetoothVariableLatency(bool* support) { |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 862 | if (support == nullptr) { |
| 863 | return BAD_VALUE; |
| 864 | } |
| 865 | |
| 866 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 867 | mDelegate->supportsBluetoothVariableLatency(support))); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 868 | |
| 869 | return NO_ERROR; |
| 870 | } |
| 871 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 872 | status_t AudioFlingerClientAdapter::getSoundDoseInterface( |
| 873 | const sp<media::ISoundDoseCallback> &callback, |
| 874 | sp<media::ISoundDose>* soundDose) { |
| 875 | return statusTFromBinderStatus(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 876 | } |
| 877 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 878 | status_t AudioFlingerClientAdapter::invalidateTracks( |
| 879 | const std::vector<audio_port_handle_t>& portIds) { |
| 880 | std::vector<int32_t> portIdsAidl = VALUE_OR_RETURN_STATUS( |
| 881 | convertContainer<std::vector<int32_t>>( |
| 882 | portIds, legacy2aidl_audio_port_handle_t_int32_t)); |
| 883 | return statusTFromBinderStatus(mDelegate->invalidateTracks(portIdsAidl)); |
| 884 | } |
| 885 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 886 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 887 | // AudioFlingerServerAdapter |
| 888 | AudioFlingerServerAdapter::AudioFlingerServerAdapter( |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 889 | const sp<AudioFlingerServerAdapter::Delegate>& delegate) : mDelegate(delegate) { |
| 890 | setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); |
| 891 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 892 | |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 893 | status_t AudioFlingerServerAdapter::onTransact(uint32_t code, |
| 894 | const Parcel& data, |
| 895 | Parcel* reply, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 896 | uint32_t flags) { |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 897 | return mDelegate->onTransactWrapper(static_cast<Delegate::TransactionCode>(code), |
| 898 | data, |
| 899 | flags, |
| 900 | [&] { |
| 901 | return BnAudioFlingerService::onTransact( |
| 902 | code, |
| 903 | data, |
| 904 | reply, |
| 905 | flags); |
| 906 | }); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 907 | } |
| 908 | |
| 909 | status_t AudioFlingerServerAdapter::dump(int fd, const Vector<String16>& args) { |
| 910 | return mDelegate->dump(fd, args); |
| 911 | } |
| 912 | |
| 913 | Status AudioFlingerServerAdapter::createTrack(const media::CreateTrackRequest& request, |
| 914 | media::CreateTrackResponse* _aidl_return) { |
| 915 | return Status::fromStatusT(mDelegate->createTrack(request, *_aidl_return)); |
| 916 | } |
| 917 | |
| 918 | Status AudioFlingerServerAdapter::createRecord(const media::CreateRecordRequest& request, |
| 919 | media::CreateRecordResponse* _aidl_return) { |
| 920 | return Status::fromStatusT(mDelegate->createRecord(request, *_aidl_return)); |
| 921 | } |
| 922 | |
| 923 | Status AudioFlingerServerAdapter::sampleRate(int32_t ioHandle, int32_t* _aidl_return) { |
| 924 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 925 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 926 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 927 | convertIntegral<int32_t>(mDelegate->sampleRate(ioHandleLegacy))); |
| 928 | return Status::ok(); |
| 929 | } |
| 930 | |
| 931 | Status AudioFlingerServerAdapter::format(int32_t output, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 932 | AudioFormatDescription* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 933 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 934 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 935 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 936 | legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 937 | return Status::ok(); |
| 938 | } |
| 939 | |
| 940 | Status AudioFlingerServerAdapter::frameCount(int32_t ioHandle, int64_t* _aidl_return) { |
| 941 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 942 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 943 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 944 | convertIntegral<int64_t>(mDelegate->frameCount(ioHandleLegacy))); |
| 945 | return Status::ok(); |
| 946 | } |
| 947 | |
| 948 | Status AudioFlingerServerAdapter::latency(int32_t output, int32_t* _aidl_return) { |
| 949 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 950 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 951 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 952 | convertIntegral<int32_t>(mDelegate->latency(outputLegacy))); |
| 953 | return Status::ok(); |
| 954 | } |
| 955 | |
| 956 | Status AudioFlingerServerAdapter::setMasterVolume(float value) { |
| 957 | return Status::fromStatusT(mDelegate->setMasterVolume(value)); |
| 958 | } |
| 959 | |
| 960 | Status AudioFlingerServerAdapter::setMasterMute(bool muted) { |
| 961 | return Status::fromStatusT(mDelegate->setMasterMute(muted)); |
| 962 | } |
| 963 | |
| 964 | Status AudioFlingerServerAdapter::masterVolume(float* _aidl_return) { |
| 965 | *_aidl_return = mDelegate->masterVolume(); |
| 966 | return Status::ok(); |
| 967 | } |
| 968 | |
| 969 | Status AudioFlingerServerAdapter::masterMute(bool* _aidl_return) { |
| 970 | *_aidl_return = mDelegate->masterMute(); |
| 971 | return Status::ok(); |
| 972 | } |
| 973 | |
| 974 | Status AudioFlingerServerAdapter::setMasterBalance(float balance) { |
| 975 | return Status::fromStatusT(mDelegate->setMasterBalance(balance)); |
| 976 | } |
| 977 | |
| 978 | Status AudioFlingerServerAdapter::getMasterBalance(float* _aidl_return) { |
| 979 | return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return)); |
| 980 | } |
| 981 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 982 | Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 983 | int32_t output) { |
| 984 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 985 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 986 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 987 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 988 | return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy)); |
| 989 | } |
| 990 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 991 | Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 992 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 993 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 994 | return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted)); |
| 995 | } |
| 996 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 997 | Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 998 | float* _aidl_return) { |
| 999 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1000 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1001 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1002 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1003 | *_aidl_return = mDelegate->streamVolume(streamLegacy, outputLegacy); |
| 1004 | return Status::ok(); |
| 1005 | } |
| 1006 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1007 | Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1008 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1009 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1010 | *_aidl_return = mDelegate->streamMute(streamLegacy); |
| 1011 | return Status::ok(); |
| 1012 | } |
| 1013 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1014 | Status AudioFlingerServerAdapter::setMode(AudioMode mode) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1015 | audio_mode_t modeLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioMode_audio_mode_t(mode)); |
| 1016 | return Status::fromStatusT(mDelegate->setMode(modeLegacy)); |
| 1017 | } |
| 1018 | |
| 1019 | Status AudioFlingerServerAdapter::setMicMute(bool state) { |
| 1020 | return Status::fromStatusT(mDelegate->setMicMute(state)); |
| 1021 | } |
| 1022 | |
| 1023 | Status AudioFlingerServerAdapter::getMicMute(bool* _aidl_return) { |
| 1024 | *_aidl_return = mDelegate->getMicMute(); |
| 1025 | return Status::ok(); |
| 1026 | } |
| 1027 | |
| 1028 | Status AudioFlingerServerAdapter::setRecordSilenced(int32_t portId, bool silenced) { |
| 1029 | audio_port_handle_t portIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1030 | aidl2legacy_int32_t_audio_port_handle_t(portId)); |
| 1031 | mDelegate->setRecordSilenced(portIdLegacy, silenced); |
| 1032 | return Status::ok(); |
| 1033 | } |
| 1034 | |
| 1035 | Status |
| 1036 | AudioFlingerServerAdapter::setParameters(int32_t ioHandle, const std::string& keyValuePairs) { |
| 1037 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1038 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1039 | String8 keyValuePairsLegacy = VALUE_OR_RETURN_BINDER( |
| 1040 | aidl2legacy_string_view_String8(keyValuePairs)); |
| 1041 | return Status::fromStatusT(mDelegate->setParameters(ioHandleLegacy, keyValuePairsLegacy)); |
| 1042 | } |
| 1043 | |
| 1044 | Status AudioFlingerServerAdapter::getParameters(int32_t ioHandle, const std::string& keys, |
| 1045 | std::string* _aidl_return) { |
| 1046 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1047 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1048 | String8 keysLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_string_view_String8(keys)); |
| 1049 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1050 | legacy2aidl_String8_string(mDelegate->getParameters(ioHandleLegacy, keysLegacy))); |
| 1051 | return Status::ok(); |
| 1052 | } |
| 1053 | |
| 1054 | Status AudioFlingerServerAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 1055 | mDelegate->registerClient(client); |
| 1056 | return Status::ok(); |
| 1057 | } |
| 1058 | |
| 1059 | Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 1060 | const AudioFormatDescription& format, |
| 1061 | const AudioChannelLayout& channelMask, |
Mikhail Naganov | 2d8df4e | 2021-06-03 13:59:13 -0700 | [diff] [blame] | 1062 | int64_t* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1063 | uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate)); |
| 1064 | audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 1065 | aidl2legacy_AudioFormatDescription_audio_format_t(format)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1066 | audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 1067 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1068 | size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy); |
| 1069 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size)); |
| 1070 | return Status::ok(); |
| 1071 | } |
| 1072 | |
| 1073 | Status AudioFlingerServerAdapter::openOutput(const media::OpenOutputRequest& request, |
| 1074 | media::OpenOutputResponse* _aidl_return) { |
| 1075 | return Status::fromStatusT(mDelegate->openOutput(request, _aidl_return)); |
| 1076 | } |
| 1077 | |
| 1078 | Status AudioFlingerServerAdapter::openDuplicateOutput(int32_t output1, int32_t output2, |
| 1079 | int32_t* _aidl_return) { |
| 1080 | audio_io_handle_t output1Legacy = VALUE_OR_RETURN_BINDER( |
| 1081 | aidl2legacy_int32_t_audio_io_handle_t(output1)); |
| 1082 | audio_io_handle_t output2Legacy = VALUE_OR_RETURN_BINDER( |
| 1083 | aidl2legacy_int32_t_audio_io_handle_t(output2)); |
| 1084 | audio_io_handle_t result = mDelegate->openDuplicateOutput(output1Legacy, output2Legacy); |
| 1085 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_io_handle_t_int32_t(result)); |
| 1086 | return Status::ok(); |
| 1087 | } |
| 1088 | |
| 1089 | Status AudioFlingerServerAdapter::closeOutput(int32_t output) { |
| 1090 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1091 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1092 | return Status::fromStatusT(mDelegate->closeOutput(outputLegacy)); |
| 1093 | } |
| 1094 | |
| 1095 | Status AudioFlingerServerAdapter::suspendOutput(int32_t output) { |
| 1096 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1097 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1098 | return Status::fromStatusT(mDelegate->suspendOutput(outputLegacy)); |
| 1099 | } |
| 1100 | |
| 1101 | Status AudioFlingerServerAdapter::restoreOutput(int32_t output) { |
| 1102 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1103 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1104 | return Status::fromStatusT(mDelegate->restoreOutput(outputLegacy)); |
| 1105 | } |
| 1106 | |
| 1107 | Status AudioFlingerServerAdapter::openInput(const media::OpenInputRequest& request, |
| 1108 | media::OpenInputResponse* _aidl_return) { |
| 1109 | return Status::fromStatusT(mDelegate->openInput(request, _aidl_return)); |
| 1110 | } |
| 1111 | |
| 1112 | Status AudioFlingerServerAdapter::closeInput(int32_t input) { |
| 1113 | audio_io_handle_t inputLegacy = VALUE_OR_RETURN_BINDER( |
| 1114 | aidl2legacy_int32_t_audio_io_handle_t(input)); |
| 1115 | return Status::fromStatusT(mDelegate->closeInput(inputLegacy)); |
| 1116 | } |
| 1117 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1118 | Status AudioFlingerServerAdapter::setVoiceVolume(float volume) { |
| 1119 | return Status::fromStatusT(mDelegate->setVoiceVolume(volume)); |
| 1120 | } |
| 1121 | |
| 1122 | Status |
| 1123 | AudioFlingerServerAdapter::getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) { |
| 1124 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1125 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1126 | uint32_t halFramesLegacy; |
| 1127 | uint32_t dspFramesLegacy; |
| 1128 | RETURN_BINDER_IF_ERROR( |
| 1129 | mDelegate->getRenderPosition(&halFramesLegacy, &dspFramesLegacy, outputLegacy)); |
| 1130 | _aidl_return->halFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(halFramesLegacy)); |
| 1131 | _aidl_return->dspFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(dspFramesLegacy)); |
| 1132 | return Status::ok(); |
| 1133 | } |
| 1134 | |
| 1135 | Status AudioFlingerServerAdapter::getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) { |
| 1136 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1137 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1138 | uint32_t result = mDelegate->getInputFramesLost(ioHandleLegacy); |
| 1139 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(result)); |
| 1140 | return Status::ok(); |
| 1141 | } |
| 1142 | |
| 1143 | Status |
| 1144 | AudioFlingerServerAdapter::newAudioUniqueId(media::AudioUniqueIdUse use, int32_t* _aidl_return) { |
| 1145 | audio_unique_id_use_t useLegacy = VALUE_OR_RETURN_BINDER( |
| 1146 | aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(use)); |
| 1147 | audio_unique_id_t result = mDelegate->newAudioUniqueId(useLegacy); |
| 1148 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_unique_id_t_int32_t(result)); |
| 1149 | return Status::ok(); |
| 1150 | } |
| 1151 | |
| 1152 | Status |
| 1153 | AudioFlingerServerAdapter::acquireAudioSessionId(int32_t audioSession, int32_t pid, int32_t uid) { |
| 1154 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1155 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1156 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1157 | uid_t uidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_uid_t(uid)); |
| 1158 | mDelegate->acquireAudioSessionId(audioSessionLegacy, pidLegacy, uidLegacy); |
| 1159 | return Status::ok(); |
| 1160 | } |
| 1161 | |
| 1162 | Status AudioFlingerServerAdapter::releaseAudioSessionId(int32_t audioSession, int32_t pid) { |
| 1163 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1164 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1165 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1166 | mDelegate->releaseAudioSessionId(audioSessionLegacy, pidLegacy); |
| 1167 | return Status::ok(); |
| 1168 | } |
| 1169 | |
| 1170 | Status AudioFlingerServerAdapter::queryNumberEffects(int32_t* _aidl_return) { |
| 1171 | uint32_t result; |
| 1172 | RETURN_BINDER_IF_ERROR(mDelegate->queryNumberEffects(&result)); |
| 1173 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(result)); |
| 1174 | return Status::ok(); |
| 1175 | } |
| 1176 | |
| 1177 | Status |
| 1178 | AudioFlingerServerAdapter::queryEffect(int32_t index, media::EffectDescriptor* _aidl_return) { |
| 1179 | uint32_t indexLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(index)); |
| 1180 | effect_descriptor_t result; |
| 1181 | RETURN_BINDER_IF_ERROR(mDelegate->queryEffect(indexLegacy, &result)); |
| 1182 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1183 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1184 | return Status::ok(); |
| 1185 | } |
| 1186 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1187 | Status AudioFlingerServerAdapter::getEffectDescriptor(const AudioUuid& effectUUID, |
| 1188 | const AudioUuid& typeUUID, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1189 | int32_t preferredTypeFlag, |
| 1190 | media::EffectDescriptor* _aidl_return) { |
| 1191 | effect_uuid_t effectUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1192 | aidl2legacy_AudioUuid_audio_uuid_t(effectUUID)); |
| 1193 | effect_uuid_t typeUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1194 | aidl2legacy_AudioUuid_audio_uuid_t(typeUUID)); |
| 1195 | uint32_t preferredTypeFlagLegacy = VALUE_OR_RETURN_BINDER( |
| 1196 | convertReinterpret<uint32_t>(preferredTypeFlag)); |
| 1197 | effect_descriptor_t result; |
| 1198 | RETURN_BINDER_IF_ERROR(mDelegate->getEffectDescriptor(&effectUuidLegacy, &typeUuidLegacy, |
| 1199 | preferredTypeFlagLegacy, &result)); |
| 1200 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1201 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1202 | return Status::ok(); |
| 1203 | } |
| 1204 | |
| 1205 | Status AudioFlingerServerAdapter::createEffect(const media::CreateEffectRequest& request, |
| 1206 | media::CreateEffectResponse* _aidl_return) { |
| 1207 | return Status::fromStatusT(mDelegate->createEffect(request, _aidl_return)); |
| 1208 | } |
| 1209 | |
| 1210 | Status |
| 1211 | AudioFlingerServerAdapter::moveEffects(int32_t session, int32_t srcOutput, int32_t dstOutput) { |
| 1212 | audio_session_t sessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1213 | aidl2legacy_int32_t_audio_session_t(session)); |
| 1214 | audio_io_handle_t srcOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1215 | aidl2legacy_int32_t_audio_io_handle_t(srcOutput)); |
| 1216 | audio_io_handle_t dstOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1217 | aidl2legacy_int32_t_audio_io_handle_t(dstOutput)); |
| 1218 | return Status::fromStatusT( |
| 1219 | mDelegate->moveEffects(sessionLegacy, srcOutputLegacy, dstOutputLegacy)); |
| 1220 | } |
| 1221 | |
| 1222 | Status AudioFlingerServerAdapter::setEffectSuspended(int32_t effectId, int32_t sessionId, |
| 1223 | bool suspended) { |
| 1224 | int effectIdLegacy = VALUE_OR_RETURN_BINDER(convertReinterpret<int>(effectId)); |
| 1225 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1226 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1227 | mDelegate->setEffectSuspended(effectIdLegacy, sessionIdLegacy, suspended); |
| 1228 | return Status::ok(); |
| 1229 | } |
| 1230 | |
| 1231 | Status AudioFlingerServerAdapter::loadHwModule(const std::string& name, int32_t* _aidl_return) { |
| 1232 | audio_module_handle_t result = mDelegate->loadHwModule(name.c_str()); |
| 1233 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_module_handle_t_int32_t(result)); |
| 1234 | return Status::ok(); |
| 1235 | } |
| 1236 | |
| 1237 | Status AudioFlingerServerAdapter::getPrimaryOutputSamplingRate(int32_t* _aidl_return) { |
| 1238 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1239 | convertIntegral<int32_t>(mDelegate->getPrimaryOutputSamplingRate())); |
| 1240 | return Status::ok(); |
| 1241 | } |
| 1242 | |
| 1243 | Status AudioFlingerServerAdapter::getPrimaryOutputFrameCount(int64_t* _aidl_return) { |
| 1244 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1245 | convertIntegral<int64_t>(mDelegate->getPrimaryOutputFrameCount())); |
| 1246 | return Status::ok(); |
| 1247 | |
| 1248 | } |
| 1249 | |
| 1250 | Status AudioFlingerServerAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
| 1251 | return Status::fromStatusT(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
| 1252 | } |
| 1253 | |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1254 | Status AudioFlingerServerAdapter::getAudioPort(const media::AudioPortFw& port, |
| 1255 | media::AudioPortFw* _aidl_return) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1256 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPortFw_audio_port_v7(port)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1257 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioPort(&portLegacy)); |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1258 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPortFw(portLegacy)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1259 | return Status::ok(); |
| 1260 | } |
| 1261 | |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1262 | Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatchFw& patch, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1263 | int32_t* _aidl_return) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1264 | audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatchFw_audio_patch(patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 1265 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1266 | aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1267 | RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy)); |
| 1268 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy)); |
| 1269 | return Status::ok(); |
| 1270 | } |
| 1271 | |
| 1272 | Status AudioFlingerServerAdapter::releaseAudioPatch(int32_t handle) { |
| 1273 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1274 | aidl2legacy_int32_t_audio_patch_handle_t(handle)); |
| 1275 | return Status::fromStatusT(mDelegate->releaseAudioPatch(handleLegacy)); |
| 1276 | } |
| 1277 | |
| 1278 | Status AudioFlingerServerAdapter::listAudioPatches(int32_t maxCount, |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1279 | std::vector<media::AudioPatchFw>* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1280 | unsigned int count = VALUE_OR_RETURN_BINDER(convertIntegral<unsigned int>(maxCount)); |
| 1281 | count = std::min(count, static_cast<unsigned int>(MAX_ITEMS_PER_LIST)); |
| 1282 | std::unique_ptr<audio_patch[]> patchesLegacy(new audio_patch[count]); |
| 1283 | RETURN_BINDER_IF_ERROR(mDelegate->listAudioPatches(&count, patchesLegacy.get())); |
| 1284 | RETURN_BINDER_IF_ERROR(convertRange(&patchesLegacy[0], |
| 1285 | &patchesLegacy[count], |
| 1286 | std::back_inserter(*_aidl_return), |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1287 | legacy2aidl_audio_patch_AudioPatchFw)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1288 | return Status::ok(); |
| 1289 | } |
| 1290 | |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 1291 | Status AudioFlingerServerAdapter::setAudioPortConfig(const media::AudioPortConfigFw& config) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1292 | audio_port_config configLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1293 | aidl2legacy_AudioPortConfigFw_audio_port_config(config)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1294 | return Status::fromStatusT(mDelegate->setAudioPortConfig(&configLegacy)); |
| 1295 | } |
| 1296 | |
| 1297 | Status AudioFlingerServerAdapter::getAudioHwSyncForSession(int32_t sessionId, |
| 1298 | int32_t* _aidl_return) { |
| 1299 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1300 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1301 | audio_hw_sync_t result = mDelegate->getAudioHwSyncForSession(sessionIdLegacy); |
| 1302 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_hw_sync_t_int32_t(result)); |
| 1303 | return Status::ok(); |
| 1304 | } |
| 1305 | |
| 1306 | Status AudioFlingerServerAdapter::systemReady() { |
| 1307 | return Status::fromStatusT(mDelegate->systemReady()); |
| 1308 | } |
| 1309 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 1310 | Status AudioFlingerServerAdapter::audioPolicyReady() { |
| 1311 | mDelegate->audioPolicyReady(); |
| 1312 | return Status::ok(); |
| 1313 | } |
| 1314 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1315 | Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) { |
| 1316 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1317 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1318 | size_t result = mDelegate->frameCountHAL(ioHandleLegacy); |
| 1319 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(result)); |
| 1320 | return Status::ok(); |
| 1321 | } |
| 1322 | |
| 1323 | Status AudioFlingerServerAdapter::getMicrophones( |
Mikhail Naganov | d5d9de7 | 2023-02-13 11:45:03 -0800 | [diff] [blame^] | 1324 | std::vector<media::MicrophoneInfoFw>* _aidl_return) { |
| 1325 | RETURN_BINDER_IF_ERROR(mDelegate->getMicrophones(_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1326 | return Status::ok(); |
| 1327 | } |
| 1328 | |
| 1329 | Status AudioFlingerServerAdapter::setAudioHalPids(const std::vector<int32_t>& pids) { |
| 1330 | std::vector<pid_t> pidsLegacy = VALUE_OR_RETURN_BINDER( |
| 1331 | convertContainer<std::vector<pid_t>>(pids, aidl2legacy_int32_t_pid_t)); |
| 1332 | RETURN_BINDER_IF_ERROR(mDelegate->setAudioHalPids(pidsLegacy)); |
| 1333 | return Status::ok(); |
| 1334 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1335 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 1336 | Status AudioFlingerServerAdapter::setVibratorInfos( |
| 1337 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 1338 | return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos)); |
| 1339 | } |
| 1340 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 1341 | Status AudioFlingerServerAdapter::updateSecondaryOutputs( |
| 1342 | const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) { |
| 1343 | TrackSecondaryOutputsMap trackSecondaryOutputs = |
| 1344 | VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>( |
| 1345 | trackSecondaryOutputInfos, |
| 1346 | aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair)); |
| 1347 | return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs)); |
| 1348 | } |
| 1349 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1350 | Status AudioFlingerServerAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 1351 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *_aidl_return) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1352 | return Status::fromStatusT(mDelegate->getMmapPolicyInfos(policyType, _aidl_return)); |
| 1353 | } |
| 1354 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 1355 | Status AudioFlingerServerAdapter::getAAudioMixerBurstCount(int32_t* _aidl_return) { |
| 1356 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1357 | convertIntegral<int32_t>(mDelegate->getAAudioMixerBurstCount())); |
| 1358 | return Status::ok(); |
| 1359 | } |
| 1360 | |
| 1361 | Status AudioFlingerServerAdapter::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) { |
| 1362 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1363 | convertIntegral<int32_t>(mDelegate->getAAudioHardwareBurstMinUsec())); |
| 1364 | return Status::ok(); |
| 1365 | } |
| 1366 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1367 | Status AudioFlingerServerAdapter::setDeviceConnectedState( |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1368 | const media::AudioPortFw& port, bool connected) { |
Mikhail Naganov | 8722725 | 2023-01-13 17:38:10 -0800 | [diff] [blame] | 1369 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPortFw_audio_port_v7(port)); |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1370 | return Status::fromStatusT(mDelegate->setDeviceConnectedState(&portLegacy, connected)); |
| 1371 | } |
| 1372 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1373 | Status AudioFlingerServerAdapter::setRequestedLatencyMode( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1374 | int32_t output, media::audio::common::AudioLatencyMode modeAidl) { |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1375 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1376 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1377 | audio_latency_mode_t modeLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1378 | aidl2legacy_AudioLatencyMode_audio_latency_mode_t(modeAidl)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1379 | return Status::fromStatusT(mDelegate->setRequestedLatencyMode( |
| 1380 | outputLegacy, modeLegacy)); |
| 1381 | } |
| 1382 | |
| 1383 | Status AudioFlingerServerAdapter::getSupportedLatencyModes( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1384 | int output, std::vector<media::audio::common::AudioLatencyMode>* _aidl_return) { |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1385 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1386 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1387 | std::vector<audio_latency_mode_t> modesLegacy; |
| 1388 | |
| 1389 | RETURN_BINDER_IF_ERROR(mDelegate->getSupportedLatencyModes(outputLegacy, &modesLegacy)); |
| 1390 | |
| 1391 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | f53e182 | 2022-12-18 02:48:14 +0000 | [diff] [blame] | 1392 | convertContainer<std::vector<media::audio::common::AudioLatencyMode>>( |
| 1393 | modesLegacy, legacy2aidl_audio_latency_mode_t_AudioLatencyMode)); |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1394 | return Status::ok(); |
| 1395 | } |
| 1396 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 1397 | Status AudioFlingerServerAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 1398 | return Status::fromStatusT(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1399 | } |
| 1400 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame] | 1401 | Status AudioFlingerServerAdapter::isBluetoothVariableLatencyEnabled(bool *enabled) { |
| 1402 | return Status::fromStatusT(mDelegate->isBluetoothVariableLatencyEnabled(enabled)); |
| 1403 | } |
| 1404 | |
| 1405 | Status AudioFlingerServerAdapter::supportsBluetoothVariableLatency(bool *support) { |
| 1406 | return Status::fromStatusT(mDelegate->supportsBluetoothVariableLatency(support)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1407 | } |
| 1408 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1409 | Status AudioFlingerServerAdapter::getSoundDoseInterface( |
| 1410 | const sp<media::ISoundDoseCallback>& callback, |
| 1411 | sp<media::ISoundDose>* soundDose) |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1412 | { |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1413 | return Status::fromStatusT(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1414 | } |
| 1415 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 1416 | Status AudioFlingerServerAdapter::invalidateTracks(const std::vector<int32_t>& portIds) { |
| 1417 | std::vector<audio_port_handle_t> portIdsLegacy = VALUE_OR_RETURN_BINDER( |
| 1418 | convertContainer<std::vector<audio_port_handle_t>>( |
| 1419 | portIds, aidl2legacy_int32_t_audio_port_handle_t)); |
| 1420 | RETURN_BINDER_IF_ERROR(mDelegate->invalidateTracks(portIdsLegacy)); |
| 1421 | return Status::ok(); |
| 1422 | } |
| 1423 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1424 | } // namespace android |