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 | |
| 496 | status_t AudioFlingerClientAdapter::invalidateStream(audio_stream_type_t stream) { |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 497 | AudioStreamType streamAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 498 | legacy2aidl_audio_stream_type_t_AudioStreamType(stream)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 499 | return statusTFromBinderStatus(mDelegate->invalidateStream(streamAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | status_t AudioFlingerClientAdapter::setVoiceVolume(float volume) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 503 | return statusTFromBinderStatus(mDelegate->setVoiceVolume(volume)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | status_t AudioFlingerClientAdapter::getRenderPosition(uint32_t* halFrames, uint32_t* dspFrames, |
| 507 | audio_io_handle_t output) const { |
| 508 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 509 | media::RenderPosition aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 510 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 511 | mDelegate->getRenderPosition(outputAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 512 | if (halFrames != nullptr) { |
| 513 | *halFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.halFrames)); |
| 514 | } |
| 515 | if (dspFrames != nullptr) { |
| 516 | *dspFrames = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet.dspFrames)); |
| 517 | } |
| 518 | return OK; |
| 519 | } |
| 520 | |
| 521 | uint32_t AudioFlingerClientAdapter::getInputFramesLost(audio_io_handle_t ioHandle) const { |
| 522 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 523 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 524 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 525 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 526 | mDelegate->getInputFramesLost(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 527 | return convertIntegral<uint32_t>(aidlRet); |
| 528 | }(); |
| 529 | // Failure is ignored. |
| 530 | return result.value_or(0); |
| 531 | } |
| 532 | |
| 533 | audio_unique_id_t AudioFlingerClientAdapter::newAudioUniqueId(audio_unique_id_use_t use) { |
| 534 | auto result = [&]() -> ConversionResult<audio_unique_id_t> { |
| 535 | media::AudioUniqueIdUse useAidl = VALUE_OR_RETURN( |
| 536 | legacy2aidl_audio_unique_id_use_t_AudioUniqueIdUse(use)); |
| 537 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 538 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 539 | mDelegate->newAudioUniqueId(useAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 540 | return aidl2legacy_int32_t_audio_unique_id_t(aidlRet); |
| 541 | }(); |
| 542 | return result.value_or(AUDIO_UNIQUE_ID_ALLOCATE); |
| 543 | } |
| 544 | |
| 545 | void AudioFlingerClientAdapter::acquireAudioSessionId(audio_session_t audioSession, pid_t pid, |
| 546 | uid_t uid) { |
| 547 | [&]() -> status_t { |
| 548 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 549 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 550 | int32_t pidAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_pid_t_int32_t(pid)); |
| 551 | 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] | 552 | return statusTFromBinderStatus( |
| 553 | mDelegate->acquireAudioSessionId(audioSessionAidl, pidAidl, uidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 554 | }(); |
| 555 | // Failure is ignored. |
| 556 | } |
| 557 | |
| 558 | void AudioFlingerClientAdapter::releaseAudioSessionId(audio_session_t audioSession, pid_t pid) { |
| 559 | [&]() -> status_t { |
| 560 | int32_t audioSessionAidl = VALUE_OR_RETURN_STATUS( |
| 561 | legacy2aidl_audio_session_t_int32_t(audioSession)); |
| 562 | 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] | 563 | return statusTFromBinderStatus( |
| 564 | mDelegate->releaseAudioSessionId(audioSessionAidl, pidAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 565 | }(); |
| 566 | // Failure is ignored. |
| 567 | } |
| 568 | |
| 569 | status_t AudioFlingerClientAdapter::queryNumberEffects(uint32_t* numEffects) const { |
| 570 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 571 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 572 | mDelegate->queryNumberEffects(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 573 | if (numEffects != nullptr) { |
| 574 | *numEffects = VALUE_OR_RETURN_STATUS(convertIntegral<uint32_t>(aidlRet)); |
| 575 | } |
| 576 | return OK; |
| 577 | } |
| 578 | |
| 579 | status_t |
| 580 | AudioFlingerClientAdapter::queryEffect(uint32_t index, effect_descriptor_t* pDescriptor) const { |
| 581 | int32_t indexAidl = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(index)); |
| 582 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 583 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 584 | mDelegate->queryEffect(indexAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 585 | if (pDescriptor != nullptr) { |
| 586 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 587 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 588 | } |
| 589 | return OK; |
| 590 | } |
| 591 | |
| 592 | status_t AudioFlingerClientAdapter::getEffectDescriptor(const effect_uuid_t* pEffectUUID, |
| 593 | const effect_uuid_t* pTypeUUID, |
| 594 | uint32_t preferredTypeFlag, |
| 595 | effect_descriptor_t* pDescriptor) const { |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 596 | AudioUuid effectUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 597 | legacy2aidl_audio_uuid_t_AudioUuid(*pEffectUUID)); |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 598 | AudioUuid typeUuidAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 599 | legacy2aidl_audio_uuid_t_AudioUuid(*pTypeUUID)); |
| 600 | int32_t preferredTypeFlagAidl = VALUE_OR_RETURN_STATUS( |
| 601 | convertReinterpret<int32_t>(preferredTypeFlag)); |
| 602 | media::EffectDescriptor aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 603 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 604 | mDelegate->getEffectDescriptor(effectUuidAidl, typeUuidAidl, preferredTypeFlagAidl, |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 605 | &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 606 | if (pDescriptor != nullptr) { |
| 607 | *pDescriptor = VALUE_OR_RETURN_STATUS( |
| 608 | aidl2legacy_EffectDescriptor_effect_descriptor_t(aidlRet)); |
| 609 | } |
| 610 | return OK; |
| 611 | } |
| 612 | |
| 613 | status_t AudioFlingerClientAdapter::createEffect(const media::CreateEffectRequest& request, |
| 614 | media::CreateEffectResponse* response) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 615 | return statusTFromBinderStatus(mDelegate->createEffect(request, response)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 616 | } |
| 617 | |
| 618 | status_t |
| 619 | AudioFlingerClientAdapter::moveEffects(audio_session_t session, audio_io_handle_t srcOutput, |
| 620 | audio_io_handle_t dstOutput) { |
| 621 | int32_t sessionAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_session_t_int32_t(session)); |
| 622 | int32_t srcOutputAidl = VALUE_OR_RETURN_STATUS( |
| 623 | legacy2aidl_audio_io_handle_t_int32_t(srcOutput)); |
| 624 | int32_t dstOutputAidl = VALUE_OR_RETURN_STATUS( |
| 625 | legacy2aidl_audio_io_handle_t_int32_t(dstOutput)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 626 | return statusTFromBinderStatus( |
| 627 | mDelegate->moveEffects(sessionAidl, srcOutputAidl, dstOutputAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | void AudioFlingerClientAdapter::setEffectSuspended(int effectId, |
| 631 | audio_session_t sessionId, |
| 632 | bool suspended) { |
| 633 | [&]() -> status_t { |
| 634 | int32_t effectIdAidl = VALUE_OR_RETURN_STATUS(convertReinterpret<int32_t>(effectId)); |
| 635 | int32_t sessionIdAidl = VALUE_OR_RETURN_STATUS( |
| 636 | legacy2aidl_audio_session_t_int32_t(sessionId)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 637 | return statusTFromBinderStatus( |
| 638 | mDelegate->setEffectSuspended(effectIdAidl, sessionIdAidl, suspended)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 639 | }(); |
| 640 | // Failure is ignored. |
| 641 | } |
| 642 | |
| 643 | audio_module_handle_t AudioFlingerClientAdapter::loadHwModule(const char* name) { |
| 644 | auto result = [&]() -> ConversionResult<audio_module_handle_t> { |
| 645 | std::string nameAidl(name); |
| 646 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 647 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 648 | mDelegate->loadHwModule(nameAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 649 | return aidl2legacy_int32_t_audio_module_handle_t(aidlRet); |
| 650 | }(); |
| 651 | // Failure is ignored. |
| 652 | return result.value_or(0); |
| 653 | } |
| 654 | |
| 655 | uint32_t AudioFlingerClientAdapter::getPrimaryOutputSamplingRate() { |
| 656 | auto result = [&]() -> ConversionResult<uint32_t> { |
| 657 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 658 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 659 | mDelegate->getPrimaryOutputSamplingRate(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 660 | return convertIntegral<uint32_t>(aidlRet); |
| 661 | }(); |
| 662 | // Failure is ignored. |
| 663 | return result.value_or(0); |
| 664 | } |
| 665 | |
| 666 | size_t AudioFlingerClientAdapter::getPrimaryOutputFrameCount() { |
| 667 | auto result = [&]() -> ConversionResult<size_t> { |
| 668 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 669 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 670 | mDelegate->getPrimaryOutputFrameCount(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 671 | return convertIntegral<size_t>(aidlRet); |
| 672 | }(); |
| 673 | // Failure is ignored. |
| 674 | return result.value_or(0); |
| 675 | } |
| 676 | |
| 677 | status_t AudioFlingerClientAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 678 | return statusTFromBinderStatus(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 679 | } |
| 680 | |
| 681 | status_t AudioFlingerClientAdapter::getAudioPort(struct audio_port_v7* port) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 682 | media::AudioPortFw portAidl = VALUE_OR_RETURN_STATUS( |
| 683 | legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 684 | media::AudioPortFw aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 685 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 686 | mDelegate->getAudioPort(portAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 687 | *port = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioPort_audio_port_v7(aidlRet)); |
| 688 | return OK; |
| 689 | } |
| 690 | |
| 691 | status_t AudioFlingerClientAdapter::createAudioPatch(const struct audio_patch* patch, |
| 692 | audio_patch_handle_t* handle) { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame^] | 693 | media::AudioPatchFw patchAidl = VALUE_OR_RETURN_STATUS( |
| 694 | legacy2aidl_audio_patch_AudioPatch(*patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 695 | int32_t aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t( |
| 696 | AUDIO_PATCH_HANDLE_NONE)); |
| 697 | if (handle != nullptr) { |
| 698 | aidlRet = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_patch_handle_t_int32_t(*handle)); |
| 699 | } |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 700 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 701 | mDelegate->createAudioPatch(patchAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 702 | if (handle != nullptr) { |
| 703 | *handle = VALUE_OR_RETURN_STATUS(aidl2legacy_int32_t_audio_patch_handle_t(aidlRet)); |
| 704 | } |
| 705 | return OK; |
| 706 | } |
| 707 | |
| 708 | status_t AudioFlingerClientAdapter::releaseAudioPatch(audio_patch_handle_t handle) { |
| 709 | 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] | 710 | return statusTFromBinderStatus(mDelegate->releaseAudioPatch(handleAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 711 | } |
| 712 | |
| 713 | status_t AudioFlingerClientAdapter::listAudioPatches(unsigned int* num_patches, |
| 714 | struct audio_patch* patches) { |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame^] | 715 | std::vector<media::AudioPatchFw> aidlRet; |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 716 | int32_t maxPatches = VALUE_OR_RETURN_STATUS(convertIntegral<int32_t>(*num_patches)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 717 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 718 | mDelegate->listAudioPatches(maxPatches, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 719 | *num_patches = VALUE_OR_RETURN_STATUS(convertIntegral<unsigned int>(aidlRet.size())); |
| 720 | return convertRange(aidlRet.begin(), aidlRet.end(), patches, |
| 721 | aidl2legacy_AudioPatch_audio_patch); |
| 722 | } |
| 723 | |
| 724 | status_t AudioFlingerClientAdapter::setAudioPortConfig(const struct audio_port_config* config) { |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 725 | media::AudioPortConfigFw configAidl = VALUE_OR_RETURN_STATUS( |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 726 | legacy2aidl_audio_port_config_AudioPortConfig(*config)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 727 | return statusTFromBinderStatus(mDelegate->setAudioPortConfig(configAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 728 | } |
| 729 | |
| 730 | audio_hw_sync_t AudioFlingerClientAdapter::getAudioHwSyncForSession(audio_session_t sessionId) { |
| 731 | auto result = [&]() -> ConversionResult<audio_hw_sync_t> { |
| 732 | int32_t sessionIdAidl = VALUE_OR_RETURN(legacy2aidl_audio_session_t_int32_t(sessionId)); |
| 733 | int32_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 734 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 735 | mDelegate->getAudioHwSyncForSession(sessionIdAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 736 | return aidl2legacy_int32_t_audio_hw_sync_t(aidlRet); |
| 737 | }(); |
| 738 | return result.value_or(AUDIO_HW_SYNC_INVALID); |
| 739 | } |
| 740 | |
| 741 | status_t AudioFlingerClientAdapter::systemReady() { |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 742 | return statusTFromBinderStatus(mDelegate->systemReady()); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 743 | } |
| 744 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 745 | status_t AudioFlingerClientAdapter::audioPolicyReady() { |
| 746 | return statusTFromBinderStatus(mDelegate->audioPolicyReady()); |
| 747 | } |
| 748 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 749 | size_t AudioFlingerClientAdapter::frameCountHAL(audio_io_handle_t ioHandle) const { |
| 750 | auto result = [&]() -> ConversionResult<size_t> { |
| 751 | int32_t ioHandleAidl = VALUE_OR_RETURN(legacy2aidl_audio_io_handle_t_int32_t(ioHandle)); |
| 752 | int64_t aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 753 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 754 | mDelegate->frameCountHAL(ioHandleAidl, &aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 755 | return convertIntegral<size_t>(aidlRet); |
| 756 | }(); |
| 757 | // Failure is ignored. |
| 758 | return result.value_or(0); |
| 759 | } |
| 760 | |
| 761 | status_t |
| 762 | AudioFlingerClientAdapter::getMicrophones(std::vector<media::MicrophoneInfo>* microphones) { |
| 763 | std::vector<media::MicrophoneInfoData> aidlRet; |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 764 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 765 | mDelegate->getMicrophones(&aidlRet))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 766 | if (microphones != nullptr) { |
| 767 | *microphones = VALUE_OR_RETURN_STATUS( |
| 768 | convertContainer<std::vector<media::MicrophoneInfo>>(aidlRet, |
| 769 | media::aidl2legacy_MicrophoneInfo)); |
| 770 | } |
| 771 | return OK; |
| 772 | } |
| 773 | |
| 774 | status_t AudioFlingerClientAdapter::setAudioHalPids(const std::vector<pid_t>& pids) { |
| 775 | std::vector<int32_t> pidsAidl = VALUE_OR_RETURN_STATUS( |
| 776 | convertContainer<std::vector<int32_t>>(pids, legacy2aidl_pid_t_int32_t)); |
Andy Hung | 1131b6e | 2020-12-08 20:47:45 -0800 | [diff] [blame] | 777 | return statusTFromBinderStatus(mDelegate->setAudioHalPids(pidsAidl)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 778 | } |
| 779 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 780 | status_t AudioFlingerClientAdapter::setVibratorInfos( |
| 781 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 782 | return statusTFromBinderStatus(mDelegate->setVibratorInfos(vibratorInfos)); |
| 783 | } |
| 784 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 785 | status_t AudioFlingerClientAdapter::updateSecondaryOutputs( |
| 786 | const TrackSecondaryOutputsMap& trackSecondaryOutputs) { |
| 787 | std::vector<media::TrackSecondaryOutputInfo> trackSecondaryOutputInfos = |
| 788 | VALUE_OR_RETURN_STATUS( |
| 789 | convertContainer<std::vector<media::TrackSecondaryOutputInfo>>( |
| 790 | trackSecondaryOutputs, |
| 791 | legacy2aidl_TrackSecondaryOutputInfoPair_TrackSecondaryOutputInfo)); |
| 792 | return statusTFromBinderStatus(mDelegate->updateSecondaryOutputs(trackSecondaryOutputInfos)); |
| 793 | } |
| 794 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 795 | status_t AudioFlingerClientAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 796 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *policyInfos) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 797 | return statusTFromBinderStatus(mDelegate->getMmapPolicyInfos(policyType, policyInfos)); |
| 798 | } |
| 799 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 800 | int32_t AudioFlingerClientAdapter::getAAudioMixerBurstCount() { |
| 801 | auto result = [&]() -> ConversionResult<int32_t> { |
| 802 | int32_t aidlRet; |
| 803 | RETURN_IF_ERROR(statusTFromBinderStatus(mDelegate->getAAudioMixerBurstCount(&aidlRet))); |
| 804 | return convertIntegral<int32_t>(aidlRet); |
| 805 | }(); |
| 806 | // Failure is ignored. |
| 807 | return result.value_or(0); |
| 808 | } |
| 809 | |
| 810 | int32_t AudioFlingerClientAdapter::getAAudioHardwareBurstMinUsec() { |
| 811 | auto result = [&]() -> ConversionResult<int32_t> { |
| 812 | int32_t aidlRet; |
| 813 | RETURN_IF_ERROR(statusTFromBinderStatus( |
| 814 | mDelegate->getAAudioHardwareBurstMinUsec(&aidlRet))); |
| 815 | return convertIntegral<int32_t>(aidlRet); |
| 816 | }(); |
| 817 | // Failure is ignored. |
| 818 | return result.value_or(0); |
| 819 | } |
| 820 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 821 | status_t AudioFlingerClientAdapter::setDeviceConnectedState( |
| 822 | const struct audio_port_v7 *port, bool connected) { |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 823 | media::AudioPortFw aidlPort = VALUE_OR_RETURN_STATUS( |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 824 | legacy2aidl_audio_port_v7_AudioPort(*port)); |
| 825 | return statusTFromBinderStatus(mDelegate->setDeviceConnectedState(aidlPort, connected)); |
| 826 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 827 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 828 | status_t AudioFlingerClientAdapter::setRequestedLatencyMode( |
| 829 | audio_io_handle_t output, audio_latency_mode_t mode) { |
| 830 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 831 | media::LatencyMode modeAidl = VALUE_OR_RETURN_STATUS( |
| 832 | legacy2aidl_audio_latency_mode_t_LatencyMode(mode)); |
| 833 | return statusTFromBinderStatus(mDelegate->setRequestedLatencyMode(outputAidl, modeAidl)); |
| 834 | } |
| 835 | |
| 836 | status_t AudioFlingerClientAdapter::getSupportedLatencyModes( |
| 837 | audio_io_handle_t output, std::vector<audio_latency_mode_t>* modes) { |
| 838 | if (modes == nullptr) { |
| 839 | return BAD_VALUE; |
| 840 | } |
| 841 | |
| 842 | int32_t outputAidl = VALUE_OR_RETURN_STATUS(legacy2aidl_audio_io_handle_t_int32_t(output)); |
| 843 | std::vector<media::LatencyMode> modesAidl; |
| 844 | |
| 845 | RETURN_STATUS_IF_ERROR(statusTFromBinderStatus( |
| 846 | mDelegate->getSupportedLatencyModes(outputAidl, &modesAidl))); |
| 847 | |
| 848 | *modes = VALUE_OR_RETURN_STATUS( |
| 849 | convertContainer<std::vector<audio_latency_mode_t>>(modesAidl, |
| 850 | aidl2legacy_LatencyMode_audio_latency_mode_t)); |
| 851 | |
| 852 | return NO_ERROR; |
| 853 | } |
| 854 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 855 | status_t AudioFlingerClientAdapter::getSoundDoseInterface( |
| 856 | const sp<media::ISoundDoseCallback> &callback, |
| 857 | sp<media::ISoundDose>* soundDose) { |
| 858 | return statusTFromBinderStatus(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 859 | } |
| 860 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 861 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 862 | // AudioFlingerServerAdapter |
| 863 | AudioFlingerServerAdapter::AudioFlingerServerAdapter( |
Andy Hung | 225aef6 | 2022-12-06 16:33:20 -0800 | [diff] [blame] | 864 | const sp<AudioFlingerServerAdapter::Delegate>& delegate) : mDelegate(delegate) { |
| 865 | setMinSchedulerPolicy(SCHED_NORMAL, ANDROID_PRIORITY_AUDIO); |
| 866 | } |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 867 | |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 868 | status_t AudioFlingerServerAdapter::onTransact(uint32_t code, |
| 869 | const Parcel& data, |
| 870 | Parcel* reply, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 871 | uint32_t flags) { |
Ytai Ben-Tsvi | 24b33fc | 2021-05-10 13:08:11 -0700 | [diff] [blame] | 872 | return mDelegate->onTransactWrapper(static_cast<Delegate::TransactionCode>(code), |
| 873 | data, |
| 874 | flags, |
| 875 | [&] { |
| 876 | return BnAudioFlingerService::onTransact( |
| 877 | code, |
| 878 | data, |
| 879 | reply, |
| 880 | flags); |
| 881 | }); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 882 | } |
| 883 | |
| 884 | status_t AudioFlingerServerAdapter::dump(int fd, const Vector<String16>& args) { |
| 885 | return mDelegate->dump(fd, args); |
| 886 | } |
| 887 | |
| 888 | Status AudioFlingerServerAdapter::createTrack(const media::CreateTrackRequest& request, |
| 889 | media::CreateTrackResponse* _aidl_return) { |
| 890 | return Status::fromStatusT(mDelegate->createTrack(request, *_aidl_return)); |
| 891 | } |
| 892 | |
| 893 | Status AudioFlingerServerAdapter::createRecord(const media::CreateRecordRequest& request, |
| 894 | media::CreateRecordResponse* _aidl_return) { |
| 895 | return Status::fromStatusT(mDelegate->createRecord(request, *_aidl_return)); |
| 896 | } |
| 897 | |
| 898 | Status AudioFlingerServerAdapter::sampleRate(int32_t ioHandle, int32_t* _aidl_return) { |
| 899 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 900 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 901 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 902 | convertIntegral<int32_t>(mDelegate->sampleRate(ioHandleLegacy))); |
| 903 | return Status::ok(); |
| 904 | } |
| 905 | |
| 906 | Status AudioFlingerServerAdapter::format(int32_t output, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 907 | AudioFormatDescription* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 908 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 909 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 910 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 911 | legacy2aidl_audio_format_t_AudioFormatDescription(mDelegate->format(outputLegacy))); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 912 | return Status::ok(); |
| 913 | } |
| 914 | |
| 915 | Status AudioFlingerServerAdapter::frameCount(int32_t ioHandle, int64_t* _aidl_return) { |
| 916 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 917 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 918 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 919 | convertIntegral<int64_t>(mDelegate->frameCount(ioHandleLegacy))); |
| 920 | return Status::ok(); |
| 921 | } |
| 922 | |
| 923 | Status AudioFlingerServerAdapter::latency(int32_t output, int32_t* _aidl_return) { |
| 924 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 925 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 926 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 927 | convertIntegral<int32_t>(mDelegate->latency(outputLegacy))); |
| 928 | return Status::ok(); |
| 929 | } |
| 930 | |
| 931 | Status AudioFlingerServerAdapter::setMasterVolume(float value) { |
| 932 | return Status::fromStatusT(mDelegate->setMasterVolume(value)); |
| 933 | } |
| 934 | |
| 935 | Status AudioFlingerServerAdapter::setMasterMute(bool muted) { |
| 936 | return Status::fromStatusT(mDelegate->setMasterMute(muted)); |
| 937 | } |
| 938 | |
| 939 | Status AudioFlingerServerAdapter::masterVolume(float* _aidl_return) { |
| 940 | *_aidl_return = mDelegate->masterVolume(); |
| 941 | return Status::ok(); |
| 942 | } |
| 943 | |
| 944 | Status AudioFlingerServerAdapter::masterMute(bool* _aidl_return) { |
| 945 | *_aidl_return = mDelegate->masterMute(); |
| 946 | return Status::ok(); |
| 947 | } |
| 948 | |
| 949 | Status AudioFlingerServerAdapter::setMasterBalance(float balance) { |
| 950 | return Status::fromStatusT(mDelegate->setMasterBalance(balance)); |
| 951 | } |
| 952 | |
| 953 | Status AudioFlingerServerAdapter::getMasterBalance(float* _aidl_return) { |
| 954 | return Status::fromStatusT(mDelegate->getMasterBalance(_aidl_return)); |
| 955 | } |
| 956 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 957 | Status AudioFlingerServerAdapter::setStreamVolume(AudioStreamType stream, float value, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 958 | int32_t output) { |
| 959 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 960 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 961 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 962 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 963 | return Status::fromStatusT(mDelegate->setStreamVolume(streamLegacy, value, outputLegacy)); |
| 964 | } |
| 965 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 966 | Status AudioFlingerServerAdapter::setStreamMute(AudioStreamType stream, bool muted) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 967 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 968 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 969 | return Status::fromStatusT(mDelegate->setStreamMute(streamLegacy, muted)); |
| 970 | } |
| 971 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 972 | Status AudioFlingerServerAdapter::streamVolume(AudioStreamType stream, int32_t output, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 973 | float* _aidl_return) { |
| 974 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 975 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 976 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 977 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 978 | *_aidl_return = mDelegate->streamVolume(streamLegacy, outputLegacy); |
| 979 | return Status::ok(); |
| 980 | } |
| 981 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 982 | Status AudioFlingerServerAdapter::streamMute(AudioStreamType stream, bool* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 983 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 984 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 985 | *_aidl_return = mDelegate->streamMute(streamLegacy); |
| 986 | return Status::ok(); |
| 987 | } |
| 988 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 989 | Status AudioFlingerServerAdapter::setMode(AudioMode mode) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 990 | audio_mode_t modeLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioMode_audio_mode_t(mode)); |
| 991 | return Status::fromStatusT(mDelegate->setMode(modeLegacy)); |
| 992 | } |
| 993 | |
| 994 | Status AudioFlingerServerAdapter::setMicMute(bool state) { |
| 995 | return Status::fromStatusT(mDelegate->setMicMute(state)); |
| 996 | } |
| 997 | |
| 998 | Status AudioFlingerServerAdapter::getMicMute(bool* _aidl_return) { |
| 999 | *_aidl_return = mDelegate->getMicMute(); |
| 1000 | return Status::ok(); |
| 1001 | } |
| 1002 | |
| 1003 | Status AudioFlingerServerAdapter::setRecordSilenced(int32_t portId, bool silenced) { |
| 1004 | audio_port_handle_t portIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1005 | aidl2legacy_int32_t_audio_port_handle_t(portId)); |
| 1006 | mDelegate->setRecordSilenced(portIdLegacy, silenced); |
| 1007 | return Status::ok(); |
| 1008 | } |
| 1009 | |
| 1010 | Status |
| 1011 | AudioFlingerServerAdapter::setParameters(int32_t ioHandle, const std::string& keyValuePairs) { |
| 1012 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1013 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1014 | String8 keyValuePairsLegacy = VALUE_OR_RETURN_BINDER( |
| 1015 | aidl2legacy_string_view_String8(keyValuePairs)); |
| 1016 | return Status::fromStatusT(mDelegate->setParameters(ioHandleLegacy, keyValuePairsLegacy)); |
| 1017 | } |
| 1018 | |
| 1019 | Status AudioFlingerServerAdapter::getParameters(int32_t ioHandle, const std::string& keys, |
| 1020 | std::string* _aidl_return) { |
| 1021 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1022 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1023 | String8 keysLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_string_view_String8(keys)); |
| 1024 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1025 | legacy2aidl_String8_string(mDelegate->getParameters(ioHandleLegacy, keysLegacy))); |
| 1026 | return Status::ok(); |
| 1027 | } |
| 1028 | |
| 1029 | Status AudioFlingerServerAdapter::registerClient(const sp<media::IAudioFlingerClient>& client) { |
| 1030 | mDelegate->registerClient(client); |
| 1031 | return Status::ok(); |
| 1032 | } |
| 1033 | |
| 1034 | Status AudioFlingerServerAdapter::getInputBufferSize(int32_t sampleRate, |
Mikhail Naganov | 57bd06f | 2021-08-10 16:41:54 -0700 | [diff] [blame] | 1035 | const AudioFormatDescription& format, |
| 1036 | const AudioChannelLayout& channelMask, |
Mikhail Naganov | 2d8df4e | 2021-06-03 13:59:13 -0700 | [diff] [blame] | 1037 | int64_t* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1038 | uint32_t sampleRateLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(sampleRate)); |
| 1039 | audio_format_t formatLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | b60bd1b | 2021-07-15 17:31:43 -0700 | [diff] [blame] | 1040 | aidl2legacy_AudioFormatDescription_audio_format_t(format)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1041 | audio_channel_mask_t channelMaskLegacy = VALUE_OR_RETURN_BINDER( |
Mikhail Naganov | de3fa18 | 2021-07-30 15:06:42 -0700 | [diff] [blame] | 1042 | aidl2legacy_AudioChannelLayout_audio_channel_mask_t(channelMask, true /*isInput*/)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1043 | size_t size = mDelegate->getInputBufferSize(sampleRateLegacy, formatLegacy, channelMaskLegacy); |
| 1044 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(size)); |
| 1045 | return Status::ok(); |
| 1046 | } |
| 1047 | |
| 1048 | Status AudioFlingerServerAdapter::openOutput(const media::OpenOutputRequest& request, |
| 1049 | media::OpenOutputResponse* _aidl_return) { |
| 1050 | return Status::fromStatusT(mDelegate->openOutput(request, _aidl_return)); |
| 1051 | } |
| 1052 | |
| 1053 | Status AudioFlingerServerAdapter::openDuplicateOutput(int32_t output1, int32_t output2, |
| 1054 | int32_t* _aidl_return) { |
| 1055 | audio_io_handle_t output1Legacy = VALUE_OR_RETURN_BINDER( |
| 1056 | aidl2legacy_int32_t_audio_io_handle_t(output1)); |
| 1057 | audio_io_handle_t output2Legacy = VALUE_OR_RETURN_BINDER( |
| 1058 | aidl2legacy_int32_t_audio_io_handle_t(output2)); |
| 1059 | audio_io_handle_t result = mDelegate->openDuplicateOutput(output1Legacy, output2Legacy); |
| 1060 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_io_handle_t_int32_t(result)); |
| 1061 | return Status::ok(); |
| 1062 | } |
| 1063 | |
| 1064 | Status AudioFlingerServerAdapter::closeOutput(int32_t output) { |
| 1065 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1066 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1067 | return Status::fromStatusT(mDelegate->closeOutput(outputLegacy)); |
| 1068 | } |
| 1069 | |
| 1070 | Status AudioFlingerServerAdapter::suspendOutput(int32_t output) { |
| 1071 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1072 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1073 | return Status::fromStatusT(mDelegate->suspendOutput(outputLegacy)); |
| 1074 | } |
| 1075 | |
| 1076 | Status AudioFlingerServerAdapter::restoreOutput(int32_t output) { |
| 1077 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1078 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1079 | return Status::fromStatusT(mDelegate->restoreOutput(outputLegacy)); |
| 1080 | } |
| 1081 | |
| 1082 | Status AudioFlingerServerAdapter::openInput(const media::OpenInputRequest& request, |
| 1083 | media::OpenInputResponse* _aidl_return) { |
| 1084 | return Status::fromStatusT(mDelegate->openInput(request, _aidl_return)); |
| 1085 | } |
| 1086 | |
| 1087 | Status AudioFlingerServerAdapter::closeInput(int32_t input) { |
| 1088 | audio_io_handle_t inputLegacy = VALUE_OR_RETURN_BINDER( |
| 1089 | aidl2legacy_int32_t_audio_io_handle_t(input)); |
| 1090 | return Status::fromStatusT(mDelegate->closeInput(inputLegacy)); |
| 1091 | } |
| 1092 | |
Mikhail Naganov | dbf0364 | 2021-08-25 18:15:32 -0700 | [diff] [blame] | 1093 | Status AudioFlingerServerAdapter::invalidateStream(AudioStreamType stream) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1094 | audio_stream_type_t streamLegacy = VALUE_OR_RETURN_BINDER( |
| 1095 | aidl2legacy_AudioStreamType_audio_stream_type_t(stream)); |
| 1096 | return Status::fromStatusT(mDelegate->invalidateStream(streamLegacy)); |
| 1097 | } |
| 1098 | |
| 1099 | Status AudioFlingerServerAdapter::setVoiceVolume(float volume) { |
| 1100 | return Status::fromStatusT(mDelegate->setVoiceVolume(volume)); |
| 1101 | } |
| 1102 | |
| 1103 | Status |
| 1104 | AudioFlingerServerAdapter::getRenderPosition(int32_t output, media::RenderPosition* _aidl_return) { |
| 1105 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1106 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1107 | uint32_t halFramesLegacy; |
| 1108 | uint32_t dspFramesLegacy; |
| 1109 | RETURN_BINDER_IF_ERROR( |
| 1110 | mDelegate->getRenderPosition(&halFramesLegacy, &dspFramesLegacy, outputLegacy)); |
| 1111 | _aidl_return->halFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(halFramesLegacy)); |
| 1112 | _aidl_return->dspFrames = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(dspFramesLegacy)); |
| 1113 | return Status::ok(); |
| 1114 | } |
| 1115 | |
| 1116 | Status AudioFlingerServerAdapter::getInputFramesLost(int32_t ioHandle, int32_t* _aidl_return) { |
| 1117 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1118 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1119 | uint32_t result = mDelegate->getInputFramesLost(ioHandleLegacy); |
| 1120 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int32_t>(result)); |
| 1121 | return Status::ok(); |
| 1122 | } |
| 1123 | |
| 1124 | Status |
| 1125 | AudioFlingerServerAdapter::newAudioUniqueId(media::AudioUniqueIdUse use, int32_t* _aidl_return) { |
| 1126 | audio_unique_id_use_t useLegacy = VALUE_OR_RETURN_BINDER( |
| 1127 | aidl2legacy_AudioUniqueIdUse_audio_unique_id_use_t(use)); |
| 1128 | audio_unique_id_t result = mDelegate->newAudioUniqueId(useLegacy); |
| 1129 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_unique_id_t_int32_t(result)); |
| 1130 | return Status::ok(); |
| 1131 | } |
| 1132 | |
| 1133 | Status |
| 1134 | AudioFlingerServerAdapter::acquireAudioSessionId(int32_t audioSession, int32_t pid, int32_t uid) { |
| 1135 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1136 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1137 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1138 | uid_t uidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_uid_t(uid)); |
| 1139 | mDelegate->acquireAudioSessionId(audioSessionLegacy, pidLegacy, uidLegacy); |
| 1140 | return Status::ok(); |
| 1141 | } |
| 1142 | |
| 1143 | Status AudioFlingerServerAdapter::releaseAudioSessionId(int32_t audioSession, int32_t pid) { |
| 1144 | audio_session_t audioSessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1145 | aidl2legacy_int32_t_audio_session_t(audioSession)); |
| 1146 | pid_t pidLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_int32_t_pid_t(pid)); |
| 1147 | mDelegate->releaseAudioSessionId(audioSessionLegacy, pidLegacy); |
| 1148 | return Status::ok(); |
| 1149 | } |
| 1150 | |
| 1151 | Status AudioFlingerServerAdapter::queryNumberEffects(int32_t* _aidl_return) { |
| 1152 | uint32_t result; |
| 1153 | RETURN_BINDER_IF_ERROR(mDelegate->queryNumberEffects(&result)); |
| 1154 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(result)); |
| 1155 | return Status::ok(); |
| 1156 | } |
| 1157 | |
| 1158 | Status |
| 1159 | AudioFlingerServerAdapter::queryEffect(int32_t index, media::EffectDescriptor* _aidl_return) { |
| 1160 | uint32_t indexLegacy = VALUE_OR_RETURN_BINDER(convertIntegral<uint32_t>(index)); |
| 1161 | effect_descriptor_t result; |
| 1162 | RETURN_BINDER_IF_ERROR(mDelegate->queryEffect(indexLegacy, &result)); |
| 1163 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1164 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1165 | return Status::ok(); |
| 1166 | } |
| 1167 | |
Mikhail Naganov | ddceecc | 2021-09-03 13:58:56 -0700 | [diff] [blame] | 1168 | Status AudioFlingerServerAdapter::getEffectDescriptor(const AudioUuid& effectUUID, |
| 1169 | const AudioUuid& typeUUID, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1170 | int32_t preferredTypeFlag, |
| 1171 | media::EffectDescriptor* _aidl_return) { |
| 1172 | effect_uuid_t effectUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1173 | aidl2legacy_AudioUuid_audio_uuid_t(effectUUID)); |
| 1174 | effect_uuid_t typeUuidLegacy = VALUE_OR_RETURN_BINDER( |
| 1175 | aidl2legacy_AudioUuid_audio_uuid_t(typeUUID)); |
| 1176 | uint32_t preferredTypeFlagLegacy = VALUE_OR_RETURN_BINDER( |
| 1177 | convertReinterpret<uint32_t>(preferredTypeFlag)); |
| 1178 | effect_descriptor_t result; |
| 1179 | RETURN_BINDER_IF_ERROR(mDelegate->getEffectDescriptor(&effectUuidLegacy, &typeUuidLegacy, |
| 1180 | preferredTypeFlagLegacy, &result)); |
| 1181 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1182 | legacy2aidl_effect_descriptor_t_EffectDescriptor(result)); |
| 1183 | return Status::ok(); |
| 1184 | } |
| 1185 | |
| 1186 | Status AudioFlingerServerAdapter::createEffect(const media::CreateEffectRequest& request, |
| 1187 | media::CreateEffectResponse* _aidl_return) { |
| 1188 | return Status::fromStatusT(mDelegate->createEffect(request, _aidl_return)); |
| 1189 | } |
| 1190 | |
| 1191 | Status |
| 1192 | AudioFlingerServerAdapter::moveEffects(int32_t session, int32_t srcOutput, int32_t dstOutput) { |
| 1193 | audio_session_t sessionLegacy = VALUE_OR_RETURN_BINDER( |
| 1194 | aidl2legacy_int32_t_audio_session_t(session)); |
| 1195 | audio_io_handle_t srcOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1196 | aidl2legacy_int32_t_audio_io_handle_t(srcOutput)); |
| 1197 | audio_io_handle_t dstOutputLegacy = VALUE_OR_RETURN_BINDER( |
| 1198 | aidl2legacy_int32_t_audio_io_handle_t(dstOutput)); |
| 1199 | return Status::fromStatusT( |
| 1200 | mDelegate->moveEffects(sessionLegacy, srcOutputLegacy, dstOutputLegacy)); |
| 1201 | } |
| 1202 | |
| 1203 | Status AudioFlingerServerAdapter::setEffectSuspended(int32_t effectId, int32_t sessionId, |
| 1204 | bool suspended) { |
| 1205 | int effectIdLegacy = VALUE_OR_RETURN_BINDER(convertReinterpret<int>(effectId)); |
| 1206 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1207 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1208 | mDelegate->setEffectSuspended(effectIdLegacy, sessionIdLegacy, suspended); |
| 1209 | return Status::ok(); |
| 1210 | } |
| 1211 | |
| 1212 | Status AudioFlingerServerAdapter::loadHwModule(const std::string& name, int32_t* _aidl_return) { |
| 1213 | audio_module_handle_t result = mDelegate->loadHwModule(name.c_str()); |
| 1214 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_module_handle_t_int32_t(result)); |
| 1215 | return Status::ok(); |
| 1216 | } |
| 1217 | |
| 1218 | Status AudioFlingerServerAdapter::getPrimaryOutputSamplingRate(int32_t* _aidl_return) { |
| 1219 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1220 | convertIntegral<int32_t>(mDelegate->getPrimaryOutputSamplingRate())); |
| 1221 | return Status::ok(); |
| 1222 | } |
| 1223 | |
| 1224 | Status AudioFlingerServerAdapter::getPrimaryOutputFrameCount(int64_t* _aidl_return) { |
| 1225 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1226 | convertIntegral<int64_t>(mDelegate->getPrimaryOutputFrameCount())); |
| 1227 | return Status::ok(); |
| 1228 | |
| 1229 | } |
| 1230 | |
| 1231 | Status AudioFlingerServerAdapter::setLowRamDevice(bool isLowRamDevice, int64_t totalMemory) { |
| 1232 | return Status::fromStatusT(mDelegate->setLowRamDevice(isLowRamDevice, totalMemory)); |
| 1233 | } |
| 1234 | |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1235 | Status AudioFlingerServerAdapter::getAudioPort(const media::AudioPortFw& port, |
| 1236 | media::AudioPortFw* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1237 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1238 | RETURN_BINDER_IF_ERROR(mDelegate->getAudioPort(&portLegacy)); |
| 1239 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_port_v7_AudioPort(portLegacy)); |
| 1240 | return Status::ok(); |
| 1241 | } |
| 1242 | |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame^] | 1243 | Status AudioFlingerServerAdapter::createAudioPatch(const media::AudioPatchFw& patch, |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1244 | int32_t* _aidl_return) { |
| 1245 | audio_patch patchLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPatch_audio_patch(patch)); |
Kuowei Li | 247a367 | 2021-07-21 21:46:07 +0800 | [diff] [blame] | 1246 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1247 | aidl2legacy_int32_t_audio_patch_handle_t(*_aidl_return)); |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1248 | RETURN_BINDER_IF_ERROR(mDelegate->createAudioPatch(&patchLegacy, &handleLegacy)); |
| 1249 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_patch_handle_t_int32_t(handleLegacy)); |
| 1250 | return Status::ok(); |
| 1251 | } |
| 1252 | |
| 1253 | Status AudioFlingerServerAdapter::releaseAudioPatch(int32_t handle) { |
| 1254 | audio_patch_handle_t handleLegacy = VALUE_OR_RETURN_BINDER( |
| 1255 | aidl2legacy_int32_t_audio_patch_handle_t(handle)); |
| 1256 | return Status::fromStatusT(mDelegate->releaseAudioPatch(handleLegacy)); |
| 1257 | } |
| 1258 | |
| 1259 | Status AudioFlingerServerAdapter::listAudioPatches(int32_t maxCount, |
Atneya Nair | 3afdbd1 | 2022-12-18 16:14:18 -0800 | [diff] [blame^] | 1260 | std::vector<media::AudioPatchFw>* _aidl_return) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1261 | unsigned int count = VALUE_OR_RETURN_BINDER(convertIntegral<unsigned int>(maxCount)); |
| 1262 | count = std::min(count, static_cast<unsigned int>(MAX_ITEMS_PER_LIST)); |
| 1263 | std::unique_ptr<audio_patch[]> patchesLegacy(new audio_patch[count]); |
| 1264 | RETURN_BINDER_IF_ERROR(mDelegate->listAudioPatches(&count, patchesLegacy.get())); |
| 1265 | RETURN_BINDER_IF_ERROR(convertRange(&patchesLegacy[0], |
| 1266 | &patchesLegacy[count], |
| 1267 | std::back_inserter(*_aidl_return), |
| 1268 | legacy2aidl_audio_patch_AudioPatch)); |
| 1269 | return Status::ok(); |
| 1270 | } |
| 1271 | |
Atneya Nair | 7a9594f | 2022-12-18 17:26:26 -0800 | [diff] [blame] | 1272 | Status AudioFlingerServerAdapter::setAudioPortConfig(const media::AudioPortConfigFw& config) { |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1273 | audio_port_config configLegacy = VALUE_OR_RETURN_BINDER( |
| 1274 | aidl2legacy_AudioPortConfig_audio_port_config(config)); |
| 1275 | return Status::fromStatusT(mDelegate->setAudioPortConfig(&configLegacy)); |
| 1276 | } |
| 1277 | |
| 1278 | Status AudioFlingerServerAdapter::getAudioHwSyncForSession(int32_t sessionId, |
| 1279 | int32_t* _aidl_return) { |
| 1280 | audio_session_t sessionIdLegacy = VALUE_OR_RETURN_BINDER( |
| 1281 | aidl2legacy_int32_t_audio_session_t(sessionId)); |
| 1282 | audio_hw_sync_t result = mDelegate->getAudioHwSyncForSession(sessionIdLegacy); |
| 1283 | *_aidl_return = VALUE_OR_RETURN_BINDER(legacy2aidl_audio_hw_sync_t_int32_t(result)); |
| 1284 | return Status::ok(); |
| 1285 | } |
| 1286 | |
| 1287 | Status AudioFlingerServerAdapter::systemReady() { |
| 1288 | return Status::fromStatusT(mDelegate->systemReady()); |
| 1289 | } |
| 1290 | |
Eric Laurent | d66d7a1 | 2021-07-13 13:35:32 +0200 | [diff] [blame] | 1291 | Status AudioFlingerServerAdapter::audioPolicyReady() { |
| 1292 | mDelegate->audioPolicyReady(); |
| 1293 | return Status::ok(); |
| 1294 | } |
| 1295 | |
Ytai Ben-Tsvi | 50b8ccb | 2020-11-24 13:47:54 -0800 | [diff] [blame] | 1296 | Status AudioFlingerServerAdapter::frameCountHAL(int32_t ioHandle, int64_t* _aidl_return) { |
| 1297 | audio_io_handle_t ioHandleLegacy = VALUE_OR_RETURN_BINDER( |
| 1298 | aidl2legacy_int32_t_audio_io_handle_t(ioHandle)); |
| 1299 | size_t result = mDelegate->frameCountHAL(ioHandleLegacy); |
| 1300 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertIntegral<int64_t>(result)); |
| 1301 | return Status::ok(); |
| 1302 | } |
| 1303 | |
| 1304 | Status AudioFlingerServerAdapter::getMicrophones( |
| 1305 | std::vector<media::MicrophoneInfoData>* _aidl_return) { |
| 1306 | std::vector<media::MicrophoneInfo> resultLegacy; |
| 1307 | RETURN_BINDER_IF_ERROR(mDelegate->getMicrophones(&resultLegacy)); |
| 1308 | *_aidl_return = VALUE_OR_RETURN_BINDER(convertContainer<std::vector<media::MicrophoneInfoData>>( |
| 1309 | resultLegacy, media::legacy2aidl_MicrophoneInfo)); |
| 1310 | return Status::ok(); |
| 1311 | } |
| 1312 | |
| 1313 | Status AudioFlingerServerAdapter::setAudioHalPids(const std::vector<int32_t>& pids) { |
| 1314 | std::vector<pid_t> pidsLegacy = VALUE_OR_RETURN_BINDER( |
| 1315 | convertContainer<std::vector<pid_t>>(pids, aidl2legacy_int32_t_pid_t)); |
| 1316 | RETURN_BINDER_IF_ERROR(mDelegate->setAudioHalPids(pidsLegacy)); |
| 1317 | return Status::ok(); |
| 1318 | } |
The Android Open Source Project | 89fa4ad | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1319 | |
jiabin | 1319f5a | 2021-03-30 22:21:24 +0000 | [diff] [blame] | 1320 | Status AudioFlingerServerAdapter::setVibratorInfos( |
| 1321 | const std::vector<media::AudioVibratorInfo>& vibratorInfos) { |
| 1322 | return Status::fromStatusT(mDelegate->setVibratorInfos(vibratorInfos)); |
| 1323 | } |
| 1324 | |
jiabin | 10a03f1 | 2021-05-07 23:46:28 +0000 | [diff] [blame] | 1325 | Status AudioFlingerServerAdapter::updateSecondaryOutputs( |
| 1326 | const std::vector<media::TrackSecondaryOutputInfo>& trackSecondaryOutputInfos) { |
| 1327 | TrackSecondaryOutputsMap trackSecondaryOutputs = |
| 1328 | VALUE_OR_RETURN_BINDER(convertContainer<TrackSecondaryOutputsMap>( |
| 1329 | trackSecondaryOutputInfos, |
| 1330 | aidl2legacy_TrackSecondaryOutputInfo_TrackSecondaryOutputInfoPair)); |
| 1331 | return Status::fromStatusT(mDelegate->updateSecondaryOutputs(trackSecondaryOutputs)); |
| 1332 | } |
| 1333 | |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1334 | Status AudioFlingerServerAdapter::getMmapPolicyInfos( |
jiabin | e99d088 | 2021-09-17 05:21:25 +0000 | [diff] [blame] | 1335 | AudioMMapPolicyType policyType, std::vector<AudioMMapPolicyInfo> *_aidl_return) { |
Jiabin Huang | ebe6410 | 2021-09-07 20:01:07 +0000 | [diff] [blame] | 1336 | return Status::fromStatusT(mDelegate->getMmapPolicyInfos(policyType, _aidl_return)); |
| 1337 | } |
| 1338 | |
jiabin | e504e7b | 2021-09-18 00:27:08 +0000 | [diff] [blame] | 1339 | Status AudioFlingerServerAdapter::getAAudioMixerBurstCount(int32_t* _aidl_return) { |
| 1340 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1341 | convertIntegral<int32_t>(mDelegate->getAAudioMixerBurstCount())); |
| 1342 | return Status::ok(); |
| 1343 | } |
| 1344 | |
| 1345 | Status AudioFlingerServerAdapter::getAAudioHardwareBurstMinUsec(int32_t* _aidl_return) { |
| 1346 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1347 | convertIntegral<int32_t>(mDelegate->getAAudioHardwareBurstMinUsec())); |
| 1348 | return Status::ok(); |
| 1349 | } |
| 1350 | |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1351 | Status AudioFlingerServerAdapter::setDeviceConnectedState( |
Atneya Nair | 638a6e4 | 2022-12-18 16:45:15 -0800 | [diff] [blame] | 1352 | const media::AudioPortFw& port, bool connected) { |
Mikhail Naganov | 516d398 | 2022-02-01 23:53:59 +0000 | [diff] [blame] | 1353 | audio_port_v7 portLegacy = VALUE_OR_RETURN_BINDER(aidl2legacy_AudioPort_audio_port_v7(port)); |
| 1354 | return Status::fromStatusT(mDelegate->setDeviceConnectedState(&portLegacy, connected)); |
| 1355 | } |
| 1356 | |
Eric Laurent | 076e7c7 | 2022-05-03 18:12:28 +0200 | [diff] [blame] | 1357 | Status AudioFlingerServerAdapter::setRequestedLatencyMode( |
| 1358 | int32_t output, media::LatencyMode modeAidl) { |
| 1359 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1360 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1361 | audio_latency_mode_t modeLegacy = VALUE_OR_RETURN_BINDER( |
| 1362 | aidl2legacy_LatencyMode_audio_latency_mode_t(modeAidl)); |
| 1363 | return Status::fromStatusT(mDelegate->setRequestedLatencyMode( |
| 1364 | outputLegacy, modeLegacy)); |
| 1365 | } |
| 1366 | |
| 1367 | Status AudioFlingerServerAdapter::getSupportedLatencyModes( |
| 1368 | int output, std::vector<media::LatencyMode>* _aidl_return) { |
| 1369 | audio_io_handle_t outputLegacy = VALUE_OR_RETURN_BINDER( |
| 1370 | aidl2legacy_int32_t_audio_io_handle_t(output)); |
| 1371 | std::vector<audio_latency_mode_t> modesLegacy; |
| 1372 | |
| 1373 | RETURN_BINDER_IF_ERROR(mDelegate->getSupportedLatencyModes(outputLegacy, &modesLegacy)); |
| 1374 | |
| 1375 | *_aidl_return = VALUE_OR_RETURN_BINDER( |
| 1376 | convertContainer<std::vector<media::LatencyMode>>( |
| 1377 | modesLegacy, legacy2aidl_audio_latency_mode_t_LatencyMode)); |
| 1378 | return Status::ok(); |
| 1379 | } |
| 1380 | |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1381 | Status AudioFlingerServerAdapter::getSoundDoseInterface( |
| 1382 | const sp<media::ISoundDoseCallback>& callback, |
| 1383 | sp<media::ISoundDose>* soundDose) |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1384 | { |
Vlad Popa | e3fd1c2 | 2022-11-07 21:03:18 +0100 | [diff] [blame] | 1385 | return Status::fromStatusT(mDelegate->getSoundDoseInterface(callback, soundDose)); |
Vlad Popa | 63f047e | 2022-11-05 14:09:19 +0100 | [diff] [blame] | 1386 | } |
| 1387 | |
Glenn Kasten | 40bc906 | 2015-03-20 09:09:33 -0700 | [diff] [blame] | 1388 | } // namespace android |