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