Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 1 | /* |
| 2 | ** |
| 3 | ** Copyright 2014, 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 | |
| 19 | #define LOG_TAG "AudioFlinger::PatchPanel" |
| 20 | //#define LOG_NDEBUG 0 |
| 21 | |
| 22 | #include "Configuration.h" |
| 23 | #include <utils/Log.h> |
| 24 | #include <audio_utils/primitives.h> |
| 25 | |
| 26 | #include "AudioFlinger.h" |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 27 | #include <media/AudioParameter.h> |
Mikhail Naganov | dc76968 | 2018-05-04 15:34:08 -0700 | [diff] [blame] | 28 | #include <media/PatchBuilder.h> |
Andy Hung | ab7ef30 | 2018-05-15 19:35:29 -0700 | [diff] [blame] | 29 | #include <mediautils/ServiceUtilities.h> |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 30 | |
| 31 | // ---------------------------------------------------------------------------- |
| 32 | |
| 33 | // Note: the following macro is used for extremely verbose logging message. In |
| 34 | // order to run with ALOG_ASSERT turned on, we need to have LOG_NDEBUG set to |
| 35 | // 0; but one side effect of this is to turn all LOGV's as well. Some messages |
| 36 | // are so verbose that we want to suppress them even when we have ALOG_ASSERT |
| 37 | // turned on. Do not uncomment the #def below unless you really know what you |
| 38 | // are doing and want to see all of the extremely verbose messages. |
| 39 | //#define VERY_VERY_VERBOSE_LOGGING |
| 40 | #ifdef VERY_VERY_VERBOSE_LOGGING |
| 41 | #define ALOGVV ALOGV |
| 42 | #else |
| 43 | #define ALOGVV(a...) do { } while(0) |
| 44 | #endif |
| 45 | |
| 46 | namespace android { |
| 47 | |
| 48 | /* List connected audio ports and their attributes */ |
| 49 | status_t AudioFlinger::listAudioPorts(unsigned int *num_ports, |
| 50 | struct audio_port *ports) |
| 51 | { |
| 52 | Mutex::Autolock _l(mLock); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 53 | return mPatchPanel.listAudioPorts(num_ports, ports); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | /* Get supported attributes for a given audio port */ |
| 57 | status_t AudioFlinger::getAudioPort(struct audio_port *port) |
| 58 | { |
| 59 | Mutex::Autolock _l(mLock); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 60 | return mPatchPanel.getAudioPort(port); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 61 | } |
| 62 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 63 | /* Connect a patch between several source and sink ports */ |
| 64 | status_t AudioFlinger::createAudioPatch(const struct audio_patch *patch, |
| 65 | audio_patch_handle_t *handle) |
| 66 | { |
| 67 | Mutex::Autolock _l(mLock); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 68 | return mPatchPanel.createAudioPatch(patch, handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | /* Disconnect a patch */ |
| 72 | status_t AudioFlinger::releaseAudioPatch(audio_patch_handle_t handle) |
| 73 | { |
| 74 | Mutex::Autolock _l(mLock); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 75 | return mPatchPanel.releaseAudioPatch(handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 78 | /* List connected audio ports and they attributes */ |
| 79 | status_t AudioFlinger::listAudioPatches(unsigned int *num_patches, |
| 80 | struct audio_patch *patches) |
| 81 | { |
| 82 | Mutex::Autolock _l(mLock); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 83 | return mPatchPanel.listAudioPatches(num_patches, patches); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 84 | } |
| 85 | |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 86 | status_t AudioFlinger::PatchPanel::SoftwarePatch::getLatencyMs_l(double *latencyMs) const |
| 87 | { |
| 88 | const auto& iter = mPatchPanel.mPatches.find(mPatchHandle); |
| 89 | if (iter != mPatchPanel.mPatches.end()) { |
| 90 | return iter->second.getLatencyMs(latencyMs); |
| 91 | } else { |
| 92 | return BAD_VALUE; |
| 93 | } |
| 94 | } |
| 95 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 96 | /* List connected audio ports and their attributes */ |
| 97 | status_t AudioFlinger::PatchPanel::listAudioPorts(unsigned int *num_ports __unused, |
| 98 | struct audio_port *ports __unused) |
| 99 | { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 100 | ALOGV(__func__); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 101 | return NO_ERROR; |
| 102 | } |
| 103 | |
| 104 | /* Get supported attributes for a given audio port */ |
| 105 | status_t AudioFlinger::PatchPanel::getAudioPort(struct audio_port *port __unused) |
| 106 | { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 107 | ALOGV(__func__); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 108 | return NO_ERROR; |
| 109 | } |
| 110 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 111 | /* Connect a patch between several source and sink ports */ |
| 112 | status_t AudioFlinger::PatchPanel::createAudioPatch(const struct audio_patch *patch, |
| 113 | audio_patch_handle_t *handle) |
| 114 | { |
Greg Kaiser | f27ce40 | 2016-03-14 13:43:14 -0700 | [diff] [blame] | 115 | if (handle == NULL || patch == NULL) { |
| 116 | return BAD_VALUE; |
| 117 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 118 | ALOGV("%s() num_sources %d num_sinks %d handle %d", |
| 119 | __func__, patch->num_sources, patch->num_sinks, *handle); |
| 120 | status_t status = NO_ERROR; |
| 121 | audio_patch_handle_t halHandle = AUDIO_PATCH_HANDLE_NONE; |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 122 | |
Mikhail Naganov | ac9858b | 2018-06-15 13:12:37 -0700 | [diff] [blame] | 123 | if (!audio_patch_is_valid(patch) || (patch->num_sinks == 0 && patch->num_sources != 2)) { |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 124 | return BAD_VALUE; |
| 125 | } |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 126 | // limit number of sources to 1 for now or 2 sources for special cross hw module case. |
| 127 | // only the audio policy manager can request a patch creation with 2 sources. |
| 128 | if (patch->num_sources > 2) { |
| 129 | return INVALID_OPERATION; |
| 130 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 131 | |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 132 | if (*handle != AUDIO_PATCH_HANDLE_NONE) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 133 | auto iter = mPatches.find(*handle); |
| 134 | if (iter != mPatches.end()) { |
| 135 | ALOGV("%s() removing patch handle %d", __func__, *handle); |
| 136 | Patch &removedPatch = iter->second; |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 137 | // free resources owned by the removed patch if applicable |
| 138 | // 1) if a software patch is present, release the playback and capture threads and |
| 139 | // tracks created. This will also release the corresponding audio HAL patches |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 140 | if (removedPatch.isSoftware()) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 141 | removedPatch.clearConnections(this); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 142 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 143 | // 2) if the new patch and old patch source or sink are devices from different |
| 144 | // hw modules, clear the audio HAL patches now because they will not be updated |
| 145 | // by call to create_audio_patch() below which will happen on a different HW module |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 146 | if (removedPatch.mHalHandle != AUDIO_PATCH_HANDLE_NONE) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 147 | audio_module_handle_t hwModule = AUDIO_MODULE_HANDLE_NONE; |
| 148 | const struct audio_patch &oldPatch = removedPatch.mAudioPatch; |
| 149 | if (oldPatch.sources[0].type == AUDIO_PORT_TYPE_DEVICE && |
| 150 | (patch->sources[0].type != AUDIO_PORT_TYPE_DEVICE || |
| 151 | oldPatch.sources[0].ext.device.hw_module != |
| 152 | patch->sources[0].ext.device.hw_module)) { |
| 153 | hwModule = oldPatch.sources[0].ext.device.hw_module; |
| 154 | } else if (patch->num_sinks == 0 || |
| 155 | (oldPatch.sinks[0].type == AUDIO_PORT_TYPE_DEVICE && |
| 156 | (patch->sinks[0].type != AUDIO_PORT_TYPE_DEVICE || |
| 157 | oldPatch.sinks[0].ext.device.hw_module != |
| 158 | patch->sinks[0].ext.device.hw_module))) { |
| 159 | // Note on (patch->num_sinks == 0): this situation should not happen as |
| 160 | // these special patches are only created by the policy manager but just |
| 161 | // in case, systematically clear the HAL patch. |
| 162 | // Note that removedPatch.mAudioPatch.num_sinks cannot be 0 here because |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 163 | // removedPatch.mHalHandle would be AUDIO_PATCH_HANDLE_NONE in this case. |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 164 | hwModule = oldPatch.sinks[0].ext.device.hw_module; |
| 165 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 166 | sp<DeviceHalInterface> hwDevice = findHwDeviceByModule(hwModule); |
| 167 | if (hwDevice != 0) { |
| 168 | hwDevice->releaseAudioPatch(removedPatch.mHalHandle); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 169 | } |
| 170 | } |
| 171 | mPatches.erase(iter); |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 172 | removeSoftwarePatchFromInsertedModules(*handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 173 | } |
| 174 | } |
| 175 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 176 | Patch newPatch{*patch}; |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 177 | audio_module_handle_t insertedModule = AUDIO_MODULE_HANDLE_NONE; |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 178 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 179 | switch (patch->sources[0].type) { |
| 180 | case AUDIO_PORT_TYPE_DEVICE: { |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 181 | audio_module_handle_t srcModule = patch->sources[0].ext.device.hw_module; |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 182 | AudioHwDevice *audioHwDevice = findAudioHwDeviceByModule(srcModule); |
| 183 | if (!audioHwDevice) { |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 184 | status = BAD_VALUE; |
| 185 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 186 | } |
| 187 | for (unsigned int i = 0; i < patch->num_sinks; i++) { |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 188 | // support only one sink if connection to a mix or across HW modules |
| 189 | if ((patch->sinks[i].type == AUDIO_PORT_TYPE_MIX || |
Mikhail Naganov | c589a49 | 2018-05-16 11:14:57 -0700 | [diff] [blame] | 190 | (patch->sinks[i].type == AUDIO_PORT_TYPE_DEVICE && |
| 191 | patch->sinks[i].ext.device.hw_module != srcModule)) && |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 192 | patch->num_sinks > 1) { |
Mikhail Naganov | c589a49 | 2018-05-16 11:14:57 -0700 | [diff] [blame] | 193 | ALOGW("%s() multiple sinks for mix or across modules not supported", __func__); |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 194 | status = INVALID_OPERATION; |
| 195 | goto exit; |
| 196 | } |
Eric Laurent | 6a94d69 | 2014-05-20 11:18:06 -0700 | [diff] [blame] | 197 | // reject connection to different sink types |
| 198 | if (patch->sinks[i].type != patch->sinks[0].type) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 199 | ALOGW("%s() different sink types in same patch not supported", __func__); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 200 | status = BAD_VALUE; |
| 201 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 202 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 203 | } |
| 204 | |
Eric Laurent | 3bcf859 | 2015-04-03 12:13:24 -0700 | [diff] [blame] | 205 | // manage patches requiring a software bridge |
Eric Laurent | d60560a | 2015-04-10 11:31:20 -0700 | [diff] [blame] | 206 | // - special patch request with 2 sources (reuse one existing output mix) OR |
Eric Laurent | 3bcf859 | 2015-04-03 12:13:24 -0700 | [diff] [blame] | 207 | // - Device to device AND |
| 208 | // - source HW module != destination HW module OR |
Mikhail Naganov | 9ee0540 | 2016-10-13 15:58:17 -0700 | [diff] [blame] | 209 | // - audio HAL does not support audio patches creation |
Eric Laurent | d60560a | 2015-04-10 11:31:20 -0700 | [diff] [blame] | 210 | if ((patch->num_sources == 2) || |
| 211 | ((patch->sinks[0].type == AUDIO_PORT_TYPE_DEVICE) && |
| 212 | ((patch->sinks[0].ext.device.hw_module != srcModule) || |
Mikhail Naganov | 9ee0540 | 2016-10-13 15:58:17 -0700 | [diff] [blame] | 213 | !audioHwDevice->supportsAudioPatches()))) { |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 214 | if (patch->num_sources == 2) { |
| 215 | if (patch->sources[1].type != AUDIO_PORT_TYPE_MIX || |
Eric Laurent | d60560a | 2015-04-10 11:31:20 -0700 | [diff] [blame] | 216 | (patch->num_sinks != 0 && patch->sinks[0].ext.device.hw_module != |
| 217 | patch->sources[1].ext.mix.hw_module)) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 218 | ALOGW("%s() invalid source combination", __func__); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 219 | status = INVALID_OPERATION; |
| 220 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 221 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 222 | |
| 223 | sp<ThreadBase> thread = |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 224 | mAudioFlinger.checkPlaybackThread_l(patch->sources[1].ext.mix.handle); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 225 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 226 | ALOGW("%s() cannot get playback thread", __func__); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 227 | status = INVALID_OPERATION; |
| 228 | goto exit; |
| 229 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 230 | // existing playback thread is reused, so it is not closed when patch is cleared |
| 231 | newPatch.mPlayback.setThread( |
| 232 | reinterpret_cast<PlaybackThread*>(thread.get()), false /*closeThread*/); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 233 | } else { |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 234 | audio_config_t config = AUDIO_CONFIG_INITIALIZER; |
| 235 | audio_devices_t device = patch->sinks[0].ext.device.type; |
| 236 | String8 address = String8(patch->sinks[0].ext.device.address); |
| 237 | audio_io_handle_t output = AUDIO_IO_HANDLE_NONE; |
Mikhail Naganov | 67bae2c | 2018-07-16 15:44:35 -0700 | [diff] [blame] | 238 | audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE; |
| 239 | if (patch->sinks[0].config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) { |
| 240 | config.sample_rate = patch->sinks[0].sample_rate; |
| 241 | } |
| 242 | if (patch->sinks[0].config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) { |
| 243 | config.channel_mask = patch->sinks[0].channel_mask; |
| 244 | } |
| 245 | if (patch->sinks[0].config_mask & AUDIO_PORT_CONFIG_FORMAT) { |
| 246 | config.format = patch->sinks[0].format; |
| 247 | } |
| 248 | if (patch->sinks[0].config_mask & AUDIO_PORT_CONFIG_FLAGS) { |
| 249 | flags = patch->sinks[0].flags.output; |
| 250 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 251 | sp<ThreadBase> thread = mAudioFlinger.openOutput_l( |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 252 | patch->sinks[0].ext.device.hw_module, |
| 253 | &output, |
| 254 | &config, |
| 255 | device, |
| 256 | address, |
Mikhail Naganov | 32abc2b | 2018-05-24 12:57:11 -0700 | [diff] [blame] | 257 | flags); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 258 | ALOGV("mAudioFlinger.openOutput_l() returned %p", thread.get()); |
| 259 | if (thread == 0) { |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 260 | status = NO_MEMORY; |
| 261 | goto exit; |
| 262 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 263 | newPatch.mPlayback.setThread(reinterpret_cast<PlaybackThread*>(thread.get())); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 264 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 265 | audio_devices_t device = patch->sources[0].ext.device.type; |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 266 | String8 address = String8(patch->sources[0].ext.device.address); |
| 267 | audio_config_t config = AUDIO_CONFIG_INITIALIZER; |
Eric Laurent | 8ae7312 | 2016-04-12 10:13:29 -0700 | [diff] [blame] | 268 | // open input stream with source device audio properties if provided or |
| 269 | // default to peer output stream properties otherwise. |
| 270 | if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_SAMPLE_RATE) { |
| 271 | config.sample_rate = patch->sources[0].sample_rate; |
| 272 | } else { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 273 | config.sample_rate = newPatch.mPlayback.thread()->sampleRate(); |
Eric Laurent | 8ae7312 | 2016-04-12 10:13:29 -0700 | [diff] [blame] | 274 | } |
| 275 | if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_CHANNEL_MASK) { |
| 276 | config.channel_mask = patch->sources[0].channel_mask; |
| 277 | } else { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 278 | config.channel_mask = audio_channel_in_mask_from_count( |
| 279 | newPatch.mPlayback.thread()->channelCount()); |
Eric Laurent | 8ae7312 | 2016-04-12 10:13:29 -0700 | [diff] [blame] | 280 | } |
| 281 | if (patch->sources[0].config_mask & AUDIO_PORT_CONFIG_FORMAT) { |
| 282 | config.format = patch->sources[0].format; |
| 283 | } else { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 284 | config.format = newPatch.mPlayback.thread()->format(); |
Eric Laurent | 8ae7312 | 2016-04-12 10:13:29 -0700 | [diff] [blame] | 285 | } |
Mikhail Naganov | 32abc2b | 2018-05-24 12:57:11 -0700 | [diff] [blame] | 286 | audio_input_flags_t flags = |
| 287 | patch->sources[0].config_mask & AUDIO_PORT_CONFIG_FLAGS ? |
| 288 | patch->sources[0].flags.input : AUDIO_INPUT_FLAG_NONE; |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 289 | audio_io_handle_t input = AUDIO_IO_HANDLE_NONE; |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 290 | sp<ThreadBase> thread = mAudioFlinger.openInput_l(srcModule, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 291 | &input, |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 292 | &config, |
Eric Laurent | cf2c021 | 2014-07-25 16:20:43 -0700 | [diff] [blame] | 293 | device, |
| 294 | address, |
| 295 | AUDIO_SOURCE_MIC, |
Mikhail Naganov | 32abc2b | 2018-05-24 12:57:11 -0700 | [diff] [blame] | 296 | flags); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 297 | ALOGV("mAudioFlinger.openInput_l() returned %p inChannelMask %08x", |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 298 | thread.get(), config.channel_mask); |
| 299 | if (thread == 0) { |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 300 | status = NO_MEMORY; |
| 301 | goto exit; |
| 302 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 303 | newPatch.mRecord.setThread(reinterpret_cast<RecordThread*>(thread.get())); |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 304 | status = newPatch.createConnections(this); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 305 | if (status != NO_ERROR) { |
| 306 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 307 | } |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 308 | if (audioHwDevice->isInsert()) { |
| 309 | insertedModule = audioHwDevice->handle(); |
| 310 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 311 | } else { |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 312 | if (patch->sinks[0].type == AUDIO_PORT_TYPE_MIX) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 313 | sp<ThreadBase> thread = mAudioFlinger.checkRecordThread_l( |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 314 | patch->sinks[0].ext.mix.handle); |
| 315 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 316 | thread = mAudioFlinger.checkMmapThread_l(patch->sinks[0].ext.mix.handle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 317 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 318 | ALOGW("%s() bad capture I/O handle %d", |
| 319 | __func__, patch->sinks[0].ext.mix.handle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 320 | status = BAD_VALUE; |
| 321 | goto exit; |
| 322 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 323 | } |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 324 | status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle); |
Eric Laurent | 526aa57 | 2019-01-15 10:54:58 -0800 | [diff] [blame] | 325 | // remove stale audio patch with same input as sink if any |
| 326 | for (auto& iter : mPatches) { |
| 327 | if (iter.second.mAudioPatch.sinks[0].ext.mix.handle == thread->id()) { |
| 328 | mPatches.erase(iter.first); |
| 329 | break; |
| 330 | } |
| 331 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 332 | } else { |
Mikhail Naganov | e4f1f63 | 2016-08-31 11:35:10 -0700 | [diff] [blame] | 333 | sp<DeviceHalInterface> hwDevice = audioHwDevice->hwDevice(); |
| 334 | status = hwDevice->createAudioPatch(patch->num_sources, |
| 335 | patch->sources, |
| 336 | patch->num_sinks, |
| 337 | patch->sinks, |
| 338 | &halHandle); |
Mikhail Naganov | 9ee0540 | 2016-10-13 15:58:17 -0700 | [diff] [blame] | 339 | if (status == INVALID_OPERATION) goto exit; |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 340 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 341 | } |
| 342 | } break; |
| 343 | case AUDIO_PORT_TYPE_MIX: { |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 344 | audio_module_handle_t srcModule = patch->sources[0].ext.mix.hw_module; |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 345 | ssize_t index = mAudioFlinger.mAudioHwDevs.indexOfKey(srcModule); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 346 | if (index < 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 347 | ALOGW("%s() bad src hw module %d", __func__, srcModule); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 348 | status = BAD_VALUE; |
| 349 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 350 | } |
| 351 | // limit to connections between devices and output streams |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 352 | audio_devices_t type = AUDIO_DEVICE_NONE; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 353 | for (unsigned int i = 0; i < patch->num_sinks; i++) { |
| 354 | if (patch->sinks[i].type != AUDIO_PORT_TYPE_DEVICE) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 355 | ALOGW("%s() invalid sink type %d for mix source", |
| 356 | __func__, patch->sinks[i].type); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 357 | status = BAD_VALUE; |
| 358 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 359 | } |
| 360 | // limit to connections between sinks and sources on same HW module |
Eric Laurent | 874c4287 | 2014-08-08 15:13:39 -0700 | [diff] [blame] | 361 | if (patch->sinks[i].ext.device.hw_module != srcModule) { |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 362 | status = BAD_VALUE; |
| 363 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 364 | } |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 365 | type |= patch->sinks[i].ext.device.type; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 366 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 367 | sp<ThreadBase> thread = |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 368 | mAudioFlinger.checkPlaybackThread_l(patch->sources[0].ext.mix.handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 369 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 370 | thread = mAudioFlinger.checkMmapThread_l(patch->sources[0].ext.mix.handle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 371 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 372 | ALOGW("%s() bad playback I/O handle %d", |
| 373 | __func__, patch->sources[0].ext.mix.handle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 374 | status = BAD_VALUE; |
| 375 | goto exit; |
| 376 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 377 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 378 | if (thread == mAudioFlinger.primaryPlaybackThread_l()) { |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 379 | AudioParameter param = AudioParameter(); |
Mikhail Naganov | 00260b5 | 2016-10-13 12:54:24 -0700 | [diff] [blame] | 380 | param.addInt(String8(AudioParameter::keyRouting), (int)type); |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 381 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 382 | mAudioFlinger.broacastParametersToRecordThreads_l(param.toString()); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 383 | } |
| 384 | |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 385 | status = thread->sendCreateAudioPatchConfigEvent(patch, &halHandle); |
Eric Laurent | 526aa57 | 2019-01-15 10:54:58 -0800 | [diff] [blame] | 386 | |
| 387 | // remove stale audio patch with same output as source if any |
| 388 | for (auto& iter : mPatches) { |
| 389 | if (iter.second.mAudioPatch.sources[0].ext.mix.handle == thread->id()) { |
| 390 | mPatches.erase(iter.first); |
| 391 | break; |
| 392 | } |
| 393 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 394 | } break; |
| 395 | default: |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 396 | status = BAD_VALUE; |
| 397 | goto exit; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 398 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 399 | exit: |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 400 | ALOGV("%s() status %d", __func__, status); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 401 | if (status == NO_ERROR) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 402 | *handle = (audio_patch_handle_t) mAudioFlinger.nextUniqueId(AUDIO_UNIQUE_ID_USE_PATCH); |
| 403 | newPatch.mHalHandle = halHandle; |
| 404 | mPatches.insert(std::make_pair(*handle, std::move(newPatch))); |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 405 | if (insertedModule != AUDIO_MODULE_HANDLE_NONE) { |
| 406 | addSoftwarePatchToInsertedModules(insertedModule, *handle); |
| 407 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 408 | ALOGV("%s() added new patch handle %d halHandle %d", __func__, *handle, halHandle); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 409 | } else { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 410 | newPatch.clearConnections(this); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 411 | } |
| 412 | return status; |
| 413 | } |
| 414 | |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 415 | AudioFlinger::PatchPanel::Patch::~Patch() |
| 416 | { |
| 417 | ALOGE_IF(isSoftware(), "Software patch connections leaked %d %d", |
| 418 | mRecord.handle(), mPlayback.handle()); |
| 419 | } |
| 420 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 421 | status_t AudioFlinger::PatchPanel::Patch::createConnections(PatchPanel *panel) |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 422 | { |
| 423 | // create patch from source device to record thread input |
Mikhail Naganov | dc76968 | 2018-05-04 15:34:08 -0700 | [diff] [blame] | 424 | status_t status = panel->createAudioPatch( |
| 425 | PatchBuilder().addSource(mAudioPatch.sources[0]). |
| 426 | addSink(mRecord.thread(), { .source = AUDIO_SOURCE_MIC }).patch(), |
| 427 | mRecord.handlePtr()); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 428 | if (status != NO_ERROR) { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 429 | *mRecord.handlePtr() = AUDIO_PATCH_HANDLE_NONE; |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 430 | return status; |
| 431 | } |
| 432 | |
| 433 | // create patch from playback thread output to sink device |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 434 | if (mAudioPatch.num_sinks != 0) { |
Mikhail Naganov | dc76968 | 2018-05-04 15:34:08 -0700 | [diff] [blame] | 435 | status = panel->createAudioPatch( |
| 436 | PatchBuilder().addSource(mPlayback.thread()).addSink(mAudioPatch.sinks[0]).patch(), |
| 437 | mPlayback.handlePtr()); |
Eric Laurent | d60560a | 2015-04-10 11:31:20 -0700 | [diff] [blame] | 438 | if (status != NO_ERROR) { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 439 | *mPlayback.handlePtr() = AUDIO_PATCH_HANDLE_NONE; |
Eric Laurent | d60560a | 2015-04-10 11:31:20 -0700 | [diff] [blame] | 440 | return status; |
| 441 | } |
| 442 | } else { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 443 | *mPlayback.handlePtr() = AUDIO_PATCH_HANDLE_NONE; |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 444 | } |
| 445 | |
| 446 | // use a pseudo LCM between input and output framecount |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 447 | size_t playbackFrameCount = mPlayback.thread()->frameCount(); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 448 | int playbackShift = __builtin_ctz(playbackFrameCount); |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 449 | size_t recordFrameCount = mRecord.thread()->frameCount(); |
| 450 | int shift = __builtin_ctz(recordFrameCount); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 451 | if (playbackShift < shift) { |
| 452 | shift = playbackShift; |
| 453 | } |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 454 | size_t frameCount = (playbackFrameCount * recordFrameCount) >> shift; |
| 455 | ALOGV("%s() playframeCount %zu recordFrameCount %zu frameCount %zu", |
| 456 | __func__, playbackFrameCount, recordFrameCount, frameCount); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 457 | |
| 458 | // create a special record track to capture from record thread |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 459 | uint32_t channelCount = mPlayback.thread()->channelCount(); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 460 | audio_channel_mask_t inChannelMask = audio_channel_in_mask_from_count(channelCount); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 461 | audio_channel_mask_t outChannelMask = mPlayback.thread()->channelMask(); |
| 462 | uint32_t sampleRate = mPlayback.thread()->sampleRate(); |
| 463 | audio_format_t format = mPlayback.thread()->format(); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 464 | |
Mikhail Naganov | 7c6ae98 | 2018-06-14 12:33:38 -0700 | [diff] [blame] | 465 | audio_format_t inputFormat = mRecord.thread()->format(); |
| 466 | if (!audio_is_linear_pcm(inputFormat)) { |
| 467 | // The playbackThread format will say PCM for IEC61937 packetized stream. |
| 468 | // Use recordThread format. |
| 469 | format = inputFormat; |
| 470 | } |
| 471 | audio_input_flags_t inputFlags = mAudioPatch.sources[0].config_mask & AUDIO_PORT_CONFIG_FLAGS ? |
| 472 | mAudioPatch.sources[0].flags.input : AUDIO_INPUT_FLAG_NONE; |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 473 | if (sampleRate == mRecord.thread()->sampleRate() && |
| 474 | inChannelMask == mRecord.thread()->channelMask() && |
| 475 | mRecord.thread()->fastTrackAvailable() && |
| 476 | mRecord.thread()->hasFastCapture()) { |
| 477 | // Create a fast track if the record thread has fast capture to get better performance. |
| 478 | // Only enable fast mode when there is no resample needed. |
| 479 | inputFlags = (audio_input_flags_t) (inputFlags | AUDIO_INPUT_FLAG_FAST); |
| 480 | } else { |
| 481 | // Fast mode is not available in this case. |
| 482 | inputFlags = (audio_input_flags_t) (inputFlags & ~AUDIO_INPUT_FLAG_FAST); |
| 483 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 484 | sp<RecordThread::PatchRecord> tempRecordTrack = new (std::nothrow) RecordThread::PatchRecord( |
| 485 | mRecord.thread().get(), |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 486 | sampleRate, |
| 487 | inChannelMask, |
| 488 | format, |
| 489 | frameCount, |
| 490 | NULL, |
Andy Hung | 8fe6803 | 2017-06-05 16:17:51 -0700 | [diff] [blame] | 491 | (size_t)0 /* bufferSize */, |
Mikhail Naganov | 7c6ae98 | 2018-06-14 12:33:38 -0700 | [diff] [blame] | 492 | inputFlags); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 493 | status = mRecord.checkTrack(tempRecordTrack.get()); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 494 | if (status != NO_ERROR) { |
| 495 | return status; |
| 496 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 497 | |
Mikhail Naganov | 7c6ae98 | 2018-06-14 12:33:38 -0700 | [diff] [blame] | 498 | audio_output_flags_t outputFlags = mAudioPatch.sinks[0].config_mask & AUDIO_PORT_CONFIG_FLAGS ? |
| 499 | mAudioPatch.sinks[0].flags.output : AUDIO_OUTPUT_FLAG_NONE; |
Mikhail Naganov | 776eb21 | 2018-07-19 15:14:11 -0700 | [diff] [blame] | 500 | audio_stream_type_t streamType = AUDIO_STREAM_PATCH; |
| 501 | if (mAudioPatch.num_sources == 2 && mAudioPatch.sources[1].type == AUDIO_PORT_TYPE_MIX) { |
| 502 | // "reuse one existing output mix" case |
| 503 | streamType = mAudioPatch.sources[1].ext.mix.usecase.stream; |
| 504 | } |
jiabin | 01c8f56 | 2018-07-19 17:47:28 -0700 | [diff] [blame] | 505 | if (mPlayback.thread()->hasFastMixer()) { |
| 506 | // Create a fast track if the playback thread has fast mixer to get better performance. |
| 507 | outputFlags = (audio_output_flags_t) (outputFlags | AUDIO_OUTPUT_FLAG_FAST); |
| 508 | } |
| 509 | |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 510 | // create a special playback track to render to playback thread. |
| 511 | // this track is given the same buffer as the PatchRecord buffer |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 512 | sp<PlaybackThread::PatchTrack> tempPatchTrack = new (std::nothrow) PlaybackThread::PatchTrack( |
| 513 | mPlayback.thread().get(), |
Mikhail Naganov | 776eb21 | 2018-07-19 15:14:11 -0700 | [diff] [blame] | 514 | streamType, |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 515 | sampleRate, |
| 516 | outChannelMask, |
| 517 | format, |
| 518 | frameCount, |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 519 | tempRecordTrack->buffer(), |
| 520 | tempRecordTrack->bufferSize(), |
Mikhail Naganov | 7c6ae98 | 2018-06-14 12:33:38 -0700 | [diff] [blame] | 521 | outputFlags); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 522 | status = mPlayback.checkTrack(tempPatchTrack.get()); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 523 | if (status != NO_ERROR) { |
| 524 | return status; |
| 525 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 526 | |
| 527 | // tie playback and record tracks together |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 528 | mRecord.setTrackAndPeer(tempRecordTrack, tempPatchTrack.get()); |
| 529 | mPlayback.setTrackAndPeer(tempPatchTrack, tempRecordTrack.get()); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 530 | |
| 531 | // start capture and playback |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 532 | mRecord.track()->start(AudioSystem::SYNC_EVENT_NONE, AUDIO_SESSION_NONE); |
| 533 | mPlayback.track()->start(); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 534 | |
| 535 | return status; |
| 536 | } |
| 537 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 538 | void AudioFlinger::PatchPanel::Patch::clearConnections(PatchPanel *panel) |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 539 | { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 540 | ALOGV("%s() mRecord.handle %d mPlayback.handle %d", |
| 541 | __func__, mRecord.handle(), mPlayback.handle()); |
| 542 | mRecord.stopTrack(); |
| 543 | mPlayback.stopTrack(); |
| 544 | mRecord.closeConnections(panel); |
| 545 | mPlayback.closeConnections(panel); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 546 | } |
| 547 | |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 548 | status_t AudioFlinger::PatchPanel::Patch::getLatencyMs(double *latencyMs) const |
| 549 | { |
| 550 | if (!isSoftware()) return INVALID_OPERATION; |
| 551 | |
| 552 | auto recordTrack = mRecord.const_track(); |
| 553 | if (recordTrack.get() == nullptr) return INVALID_OPERATION; |
| 554 | |
| 555 | auto playbackTrack = mPlayback.const_track(); |
| 556 | if (playbackTrack.get() == nullptr) return INVALID_OPERATION; |
| 557 | |
| 558 | // Latency information for tracks may be called without obtaining |
| 559 | // the underlying thread lock. |
| 560 | // |
| 561 | // We use record server latency + playback track latency (generally smaller than the |
| 562 | // reverse due to internal biases). |
| 563 | // |
| 564 | // TODO: is this stable enough? Consider a PatchTrack synchronized version of this. |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 565 | |
Andy Hung | 3028256 | 2018-08-08 18:27:03 -0700 | [diff] [blame] | 566 | // For PCM tracks get server latency. |
| 567 | if (audio_is_linear_pcm(recordTrack->format())) { |
| 568 | double recordServerLatencyMs, playbackTrackLatencyMs; |
| 569 | if (recordTrack->getServerLatencyMs(&recordServerLatencyMs) == OK |
| 570 | && playbackTrack->getTrackLatencyMs(&playbackTrackLatencyMs) == OK) { |
| 571 | *latencyMs = recordServerLatencyMs + playbackTrackLatencyMs; |
| 572 | return OK; |
| 573 | } |
| 574 | } |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 575 | |
Andy Hung | 3028256 | 2018-08-08 18:27:03 -0700 | [diff] [blame] | 576 | // See if kernel latencies are available. |
| 577 | // If so, do a frame diff and time difference computation to estimate |
| 578 | // the total patch latency. This requires that frame counts are reported by the |
| 579 | // HAL are matched properly in the case of record overruns and playback underruns. |
| 580 | ThreadBase::TrackBase::FrameTime recordFT{}, playFT{}; |
| 581 | recordTrack->getKernelFrameTime(&recordFT); |
| 582 | playbackTrack->getKernelFrameTime(&playFT); |
| 583 | if (recordFT.timeNs > 0 && playFT.timeNs > 0) { |
| 584 | const int64_t frameDiff = recordFT.frames - playFT.frames; |
| 585 | const int64_t timeDiffNs = recordFT.timeNs - playFT.timeNs; |
| 586 | |
| 587 | // It is possible that the patch track and patch record have a large time disparity because |
| 588 | // one thread runs but another is stopped. We arbitrarily choose the maximum timestamp |
| 589 | // time difference based on how often we expect the timestamps to update in normal operation |
| 590 | // (typical should be no more than 50 ms). |
| 591 | // |
| 592 | // If the timestamps aren't sampled close enough, the patch latency is not |
| 593 | // considered valid. |
| 594 | // |
| 595 | // TODO: change this based on more experiments. |
| 596 | constexpr int64_t maxValidTimeDiffNs = 200 * NANOS_PER_MILLISECOND; |
| 597 | if (std::abs(timeDiffNs) < maxValidTimeDiffNs) { |
| 598 | *latencyMs = frameDiff * 1e3 / recordTrack->sampleRate() |
| 599 | - timeDiffNs * 1e-6; |
| 600 | return OK; |
| 601 | } |
| 602 | } |
| 603 | |
| 604 | return INVALID_OPERATION; |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 605 | } |
| 606 | |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 607 | String8 AudioFlinger::PatchPanel::Patch::dump(audio_patch_handle_t myHandle) const |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 608 | { |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 609 | // TODO: Consider table dump form for patches, just like tracks. |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 610 | String8 result = String8::format("Patch %d: thread %p => thread %p", |
| 611 | myHandle, mRecord.const_thread().get(), mPlayback.const_thread().get()); |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 612 | |
| 613 | // add latency if it exists |
| 614 | double latencyMs; |
| 615 | if (getLatencyMs(&latencyMs) == OK) { |
Mikhail Naganov | b8b6097 | 2018-09-13 12:55:43 -0700 | [diff] [blame] | 616 | result.appendFormat(" latency: %.2lf ms", latencyMs); |
Andy Hung | c3ab773 | 2018-06-01 13:46:29 -0700 | [diff] [blame] | 617 | } |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 618 | return result; |
| 619 | } |
| 620 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 621 | /* Disconnect a patch */ |
| 622 | status_t AudioFlinger::PatchPanel::releaseAudioPatch(audio_patch_handle_t handle) |
| 623 | { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 624 | ALOGV("%s handle %d", __func__, handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 625 | status_t status = NO_ERROR; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 626 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 627 | auto iter = mPatches.find(handle); |
| 628 | if (iter == mPatches.end()) { |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 629 | return BAD_VALUE; |
| 630 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 631 | Patch &removedPatch = iter->second; |
| 632 | const struct audio_patch &patch = removedPatch.mAudioPatch; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 633 | |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 634 | const struct audio_port_config &src = patch.sources[0]; |
| 635 | switch (src.type) { |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 636 | case AUDIO_PORT_TYPE_DEVICE: { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 637 | sp<DeviceHalInterface> hwDevice = findHwDeviceByModule(src.ext.device.hw_module); |
| 638 | if (hwDevice == 0) { |
| 639 | ALOGW("%s() bad src hw module %d", __func__, src.ext.device.hw_module); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 640 | status = BAD_VALUE; |
| 641 | break; |
| 642 | } |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 643 | |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 644 | if (removedPatch.isSoftware()) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 645 | removedPatch.clearConnections(this); |
Eric Laurent | 83b8808 | 2014-06-20 18:31:16 -0700 | [diff] [blame] | 646 | break; |
| 647 | } |
| 648 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 649 | if (patch.sinks[0].type == AUDIO_PORT_TYPE_MIX) { |
| 650 | audio_io_handle_t ioHandle = patch.sinks[0].ext.mix.handle; |
| 651 | sp<ThreadBase> thread = mAudioFlinger.checkRecordThread_l(ioHandle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 652 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 653 | thread = mAudioFlinger.checkMmapThread_l(ioHandle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 654 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 655 | ALOGW("%s() bad capture I/O handle %d", __func__, ioHandle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 656 | status = BAD_VALUE; |
| 657 | break; |
| 658 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 659 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 660 | status = thread->sendReleaseAudioPatchConfigEvent(removedPatch.mHalHandle); |
Eric Laurent | 054d9d3 | 2015-04-24 08:48:48 -0700 | [diff] [blame] | 661 | } else { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 662 | status = hwDevice->releaseAudioPatch(removedPatch.mHalHandle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 663 | } |
| 664 | } break; |
| 665 | case AUDIO_PORT_TYPE_MIX: { |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 666 | if (findHwDeviceByModule(src.ext.mix.hw_module) == 0) { |
| 667 | ALOGW("%s() bad src hw module %d", __func__, src.ext.mix.hw_module); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 668 | status = BAD_VALUE; |
| 669 | break; |
| 670 | } |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 671 | audio_io_handle_t ioHandle = src.ext.mix.handle; |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 672 | sp<ThreadBase> thread = mAudioFlinger.checkPlaybackThread_l(ioHandle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 673 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 674 | thread = mAudioFlinger.checkMmapThread_l(ioHandle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 675 | if (thread == 0) { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 676 | ALOGW("%s() bad playback I/O handle %d", __func__, ioHandle); |
Eric Laurent | 6acd1d4 | 2017-01-04 14:23:29 -0800 | [diff] [blame] | 677 | status = BAD_VALUE; |
| 678 | break; |
| 679 | } |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 680 | } |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 681 | status = thread->sendReleaseAudioPatchConfigEvent(removedPatch.mHalHandle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 682 | } break; |
| 683 | default: |
| 684 | status = BAD_VALUE; |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 685 | } |
| 686 | |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 687 | mPatches.erase(iter); |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 688 | removeSoftwarePatchFromInsertedModules(handle); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 689 | return status; |
| 690 | } |
| 691 | |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 692 | /* List connected audio ports and they attributes */ |
| 693 | status_t AudioFlinger::PatchPanel::listAudioPatches(unsigned int *num_patches __unused, |
| 694 | struct audio_patch *patches __unused) |
| 695 | { |
Mikhail Naganov | dea5304 | 2018-04-26 13:10:21 -0700 | [diff] [blame] | 696 | ALOGV(__func__); |
Eric Laurent | 951f455 | 2014-05-20 10:48:17 -0700 | [diff] [blame] | 697 | return NO_ERROR; |
| 698 | } |
| 699 | |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 700 | status_t AudioFlinger::PatchPanel::getDownstreamSoftwarePatches( |
| 701 | audio_io_handle_t stream, |
| 702 | std::vector<AudioFlinger::PatchPanel::SoftwarePatch> *patches) const |
| 703 | { |
| 704 | for (const auto& module : mInsertedModules) { |
| 705 | if (module.second.streams.count(stream)) { |
| 706 | for (const auto& patchHandle : module.second.sw_patches) { |
| 707 | const auto& patch_iter = mPatches.find(patchHandle); |
| 708 | if (patch_iter != mPatches.end()) { |
| 709 | const Patch &patch = patch_iter->second; |
| 710 | patches->emplace_back(*this, patchHandle, |
| 711 | patch.mPlayback.const_thread()->id(), |
| 712 | patch.mRecord.const_thread()->id()); |
| 713 | } else { |
| 714 | ALOGE("Stale patch handle in the cache: %d", patchHandle); |
| 715 | } |
| 716 | } |
| 717 | return OK; |
| 718 | } |
| 719 | } |
| 720 | // The stream is not associated with any of inserted modules. |
| 721 | return BAD_VALUE; |
| 722 | } |
| 723 | |
| 724 | void AudioFlinger::PatchPanel::notifyStreamOpened( |
| 725 | AudioHwDevice *audioHwDevice, audio_io_handle_t stream) |
| 726 | { |
| 727 | if (audioHwDevice->isInsert()) { |
| 728 | mInsertedModules[audioHwDevice->handle()].streams.insert(stream); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | void AudioFlinger::PatchPanel::notifyStreamClosed(audio_io_handle_t stream) |
| 733 | { |
| 734 | for (auto& module : mInsertedModules) { |
| 735 | module.second.streams.erase(stream); |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | AudioHwDevice* AudioFlinger::PatchPanel::findAudioHwDeviceByModule(audio_module_handle_t module) |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 740 | { |
| 741 | if (module == AUDIO_MODULE_HANDLE_NONE) return nullptr; |
| 742 | ssize_t index = mAudioFlinger.mAudioHwDevs.indexOfKey(module); |
| 743 | if (index < 0) { |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 744 | ALOGW("%s() bad hw module %d", __func__, module); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 745 | return nullptr; |
| 746 | } |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 747 | return mAudioFlinger.mAudioHwDevs.valueAt(index); |
Mikhail Naganov | 444ecc3 | 2018-05-01 17:40:05 -0700 | [diff] [blame] | 748 | } |
| 749 | |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 750 | sp<DeviceHalInterface> AudioFlinger::PatchPanel::findHwDeviceByModule(audio_module_handle_t module) |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 751 | { |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 752 | AudioHwDevice *audioHwDevice = findAudioHwDeviceByModule(module); |
| 753 | return audioHwDevice ? audioHwDevice->hwDevice() : nullptr; |
| 754 | } |
| 755 | |
| 756 | void AudioFlinger::PatchPanel::addSoftwarePatchToInsertedModules( |
| 757 | audio_module_handle_t module, audio_patch_handle_t handle) |
| 758 | { |
| 759 | mInsertedModules[module].sw_patches.insert(handle); |
| 760 | } |
| 761 | |
| 762 | void AudioFlinger::PatchPanel::removeSoftwarePatchFromInsertedModules( |
| 763 | audio_patch_handle_t handle) |
| 764 | { |
| 765 | for (auto& module : mInsertedModules) { |
| 766 | module.second.sw_patches.erase(handle); |
| 767 | } |
| 768 | } |
| 769 | |
| 770 | void AudioFlinger::PatchPanel::dump(int fd) const |
| 771 | { |
| 772 | String8 patchPanelDump; |
| 773 | const char *indent = " "; |
| 774 | |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 775 | // Only dump software patches. |
| 776 | bool headerPrinted = false; |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 777 | for (const auto& iter : mPatches) { |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 778 | if (iter.second.isSoftware()) { |
| 779 | if (!headerPrinted) { |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 780 | patchPanelDump += "\nSoftware patches:\n"; |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 781 | headerPrinted = true; |
| 782 | } |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 783 | patchPanelDump.appendFormat("%s%s\n", indent, iter.second.dump(iter.first).string()); |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 784 | } |
| 785 | } |
Mikhail Naganov | adca70f | 2018-07-09 12:49:25 -0700 | [diff] [blame] | 786 | |
| 787 | headerPrinted = false; |
| 788 | for (const auto& module : mInsertedModules) { |
| 789 | if (!module.second.streams.empty() || !module.second.sw_patches.empty()) { |
| 790 | if (!headerPrinted) { |
| 791 | patchPanelDump += "\nTracked inserted modules:\n"; |
| 792 | headerPrinted = true; |
| 793 | } |
| 794 | String8 moduleDump = String8::format("Module %d: I/O handles: ", module.first); |
| 795 | for (const auto& stream : module.second.streams) { |
| 796 | moduleDump.appendFormat("%d ", stream); |
| 797 | } |
| 798 | moduleDump.append("; SW Patches: "); |
| 799 | for (const auto& patch : module.second.sw_patches) { |
| 800 | moduleDump.appendFormat("%d ", patch); |
| 801 | } |
| 802 | patchPanelDump.appendFormat("%s%s\n", indent, moduleDump.string()); |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | if (!patchPanelDump.isEmpty()) { |
| 807 | write(fd, patchPanelDump.string(), patchPanelDump.size()); |
Mikhail Naganov | 201369b | 2018-05-16 16:52:32 -0700 | [diff] [blame] | 808 | } |
| 809 | } |
| 810 | |
Glenn Kasten | 63238ef | 2015-03-02 15:50:29 -0800 | [diff] [blame] | 811 | } // namespace android |