Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 17 | #define LOG_TAG "AudioEndpoint" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 18 | //#define LOG_NDEBUG 0 |
| 19 | #include <utils/Log.h> |
| 20 | |
| 21 | #include <cassert> |
Phil Burk | e4d7bb4 | 2017-03-28 11:32:39 -0700 | [diff] [blame] | 22 | #include <aaudio/AAudio.h> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 23 | |
| 24 | #include "AudioEndpointParcelable.h" |
| 25 | #include "AudioEndpoint.h" |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 26 | #include "AAudioServiceMessage.h" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 27 | |
| 28 | using namespace android; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 29 | using namespace aaudio; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 30 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 31 | #define RIDICULOUSLY_LARGE_BUFFER_CAPACITY (256 * 1024) |
| 32 | #define RIDICULOUSLY_LARGE_FRAME_SIZE 4096 |
| 33 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 34 | AudioEndpoint::AudioEndpoint() |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 35 | : mFreeRunning(false) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 36 | , mDataReadCounter(0) |
| 37 | , mDataWriteCounter(0) |
| 38 | { |
| 39 | } |
| 40 | |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 41 | // TODO Consider moving to a method in RingBufferDescriptor |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 42 | static aaudio_result_t AudioEndpoint_validateQueueDescriptor(const char *type, |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 43 | const RingBufferDescriptor *descriptor) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 44 | if (descriptor == nullptr) { |
| 45 | ALOGE("AudioEndpoint_validateQueueDescriptor() NULL descriptor"); |
| 46 | return AAUDIO_ERROR_NULL; |
| 47 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 48 | |
| 49 | if (descriptor->capacityInFrames < 1 |
| 50 | || descriptor->capacityInFrames > RIDICULOUSLY_LARGE_BUFFER_CAPACITY) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 51 | ALOGE("AudioEndpoint_validateQueueDescriptor() bad capacityInFrames = %d", |
| 52 | descriptor->capacityInFrames); |
| 53 | return AAUDIO_ERROR_OUT_OF_RANGE; |
| 54 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 55 | |
| 56 | // Reject extreme values to catch bugs and prevent numeric overflows. |
| 57 | if (descriptor->bytesPerFrame < 1 |
| 58 | || descriptor->bytesPerFrame > RIDICULOUSLY_LARGE_FRAME_SIZE) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 59 | ALOGE("AudioEndpoint_validateQueueDescriptor() bad bytesPerFrame = %d", |
| 60 | descriptor->bytesPerFrame); |
| 61 | return AAUDIO_ERROR_OUT_OF_RANGE; |
| 62 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 63 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 64 | if (descriptor->dataAddress == nullptr) { |
| 65 | ALOGE("AudioEndpoint_validateQueueDescriptor() NULL dataAddress"); |
| 66 | return AAUDIO_ERROR_NULL; |
| 67 | } |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 68 | ALOGV("AudioEndpoint_validateQueueDescriptor %s, dataAddress at %p ====================", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 69 | type, |
| 70 | descriptor->dataAddress); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 71 | ALOGV("AudioEndpoint_validateQueueDescriptor readCounter at %p, writeCounter at %p", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 72 | descriptor->readCounterAddress, |
| 73 | descriptor->writeCounterAddress); |
| 74 | |
| 75 | // Try to READ from the data area. |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 76 | // This code will crash if the mmap failed. |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 77 | uint8_t value = descriptor->dataAddress[0]; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 78 | ALOGV("AudioEndpoint_validateQueueDescriptor() dataAddress[0] = %d, then try to write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 79 | (int) value); |
| 80 | // Try to WRITE to the data area. |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 81 | descriptor->dataAddress[0] = value * 3; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 82 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 83 | |
| 84 | if (descriptor->readCounterAddress) { |
| 85 | fifo_counter_t counter = *descriptor->readCounterAddress; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 86 | ALOGV("AudioEndpoint_validateQueueDescriptor() *readCounterAddress = %d, now write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 87 | (int) counter); |
| 88 | *descriptor->readCounterAddress = counter; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 89 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote readCounterAddress successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 90 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 91 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 92 | if (descriptor->writeCounterAddress) { |
| 93 | fifo_counter_t counter = *descriptor->writeCounterAddress; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 94 | ALOGV("AudioEndpoint_validateQueueDescriptor() *writeCounterAddress = %d, now write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 95 | (int) counter); |
| 96 | *descriptor->writeCounterAddress = counter; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 97 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote writeCounterAddress successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 98 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 99 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 100 | return AAUDIO_OK; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 101 | } |
| 102 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 103 | aaudio_result_t AudioEndpoint_validateDescriptor(const EndpointDescriptor *pEndpointDescriptor) { |
| 104 | aaudio_result_t result = AudioEndpoint_validateQueueDescriptor("messages", |
| 105 | &pEndpointDescriptor->upMessageQueueDescriptor); |
| 106 | if (result == AAUDIO_OK) { |
| 107 | result = AudioEndpoint_validateQueueDescriptor("data", |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 108 | &pEndpointDescriptor->dataQueueDescriptor); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 109 | } |
| 110 | return result; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 111 | } |
| 112 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 113 | aaudio_result_t AudioEndpoint::configure(const EndpointDescriptor *pEndpointDescriptor, |
| 114 | aaudio_direction_t direction) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 115 | { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 116 | aaudio_result_t result = AudioEndpoint_validateDescriptor(pEndpointDescriptor); |
| 117 | if (result != AAUDIO_OK) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 118 | return result; |
| 119 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 120 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 121 | // ============================ up message queue ============================= |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 122 | const RingBufferDescriptor *descriptor = &pEndpointDescriptor->upMessageQueueDescriptor; |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 123 | if(descriptor->bytesPerFrame != sizeof(AAudioServiceMessage)) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 124 | ALOGE("configure() bytesPerFrame != sizeof(AAudioServiceMessage) = %d", |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 125 | descriptor->bytesPerFrame); |
| 126 | return AAUDIO_ERROR_INTERNAL; |
| 127 | } |
| 128 | |
| 129 | if(descriptor->readCounterAddress == nullptr || descriptor->writeCounterAddress == nullptr) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 130 | ALOGE("configure() NULL counter address"); |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 131 | return AAUDIO_ERROR_NULL; |
| 132 | } |
| 133 | |
Phil Burk | 99306c8 | 2017-08-14 12:38:58 -0700 | [diff] [blame] | 134 | // Prevent memory leak and reuse. |
| 135 | if(mUpCommandQueue != nullptr || mDataQueue != nullptr) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 136 | ALOGE("configure() endpoint already used"); |
Phil Burk | 99306c8 | 2017-08-14 12:38:58 -0700 | [diff] [blame] | 137 | return AAUDIO_ERROR_INTERNAL; |
| 138 | } |
| 139 | |
Phil Burk | 8f4fe50 | 2020-07-15 23:54:50 +0000 | [diff] [blame] | 140 | mUpCommandQueue = std::make_unique<FifoBufferIndirect>( |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 141 | descriptor->bytesPerFrame, |
| 142 | descriptor->capacityInFrames, |
| 143 | descriptor->readCounterAddress, |
| 144 | descriptor->writeCounterAddress, |
| 145 | descriptor->dataAddress |
| 146 | ); |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 147 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 148 | // ============================ data queue ============================= |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 149 | descriptor = &pEndpointDescriptor->dataQueueDescriptor; |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 150 | ALOGV("configure() data framesPerBurst = %d", descriptor->framesPerBurst); |
| 151 | ALOGV("configure() data readCounterAddress = %p", |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 152 | descriptor->readCounterAddress); |
| 153 | |
| 154 | // An example of free running is when the other side is read or written by hardware DMA |
| 155 | // or a DSP. It does not update its counter so we have to update it. |
| 156 | int64_t *remoteCounter = (direction == AAUDIO_DIRECTION_OUTPUT) |
| 157 | ? descriptor->readCounterAddress // read by other side |
| 158 | : descriptor->writeCounterAddress; // written by other side |
| 159 | mFreeRunning = (remoteCounter == nullptr); |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 160 | ALOGV("configure() mFreeRunning = %d", mFreeRunning ? 1 : 0); |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 161 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 162 | int64_t *readCounterAddress = (descriptor->readCounterAddress == nullptr) |
| 163 | ? &mDataReadCounter |
| 164 | : descriptor->readCounterAddress; |
| 165 | int64_t *writeCounterAddress = (descriptor->writeCounterAddress == nullptr) |
| 166 | ? &mDataWriteCounter |
| 167 | : descriptor->writeCounterAddress; |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 168 | |
Phil Burk | 8f4fe50 | 2020-07-15 23:54:50 +0000 | [diff] [blame] | 169 | mDataQueue = std::make_unique<FifoBufferIndirect>( |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 170 | descriptor->bytesPerFrame, |
| 171 | descriptor->capacityInFrames, |
| 172 | readCounterAddress, |
| 173 | writeCounterAddress, |
| 174 | descriptor->dataAddress |
| 175 | ); |
| 176 | uint32_t threshold = descriptor->capacityInFrames / 2; |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 177 | mDataQueue->setThreshold(threshold); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 178 | return result; |
| 179 | } |
| 180 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 181 | aaudio_result_t AudioEndpoint::readUpCommand(AAudioServiceMessage *commandPtr) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 182 | { |
| 183 | return mUpCommandQueue->read(commandPtr, 1); |
| 184 | } |
| 185 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 186 | int32_t AudioEndpoint::getEmptyFramesAvailable(WrappingBuffer *wrappingBuffer) { |
| 187 | return mDataQueue->getEmptyRoomAvailable(wrappingBuffer); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 188 | } |
| 189 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 190 | int32_t AudioEndpoint::getEmptyFramesAvailable() { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 191 | return mDataQueue->getEmptyFramesAvailable(); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 194 | int32_t AudioEndpoint::getFullFramesAvailable(WrappingBuffer *wrappingBuffer) { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 195 | return mDataQueue->getFullDataAvailable(wrappingBuffer); |
Phil Burk | 4485d41 | 2017-05-09 15:55:02 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 198 | int32_t AudioEndpoint::getFullFramesAvailable() { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 199 | return mDataQueue->getFullFramesAvailable(); |
Phil Burk | 4485d41 | 2017-05-09 15:55:02 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 202 | void AudioEndpoint::advanceWriteIndex(int32_t deltaFrames) { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 203 | mDataQueue->advanceWriteIndex(deltaFrames); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 204 | } |
| 205 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 206 | void AudioEndpoint::advanceReadIndex(int32_t deltaFrames) { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 207 | mDataQueue->advanceReadIndex(deltaFrames); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 208 | } |
| 209 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 210 | void AudioEndpoint::setDataReadCounter(fifo_counter_t framesRead) { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 211 | mDataQueue->setReadCounter(framesRead); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 212 | } |
| 213 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 214 | fifo_counter_t AudioEndpoint::getDataReadCounter() const { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 215 | return mDataQueue->getReadCounter(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 216 | } |
| 217 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 218 | void AudioEndpoint::setDataWriteCounter(fifo_counter_t framesRead) { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 219 | mDataQueue->setWriteCounter(framesRead); |
| 220 | } |
| 221 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 222 | fifo_counter_t AudioEndpoint::getDataWriteCounter() const { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 223 | return mDataQueue->getWriteCounter(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 224 | } |
| 225 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 226 | int32_t AudioEndpoint::setBufferSizeInFrames(int32_t requestedFrames, |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 227 | int32_t *actualFrames) { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 228 | if (requestedFrames < ENDPOINT_DATA_QUEUE_SIZE_MIN) { |
| 229 | requestedFrames = ENDPOINT_DATA_QUEUE_SIZE_MIN; |
| 230 | } |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 231 | mDataQueue->setThreshold(requestedFrames); |
| 232 | *actualFrames = mDataQueue->getThreshold(); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 233 | return AAUDIO_OK; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 234 | } |
| 235 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 236 | int32_t AudioEndpoint::getBufferSizeInFrames() const { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 237 | return mDataQueue->getThreshold(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 240 | int32_t AudioEndpoint::getBufferCapacityInFrames() const { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 241 | return (int32_t)mDataQueue->getBufferCapacityInFrames(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 244 | void AudioEndpoint::dump() const { |
Phil Burk | 5edc4ea | 2020-04-17 08:15:42 -0700 | [diff] [blame] | 245 | ALOGD("data readCounter = %lld", (long long) getDataReadCounter()); |
| 246 | ALOGD("data writeCounter = %lld", (long long) getDataWriteCounter()); |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 247 | } |
Phil Burk | ea04d97 | 2017-08-07 12:30:44 -0700 | [diff] [blame] | 248 | |
| 249 | void AudioEndpoint::eraseDataMemory() { |
| 250 | mDataQueue->eraseMemory(); |
| 251 | } |