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