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