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