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