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( |
| 677 | legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 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))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 681 | *port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPort_audio_port_v7(aidlRet)); |
| 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( |
| 688 | legacy2aidl_audio_patch_AudioPatch(*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, |
| 715 | aidl2legacy_AudioPatch_audio_patch); |
| 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( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 720 | legacy2aidl_audio_port_config_AudioPortConfig(*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 |
| 756 | AudioFlingerClientAdapter::getMicrophones(std::vector<media::MicrophoneInfo>* microphones) { |
| 757 | std::vector<media::MicrophoneInfoData> aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 758 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 759 | mDelegate->getMicrophones(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 760 | if (microphones != nullptr) { |
| 761 | *microphones = VALUE_OR_RETURN_STATUS( |
| 762 | convertContainer<std::vector<media::MicrophoneInfo>>(aidlRet, |
| 763 | media::aidl2legacy_MicrophoneInfo)); |
| 764 | } |
| 765 | return OK; |
| 766 | } |
| 767 | |
| 768 | status_t AudioFlingerClientAdapter::setAudioHalPids(const std::vector<pid_t>& pids) { |
| 769 | std::vector<int32_t> pidsAidl = VALUE_OR_RETURN_STATUS( |
| 770 | convertContainer<std::vector<int32_t>>(pids, legacy2aidl_pid_t_int32_t)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 771 | return statusTFromBinderStatus(mDelegate->setAudioHalPids(pidsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 772 | } |
| 773 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 774 | status_t AudioFlingerClientAdapter::setVibratorInfos( |
| 775 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 776 | return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos)); |
| 777 | } |
| 778 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 779 | status_t AudioFlingerClientAdapter::updateSecondaryOutputs( |
| 780 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 781 | std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos = |
| 782 | VALUE_OR_RETURN_STATUS( |
| 783 | convertContainer<std::vector<media::TrackSecondaryOutputInfo>>( |
| 784 | trackSecondaryOutputs, |
| 785 | legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo)); |
| 786 | return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos)); |
| 787 | } |
| 788 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 789 | status_t AudioFlingerClientAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 790 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *policyInfos) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 791 | return statusTFromBinderStatus(mDelegate->getMmapPolicyInfos(policyType, policyInfos)); |
| 792 | } |
| 793 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 794 | int32_t AudioFlingerClientAdapter::getAAudioMixerBurstCount() { |
| 795 | auto result = [&]() -> ConversionResult<int32_t> { |
| 796 | int32_t aidlRet; |
| 797 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->getAAudioMixerBurstCount(&aidlRet))); |
| 798 | return convertIntegral<int32_t>(aidlRet); |
| 799 | }(); |
| 800 | // Failure is ignored. |
| 801 | return result.value_or(0); |
| 802 | } |
| 803 | |
| 804 | int32_t AudioFlingerClientAdapter::getAAudioHardwareBurstMinUsec() { |
| 805 | auto result = [&]() -> ConversionResult<int32_t> { |
| 806 | int32_t aidlRet; |
| 807 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 808 | mDelegate->getAAudioHardwareBurstMinUsec(&aidlRet))); |
| 809 | return convertIntegral<int32_t>(aidlRet); |
| 810 | }(); |
| 811 | // Failure is ignored. |
| 812 | return result.value_or(0); |
| 813 | } |
| 814 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 815 | status_t AudioFlingerClientAdapter::setDeviceConnectedState( |
| 816 | const struct audio_port_v7 *port, bool connected) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 817 | media::AudioPortFw aidlPort = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 818 | legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 819 | return statusTFromBinderStatus(mDelegate->setDeviceConnectedState(aidlPort, connected)); |
| 820 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 821 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 822 | status_t AudioFlingerClientAdapter::setRequestedLatencyMode( |
| 823 | audio_io_handle_t output, audio_latency_mode_t mode) { |
| 824 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 825 | media::LatencyMode modeAidl = VALUE_OR_RETURN_STATUS( |
| 826 | legacy2aidl_audio_latency_mode_t_LatencyMode(mode)); |
| 827 | return statusTFromBinderStatus(mDelegate->setRequestedLatencyMode(outputAidl, modeAidl)); |
| 828 | } |
| 829 | |
| 830 | status_t AudioFlingerClientAdapter::getSupportedLatencyModes( |
| 831 | audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) { |
| 832 | if (modes == nullptr) { |
| 833 | return BAD_VALUE; |
| 834 | } |
| 835 | |
| 836 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 837 | std::vector<media::LatencyMode> modesAidl; |
| 838 | |
| 839 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 840 | mDelegate->getSupportedLatencyModes(outputAidl, &modesAidl))); |
| 841 | |
| 842 | *modes = VALUE_OR_RETURN_STATUS( |
| 843 | convertContainer<std::vector<audio_latency_mode_t>>(modesAidl, |
| 844 | aidl2legacy_LatencyMode_audio_latency_mode_t)); |
| 845 | |
| 846 | return NO_ERROR; |
| 847 | } |
| 848 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame^] | 849 | status_t AudioFlingerClientAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 850 | return statusTFromBinderStatus(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 851 | } |
| 852 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame^] | 853 | status_t AudioFlingerClientAdapter::isBluetoothVariableLatencyEnabled(bool* enabled) { |
| 854 | if (enabled == nullptr) { |
| 855 | return BAD_VALUE; |
| 856 | } |
| 857 | |
| 858 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 859 | mDelegate->isBluetoothVariableLatencyEnabled(enabled))); |
| 860 | |
| 861 | return NO_ERROR; |
| 862 | } |
| 863 | |
| 864 | status_t AudioFlingerClientAdapter::supportsBluetoothVariableLatency(bool* support) { |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 865 | if (support == nullptr) { |
| 866 | return BAD_VALUE; |
| 867 | } |
| 868 | |
| 869 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame^] | 870 | mDelegate->supportsBluetoothVariableLatency(support))); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 871 | |
| 872 | return NO_ERROR; |
| 873 | } |
| 874 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 875 | status_t AudioFlingerClientAdapter::getSoundDoseInterface( |
| 876 | const sp<media::ISoundDoseCallback> &callback, |
| 877 | sp<media::ISoundDose>* soundDose) { |
| 878 | return statusTFromBinderStatus(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 879 | } |
| 880 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 881 | status_t AudioFlingerClientAdapter::invalidateTracks( |
| 882 | const std::vector<audio_port_handle_t>& portIds) { |
| 883 | std::vector<int32_t> portIdsAidl = VALUE_OR_RETURN_STATUS( |
| 884 | convertContainer<std::vector<int32_t>>( |
| 885 | portIds, legacy2aidl_audio_port_handle_t_int32_t)); |
| 886 | return statusTFromBinderStatus(mDelegate->invalidateTracks(portIdsAidl)); |
| 887 | } |
| 888 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 889 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 890 | // AudioFlingerServerAdapter |
| 891 | AudioFlingerServerAdapter::AudioFlingerServerAdapter( |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 892 | const sp<AudioFlingerServerAdapter::Delegate>& delegate) : mDelegate(delegate) { |
| 893 | setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); |
| 894 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 895 | |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 896 | status_t AudioFlingerServerAdapter::onTransact(uint32_t code, |
| 897 | const Parcel& data, |
| 898 | Parcel* reply, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 899 | uint32_t flags) { |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 900 | return mDelegate->onTransactWrapper(static_cast<Delegate::TransactionCode>(code), |
| 901 | data, |
| 902 | flags, |
| 903 | [&] { |
| 904 | return BnAudioFlingerService::onTransact( |
| 905 | code, |
| 906 | data, |
| 907 | reply, |
| 908 | flags); |
| 909 | }); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 910 | } |
| 911 | |
| 912 | status_t AudioFlingerServerAdapter::dump(int fd, const Vector<String16>& args) { |
| 913 | return mDelegate->dump(fd, args); |
| 914 | } |
| 915 | |
| 916 | Status AudioFlingerServerAdapter::createTrack(const media::CreateTrackRequest& request, |
| 917 | media::CreateTrackResponse* _aidl_return) { |
| 918 | return Status::fromStatusT(mDelegate->createTrack(request, *_aidl_return)); |
| 919 | } |
| 920 | |
| 921 | Status AudioFlingerServerAdapter::createRecord(const media::CreateRecordRequest& request, |
| 922 | media::CreateRecordResponse* _aidl_return) { |
| 923 | return Status::fromStatusT(mDelegate->createRecord(request, *_aidl_return)); |
| 924 | } |
| 925 | |
| 926 | Status AudioFlingerServerAdapter::sampleRate(int32_t ioHandle, int32_t* _aidl_return) { |
| 927 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 928 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 929 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 930 | convertIntegral<int32_t>(mDelegate->sampleRate(ioHandleLegacy))); |
| 931 | return Status::ok(); |
| 932 | } |
| 933 | |
| 934 | Status AudioFlingerServerAdapter::format(int32_t output, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 935 | AudioFormatDescription* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 936 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 937 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 938 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 939 | legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 940 | return Status::ok(); |
| 941 | } |
| 942 | |
| 943 | Status AudioFlingerServerAdapter::frameCount(int32_t ioHandle, int64_t* _aidl_return) { |
| 944 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 945 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 946 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 947 | convertIntegral<int64_t>(mDelegate->frameCount(ioHandleLegacy))); |
| 948 | return Status::ok(); |
| 949 | } |
| 950 | |
| 951 | Status AudioFlingerServerAdapter::latency(int32_t output, int32_t* _aidl_return) { |
| 952 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 953 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 954 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 955 | convertIntegral<int32_t>(mDelegate->latency(outputLegacy))); |
| 956 | return Status::ok(); |
| 957 | } |
| 958 | |
| 959 | Status AudioFlingerServerAdapter::setMasterVolume(float value) { |
| 960 | return Status::fromStatusT(mDelegate->setMasterVolume(value)); |
| 961 | } |
| 962 | |
| 963 | Status AudioFlingerServerAdapter::setMasterMute(bool muted) { |
| 964 | return Status::fromStatusT(mDelegate->setMasterMute(muted)); |
| 965 | } |
| 966 | |
| 967 | Status AudioFlingerServerAdapter::masterVolume(float* _aidl_return) { |
| 968 | *_aidl_return = mDelegate->masterVolume(); |
| 969 | return Status::ok(); |
| 970 | } |
| 971 | |
| 972 | Status AudioFlingerServerAdapter::masterMute(bool* _aidl_return) { |
| 973 | *_aidl_return = mDelegate->masterMute(); |
| 974 | return Status::ok(); |
| 975 | } |
| 976 | |
| 977 | Status AudioFlingerServerAdapter::setMasterBalance(float balance) { |
| 978 | return Status::fromStatusT(mDelegate->setMasterBalance(balance)); |
| 979 | } |
| 980 | |
| 981 | Status AudioFlingerServerAdapter::getMasterBalance(float* _aidl_return) { |
| 982 | return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return)); |
| 983 | } |
| 984 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 985 | Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 986 | int32_t output) { |
| 987 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 988 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 989 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 990 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 991 | return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy)); |
| 992 | } |
| 993 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 994 | Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 995 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 996 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 997 | return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted)); |
| 998 | } |
| 999 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1000 | Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1001 | float* _aidl_return) { |
| 1002 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1003 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1004 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1005 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1006 | *_aidl_return = mDelegate->streamVolume(streamLegacy, outputLegacy); |
| 1007 | return Status::ok(); |
| 1008 | } |
| 1009 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1010 | Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1011 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1012 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1013 | *_aidl_return = mDelegate->streamMute(streamLegacy); |
| 1014 | return Status::ok(); |
| 1015 | } |
| 1016 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1017 | Status AudioFlingerServerAdapter::setMode(AudioMode mode) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1018 | audio_mode_t modeLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioMode_audio_mode_t(mode)); |
| 1019 | return Status::fromStatusT(mDelegate->setMode(modeLegacy)); |
| 1020 | } |
| 1021 | |
| 1022 | Status AudioFlingerServerAdapter::setMicMute(bool state) { |
| 1023 | return Status::fromStatusT(mDelegate->setMicMute(state)); |
| 1024 | } |
| 1025 | |
| 1026 | Status AudioFlingerServerAdapter::getMicMute(bool* _aidl_return) { |
| 1027 | *_aidl_return = mDelegate->getMicMute(); |
| 1028 | return Status::ok(); |
| 1029 | } |
| 1030 | |
| 1031 | Status AudioFlingerServerAdapter::setRecordSilenced(int32_t portId, bool silenced) { |
| 1032 | audio_port_handle_t portIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1033 | aidl2legacy_int32_t_audio_port_handle_t(portId)); |
| 1034 | mDelegate->setRecordSilenced(portIdLegacy, silenced); |
| 1035 | return Status::ok(); |
| 1036 | } |
| 1037 | |
| 1038 | Status |
| 1039 | AudioFlingerServerAdapter::setParameters(int32_t ioHandle, const std::string& keyValuePairs) { |
| 1040 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1041 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1042 | String8 keyValuePairsLegacy = VALUE_OR_RETURN_BINDER( |
| 1043 | aidl2legacy_string_view_String8(keyValuePairs)); |
| 1044 | return Status::fromStatusT(mDelegate->setParameters(ioHandleLegacy, keyValuePairsLegacy)); |
| 1045 | } |
| 1046 | |
| 1047 | Status AudioFlingerServerAdapter::getParameters(int32_t ioHandle, const std::string& keys, |
| 1048 | std::string* _aidl_return) { |
| 1049 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1050 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1051 | String8 keysLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_string_view_String8(keys)); |
| 1052 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1053 | legacy2aidl_String8_string(mDelegate->getParameters(ioHandleLegacy, keysLegacy))); |
| 1054 | return Status::ok(); |
| 1055 | } |
| 1056 | |
| 1057 | Status AudioFlingerServerAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 1058 | mDelegate->registerClient(client); |
| 1059 | return Status::ok(); |
| 1060 | } |
| 1061 | |
| 1062 | Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 1063 | const AudioFormatDescription& format, |
| 1064 | const AudioChannelLayout& channelMask, |
Mikhail Naganov | 2d8df4e | 2021-06-03 13:59:13 -0700 | [diff] [blame] | 1065 | int64_t* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1066 | uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate)); |
| 1067 | audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 1068 | aidl2legacy_AudioFormatDescription_audio_format_t(format)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1069 | audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 1070 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1071 | size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy); |
| 1072 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size)); |
| 1073 | return Status::ok(); |
| 1074 | } |
| 1075 | |
| 1076 | Status AudioFlingerServerAdapter::openOutput(const media::OpenOutputRequest& request, |
| 1077 | media::OpenOutputResponse* _aidl_return) { |
| 1078 | return Status::fromStatusT(mDelegate->openOutput(request, _aidl_return)); |
| 1079 | } |
| 1080 | |
| 1081 | Status AudioFlingerServerAdapter::openDuplicateOutput(int32_t output1, int32_t output2, |
| 1082 | int32_t* _aidl_return) { |
| 1083 | audio_io_handle_t output1Legacy = VALUE_OR_RETURN_BINDER( |
| 1084 | aidl2legacy_int32_t_audio_io_handle_t(output1)); |
| 1085 | audio_io_handle_t output2Legacy = VALUE_OR_RETURN_BINDER( |
| 1086 | aidl2legacy_int32_t_audio_io_handle_t(output2)); |
| 1087 | audio_io_handle_t result = mDelegate->openDuplicateOutput(output1Legacy, output2Legacy); |
| 1088 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_io_handle_t_int32_t(result)); |
| 1089 | return Status::ok(); |
| 1090 | } |
| 1091 | |
| 1092 | Status AudioFlingerServerAdapter::closeOutput(int32_t output) { |
| 1093 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1094 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1095 | return Status::fromStatusT(mDelegate->closeOutput(outputLegacy)); |
| 1096 | } |
| 1097 | |
| 1098 | Status AudioFlingerServerAdapter::suspendOutput(int32_t output) { |
| 1099 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1100 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1101 | return Status::fromStatusT(mDelegate->suspendOutput(outputLegacy)); |
| 1102 | } |
| 1103 | |
| 1104 | Status AudioFlingerServerAdapter::restoreOutput(int32_t output) { |
| 1105 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1106 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1107 | return Status::fromStatusT(mDelegate->restoreOutput(outputLegacy)); |
| 1108 | } |
| 1109 | |
| 1110 | Status AudioFlingerServerAdapter::openInput(const media::OpenInputRequest& request, |
| 1111 | media::OpenInputResponse* _aidl_return) { |
| 1112 | return Status::fromStatusT(mDelegate->openInput(request, _aidl_return)); |
| 1113 | } |
| 1114 | |
| 1115 | Status AudioFlingerServerAdapter::closeInput(int32_t input) { |
| 1116 | audio_io_handle_t inputLegacy = VALUE_OR_RETURN_BINDER( |
| 1117 | aidl2legacy_int32_t_audio_io_handle_t(input)); |
| 1118 | return Status::fromStatusT(mDelegate->closeInput(inputLegacy)); |
| 1119 | } |
| 1120 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1121 | Status AudioFlingerServerAdapter::setVoiceVolume(float volume) { |
| 1122 | return Status::fromStatusT(mDelegate->setVoiceVolume(volume)); |
| 1123 | } |
| 1124 | |
| 1125 | Status |
| 1126 | AudioFlingerServerAdapter::getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) { |
| 1127 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1128 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1129 | uint32_t halFramesLegacy; |
| 1130 | uint32_t dspFramesLegacy; |
| 1131 | RETURN_BINDER_IF_ERROR( |
| 1132 | mDelegate->getRenderPosition(&halFramesLegacy, &dspFramesLegacy, outputLegacy)); |
| 1133 | _aidl_return->halFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(halFramesLegacy)); |
| 1134 | _aidl_return->dspFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(dspFramesLegacy)); |
| 1135 | return Status::ok(); |
| 1136 | } |
| 1137 | |
| 1138 | Status AudioFlingerServerAdapter::getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) { |
| 1139 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1140 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1141 | uint32_t result = mDelegate->getInputFramesLost(ioHandleLegacy); |
| 1142 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(result)); |
| 1143 | return Status::ok(); |
| 1144 | } |
| 1145 | |
| 1146 | Status |
| 1147 | AudioFlingerServerAdapter::newAudioUniqueId(media::AudioUniqueIdUse use, int32_t* _aidl_return) { |
| 1148 | audio_unique_id_use_t useLegacy = VALUE_OR_RETURN_BINDER( |
| 1149 | aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(use)); |
| 1150 | audio_unique_id_t result = mDelegate->newAudioUniqueId(useLegacy); |
| 1151 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_unique_id_t_int32_t(result)); |
| 1152 | return Status::ok(); |
| 1153 | } |
| 1154 | |
| 1155 | Status |
| 1156 | AudioFlingerServerAdapter::acquireAudioSessionId(int32_t audioSession, int32_t pid, int32_t uid) { |
| 1157 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1158 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1159 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1160 | uid_t uidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_uid_t(uid)); |
| 1161 | mDelegate->acquireAudioSessionId(audioSessionLegacy, pidLegacy, uidLegacy); |
| 1162 | return Status::ok(); |
| 1163 | } |
| 1164 | |
| 1165 | Status AudioFlingerServerAdapter::releaseAudioSessionId(int32_t audioSession, int32_t pid) { |
| 1166 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1167 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1168 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1169 | mDelegate->releaseAudioSessionId(audioSessionLegacy, pidLegacy); |
| 1170 | return Status::ok(); |
| 1171 | } |
| 1172 | |
| 1173 | Status AudioFlingerServerAdapter::queryNumberEffects(int32_t* _aidl_return) { |
| 1174 | uint32_t result; |
| 1175 | RETURN_BINDER_IF_ERROR(mDelegate->queryNumberEffects(&result)); |
| 1176 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(result)); |
| 1177 | return Status::ok(); |
| 1178 | } |
| 1179 | |
| 1180 | Status |
| 1181 | AudioFlingerServerAdapter::queryEffect(int32_t index, media::EffectDescriptor* _aidl_return) { |
| 1182 | uint32_t indexLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(index)); |
| 1183 | effect_descriptor_t result; |
| 1184 | RETURN_BINDER_IF_ERROR(mDelegate->queryEffect(indexLegacy, &result)); |
| 1185 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1186 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1187 | return Status::ok(); |
| 1188 | } |
| 1189 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1190 | Status AudioFlingerServerAdapter::getEffectDescriptor(const AudioUuid& effectUUID, |
| 1191 | const AudioUuid& typeUUID, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1192 | int32_t preferredTypeFlag, |
| 1193 | media::EffectDescriptor* _aidl_return) { |
| 1194 | effect_uuid_t effectUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1195 | aidl2legacy_AudioUuid_audio_uuid_t(effectUUID)); |
| 1196 | effect_uuid_t typeUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1197 | aidl2legacy_AudioUuid_audio_uuid_t(typeUUID)); |
| 1198 | uint32_t preferredTypeFlagLegacy = VALUE_OR_RETURN_BINDER( |
| 1199 | convertReinterpret<uint32_t>(preferredTypeFlag)); |
| 1200 | effect_descriptor_t result; |
| 1201 | RETURN_BINDER_IF_ERROR(mDelegate->getEffectDescriptor(&effectUuidLegacy, &typeUuidLegacy, |
| 1202 | preferredTypeFlagLegacy, &result)); |
| 1203 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1204 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1205 | return Status::ok(); |
| 1206 | } |
| 1207 | |
| 1208 | Status AudioFlingerServerAdapter::createEffect(const media::CreateEffectRequest& request, |
| 1209 | media::CreateEffectResponse* _aidl_return) { |
| 1210 | return Status::fromStatusT(mDelegate->createEffect(request, _aidl_return)); |
| 1211 | } |
| 1212 | |
| 1213 | Status |
| 1214 | AudioFlingerServerAdapter::moveEffects(int32_t session, int32_t srcOutput, int32_t dstOutput) { |
| 1215 | audio_session_t sessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1216 | aidl2legacy_int32_t_audio_session_t(session)); |
| 1217 | audio_io_handle_t srcOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1218 | aidl2legacy_int32_t_audio_io_handle_t(srcOutput)); |
| 1219 | audio_io_handle_t dstOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1220 | aidl2legacy_int32_t_audio_io_handle_t(dstOutput)); |
| 1221 | return Status::fromStatusT( |
| 1222 | mDelegate->moveEffects(sessionLegacy, srcOutputLegacy, dstOutputLegacy)); |
| 1223 | } |
| 1224 | |
| 1225 | Status AudioFlingerServerAdapter::setEffectSuspended(int32_t effectId, int32_t sessionId, |
| 1226 | bool suspended) { |
| 1227 | int effectIdLegacy = VALUE_OR_RETURN_BINDER(convertReinterpret<int>(effectId)); |
| 1228 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1229 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1230 | mDelegate->setEffectSuspended(effectIdLegacy, sessionIdLegacy, suspended); |
| 1231 | return Status::ok(); |
| 1232 | } |
| 1233 | |
| 1234 | Status AudioFlingerServerAdapter::loadHwModule(const std::string& name, int32_t* _aidl_return) { |
| 1235 | audio_module_handle_t result = mDelegate->loadHwModule(name.c_str()); |
| 1236 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_module_handle_t_int32_t(result)); |
| 1237 | return Status::ok(); |
| 1238 | } |
| 1239 | |
| 1240 | Status AudioFlingerServerAdapter::getPrimaryOutputSamplingRate(int32_t* _aidl_return) { |
| 1241 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1242 | convertIntegral<int32_t>(mDelegate->getPrimaryOutputSamplingRate())); |
| 1243 | return Status::ok(); |
| 1244 | } |
| 1245 | |
| 1246 | Status AudioFlingerServerAdapter::getPrimaryOutputFrameCount(int64_t* _aidl_return) { |
| 1247 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1248 | convertIntegral<int64_t>(mDelegate->getPrimaryOutputFrameCount())); |
| 1249 | return Status::ok(); |
| 1250 | |
| 1251 | } |
| 1252 | |
| 1253 | Status AudioFlingerServerAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
| 1254 | return Status::fromStatusT(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
| 1255 | } |
| 1256 | |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1257 | Status AudioFlingerServerAdapter::getAudioPort(const media::AudioPortFw& port, |
| 1258 | media::AudioPortFw* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1259 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1260 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioPort(&portLegacy)); |
| 1261 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPort(portLegacy)); |
| 1262 | return Status::ok(); |
| 1263 | } |
| 1264 | |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1265 | Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatchFw& patch, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1266 | int32_t* _aidl_return) { |
| 1267 | audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatch_audio_patch(patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 1268 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1269 | aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1270 | RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy)); |
| 1271 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy)); |
| 1272 | return Status::ok(); |
| 1273 | } |
| 1274 | |
| 1275 | Status AudioFlingerServerAdapter::releaseAudioPatch(int32_t handle) { |
| 1276 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1277 | aidl2legacy_int32_t_audio_patch_handle_t(handle)); |
| 1278 | return Status::fromStatusT(mDelegate->releaseAudioPatch(handleLegacy)); |
| 1279 | } |
| 1280 | |
| 1281 | Status AudioFlingerServerAdapter::listAudioPatches(int32_t maxCount, |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame] | 1282 | std::vector<media::AudioPatchFw>* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1283 | unsigned int count = VALUE_OR_RETURN_BINDER(convertIntegral<unsigned int>(maxCount)); |
| 1284 | count = std::min(count, static_cast<unsigned int>(MAX_ITEMS_PER_LIST)); |
| 1285 | std::unique_ptr<audio_patch[]> patchesLegacy(new audio_patch[count]); |
| 1286 | RETURN_BINDER_IF_ERROR(mDelegate->listAudioPatches(&count, patchesLegacy.get())); |
| 1287 | RETURN_BINDER_IF_ERROR(convertRange(&patchesLegacy[0], |
| 1288 | &patchesLegacy[count], |
| 1289 | std::back_inserter(*_aidl_return), |
| 1290 | legacy2aidl_audio_patch_AudioPatch)); |
| 1291 | return Status::ok(); |
| 1292 | } |
| 1293 | |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 1294 | Status AudioFlingerServerAdapter::setAudioPortConfig(const media::AudioPortConfigFw& config) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1295 | audio_port_config configLegacy = VALUE_OR_RETURN_BINDER( |
| 1296 | aidl2legacy_AudioPortConfig_audio_port_config(config)); |
| 1297 | return Status::fromStatusT(mDelegate->setAudioPortConfig(&configLegacy)); |
| 1298 | } |
| 1299 | |
| 1300 | Status AudioFlingerServerAdapter::getAudioHwSyncForSession(int32_t sessionId, |
| 1301 | int32_t* _aidl_return) { |
| 1302 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1303 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1304 | audio_hw_sync_t result = mDelegate->getAudioHwSyncForSession(sessionIdLegacy); |
| 1305 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_hw_sync_t_int32_t(result)); |
| 1306 | return Status::ok(); |
| 1307 | } |
| 1308 | |
| 1309 | Status AudioFlingerServerAdapter::systemReady() { |
| 1310 | return Status::fromStatusT(mDelegate->systemReady()); |
| 1311 | } |
| 1312 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 1313 | Status AudioFlingerServerAdapter::audioPolicyReady() { |
| 1314 | mDelegate->audioPolicyReady(); |
| 1315 | return Status::ok(); |
| 1316 | } |
| 1317 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1318 | Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) { |
| 1319 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1320 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1321 | size_t result = mDelegate->frameCountHAL(ioHandleLegacy); |
| 1322 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(result)); |
| 1323 | return Status::ok(); |
| 1324 | } |
| 1325 | |
| 1326 | Status AudioFlingerServerAdapter::getMicrophones( |
| 1327 | std::vector<media::MicrophoneInfoData>* _aidl_return) { |
| 1328 | std::vector<media::MicrophoneInfo> resultLegacy; |
| 1329 | RETURN_BINDER_IF_ERROR(mDelegate->getMicrophones(&resultLegacy)); |
| 1330 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertContainer<std::vector<media::MicrophoneInfoData>>( |
| 1331 | resultLegacy, media::legacy2aidl_MicrophoneInfo)); |
| 1332 | return Status::ok(); |
| 1333 | } |
| 1334 | |
| 1335 | Status AudioFlingerServerAdapter::setAudioHalPids(const std::vector<int32_t>& pids) { |
| 1336 | std::vector<pid_t> pidsLegacy = VALUE_OR_RETURN_BINDER( |
| 1337 | convertContainer<std::vector<pid_t>>(pids, aidl2legacy_int32_t_pid_t)); |
| 1338 | RETURN_BINDER_IF_ERROR(mDelegate->setAudioHalPids(pidsLegacy)); |
| 1339 | return Status::ok(); |
| 1340 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1341 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 1342 | Status AudioFlingerServerAdapter::setVibratorInfos( |
| 1343 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 1344 | return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos)); |
| 1345 | } |
| 1346 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 1347 | Status AudioFlingerServerAdapter::updateSecondaryOutputs( |
| 1348 | const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) { |
| 1349 | TrackSecondaryOutputsMap trackSecondaryOutputs = |
| 1350 | VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>( |
| 1351 | trackSecondaryOutputInfos, |
| 1352 | aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair)); |
| 1353 | return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs)); |
| 1354 | } |
| 1355 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1356 | Status AudioFlingerServerAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 1357 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *_aidl_return) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1358 | return Status::fromStatusT(mDelegate->getMmapPolicyInfos(policyType, _aidl_return)); |
| 1359 | } |
| 1360 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 1361 | Status AudioFlingerServerAdapter::getAAudioMixerBurstCount(int32_t* _aidl_return) { |
| 1362 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1363 | convertIntegral<int32_t>(mDelegate->getAAudioMixerBurstCount())); |
| 1364 | return Status::ok(); |
| 1365 | } |
| 1366 | |
| 1367 | Status AudioFlingerServerAdapter::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) { |
| 1368 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1369 | convertIntegral<int32_t>(mDelegate->getAAudioHardwareBurstMinUsec())); |
| 1370 | return Status::ok(); |
| 1371 | } |
| 1372 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1373 | Status AudioFlingerServerAdapter::setDeviceConnectedState( |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1374 | const media::AudioPortFw& port, bool connected) { |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1375 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1376 | return Status::fromStatusT(mDelegate->setDeviceConnectedState(&portLegacy, connected)); |
| 1377 | } |
| 1378 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1379 | Status AudioFlingerServerAdapter::setRequestedLatencyMode( |
| 1380 | int32_t output, media::LatencyMode modeAidl) { |
| 1381 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1382 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1383 | audio_latency_mode_t modeLegacy = VALUE_OR_RETURN_BINDER( |
| 1384 | aidl2legacy_LatencyMode_audio_latency_mode_t(modeAidl)); |
| 1385 | return Status::fromStatusT(mDelegate->setRequestedLatencyMode( |
| 1386 | outputLegacy, modeLegacy)); |
| 1387 | } |
| 1388 | |
| 1389 | Status AudioFlingerServerAdapter::getSupportedLatencyModes( |
| 1390 | int output, std::vector<media::LatencyMode>* _aidl_return) { |
| 1391 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1392 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1393 | std::vector<audio_latency_mode_t> modesLegacy; |
| 1394 | |
| 1395 | RETURN_BINDER_IF_ERROR(mDelegate->getSupportedLatencyModes(outputLegacy, &modesLegacy)); |
| 1396 | |
| 1397 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1398 | convertContainer<std::vector<media::LatencyMode>>( |
| 1399 | modesLegacy, legacy2aidl_audio_latency_mode_t_LatencyMode)); |
| 1400 | return Status::ok(); |
| 1401 | } |
| 1402 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame^] | 1403 | Status AudioFlingerServerAdapter::setBluetoothVariableLatencyEnabled(bool enabled) { |
| 1404 | return Status::fromStatusT(mDelegate->setBluetoothVariableLatencyEnabled(enabled)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1405 | } |
| 1406 | |
Eric Laurent | 50d7258 | 2022-12-20 20:20:23 +0100 | [diff] [blame^] | 1407 | Status AudioFlingerServerAdapter::isBluetoothVariableLatencyEnabled(bool *enabled) { |
| 1408 | return Status::fromStatusT(mDelegate->isBluetoothVariableLatencyEnabled(enabled)); |
| 1409 | } |
| 1410 | |
| 1411 | Status AudioFlingerServerAdapter::supportsBluetoothVariableLatency(bool *support) { |
| 1412 | return Status::fromStatusT(mDelegate->supportsBluetoothVariableLatency(support)); |
Eric Laurent | 5205764 | 2022-12-16 11:45:07 +0100 | [diff] [blame] | 1413 | } |
| 1414 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1415 | Status AudioFlingerServerAdapter::getSoundDoseInterface( |
| 1416 | const sp<media::ISoundDoseCallback>& callback, |
| 1417 | sp<media::ISoundDose>* soundDose) |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1418 | { |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1419 | return Status::fromStatusT(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1420 | } |
| 1421 | |
jiabin | c44b346 | 2022-12-08 12:52:31 -0800 | [diff] [blame] | 1422 | Status AudioFlingerServerAdapter::invalidateTracks(const std::vector<int32_t>& portIds) { |
| 1423 | std::vector<audio_port_handle_t> portIdsLegacy = VALUE_OR_RETURN_BINDER( |
| 1424 | convertContainer<std::vector<audio_port_handle_t>>( |
| 1425 | portIds, aidl2legacy_int32_t_audio_port_handle_t)); |
| 1426 | RETURN_BINDER_IF_ERROR(mDelegate->invalidateTracks(portIdsLegacy)); |
| 1427 | return Status::ok(); |
| 1428 | } |
| 1429 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1430 | } // namespace android |