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 | 4a8d260 | 2017-08-09 16:53:35 -0700 | [diff] [blame] | 35 | : mUpCommandQueue(nullptr) |
| 36 | , mDataQueue(nullptr) |
| 37 | , mFreeRunning(false) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 38 | , mDataReadCounter(0) |
| 39 | , mDataWriteCounter(0) |
| 40 | { |
| 41 | } |
| 42 | |
Phil Burk | 4a8d260 | 2017-08-09 16:53:35 -0700 | [diff] [blame] | 43 | AudioEndpoint::~AudioEndpoint() { |
| 44 | delete mDataQueue; |
| 45 | delete mUpCommandQueue; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 46 | } |
| 47 | |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 48 | // TODO Consider moving to a method in RingBufferDescriptor |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 49 | static aaudio_result_t AudioEndpoint_validateQueueDescriptor(const char *type, |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 50 | const RingBufferDescriptor *descriptor) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 51 | if (descriptor == nullptr) { |
| 52 | ALOGE("AudioEndpoint_validateQueueDescriptor() NULL descriptor"); |
| 53 | return AAUDIO_ERROR_NULL; |
| 54 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 55 | |
| 56 | if (descriptor->capacityInFrames < 1 |
| 57 | || descriptor->capacityInFrames > RIDICULOUSLY_LARGE_BUFFER_CAPACITY) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 58 | ALOGE("AudioEndpoint_validateQueueDescriptor() bad capacityInFrames = %d", |
| 59 | descriptor->capacityInFrames); |
| 60 | return AAUDIO_ERROR_OUT_OF_RANGE; |
| 61 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 62 | |
| 63 | // Reject extreme values to catch bugs and prevent numeric overflows. |
| 64 | if (descriptor->bytesPerFrame < 1 |
| 65 | || descriptor->bytesPerFrame > RIDICULOUSLY_LARGE_FRAME_SIZE) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 66 | ALOGE("AudioEndpoint_validateQueueDescriptor() bad bytesPerFrame = %d", |
| 67 | descriptor->bytesPerFrame); |
| 68 | return AAUDIO_ERROR_OUT_OF_RANGE; |
| 69 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 70 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 71 | if (descriptor->dataAddress == nullptr) { |
| 72 | ALOGE("AudioEndpoint_validateQueueDescriptor() NULL dataAddress"); |
| 73 | return AAUDIO_ERROR_NULL; |
| 74 | } |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 75 | ALOGV("AudioEndpoint_validateQueueDescriptor %s, dataAddress at %p ====================", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 76 | type, |
| 77 | descriptor->dataAddress); |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 78 | ALOGV("AudioEndpoint_validateQueueDescriptor readCounter at %p, writeCounter at %p", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 79 | descriptor->readCounterAddress, |
| 80 | descriptor->writeCounterAddress); |
| 81 | |
| 82 | // Try to READ from the data area. |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 83 | // This code will crash if the mmap failed. |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 84 | uint8_t value = descriptor->dataAddress[0]; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 85 | ALOGV("AudioEndpoint_validateQueueDescriptor() dataAddress[0] = %d, then try to write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 86 | (int) value); |
| 87 | // Try to WRITE to the data area. |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 88 | descriptor->dataAddress[0] = value * 3; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 89 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 90 | |
| 91 | if (descriptor->readCounterAddress) { |
| 92 | fifo_counter_t counter = *descriptor->readCounterAddress; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 93 | ALOGV("AudioEndpoint_validateQueueDescriptor() *readCounterAddress = %d, now write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 94 | (int) counter); |
| 95 | *descriptor->readCounterAddress = counter; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 96 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote readCounterAddress successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 97 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 98 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 99 | if (descriptor->writeCounterAddress) { |
| 100 | fifo_counter_t counter = *descriptor->writeCounterAddress; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 101 | ALOGV("AudioEndpoint_validateQueueDescriptor() *writeCounterAddress = %d, now write", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 102 | (int) counter); |
| 103 | *descriptor->writeCounterAddress = counter; |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 104 | ALOGV("AudioEndpoint_validateQueueDescriptor() wrote writeCounterAddress successfully"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 105 | } |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 106 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 107 | return AAUDIO_OK; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 108 | } |
| 109 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 110 | aaudio_result_t AudioEndpoint_validateDescriptor(const EndpointDescriptor *pEndpointDescriptor) { |
| 111 | aaudio_result_t result = AudioEndpoint_validateQueueDescriptor("messages", |
| 112 | &pEndpointDescriptor->upMessageQueueDescriptor); |
| 113 | if (result == AAUDIO_OK) { |
| 114 | result = AudioEndpoint_validateQueueDescriptor("data", |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 115 | &pEndpointDescriptor->dataQueueDescriptor); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 116 | } |
| 117 | return result; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 118 | } |
| 119 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 120 | aaudio_result_t AudioEndpoint::configure(const EndpointDescriptor *pEndpointDescriptor, |
| 121 | aaudio_direction_t direction) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 122 | { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 123 | aaudio_result_t result = AudioEndpoint_validateDescriptor(pEndpointDescriptor); |
| 124 | if (result != AAUDIO_OK) { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 125 | return result; |
| 126 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 127 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 128 | // ============================ up message queue ============================= |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 129 | const RingBufferDescriptor *descriptor = &pEndpointDescriptor->upMessageQueueDescriptor; |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 130 | if(descriptor->bytesPerFrame != sizeof(AAudioServiceMessage)) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 131 | ALOGE("configure() bytesPerFrame != sizeof(AAudioServiceMessage) = %d", |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 132 | descriptor->bytesPerFrame); |
| 133 | return AAUDIO_ERROR_INTERNAL; |
| 134 | } |
| 135 | |
| 136 | if(descriptor->readCounterAddress == nullptr || descriptor->writeCounterAddress == nullptr) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 137 | ALOGE("configure() NULL counter address"); |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 138 | return AAUDIO_ERROR_NULL; |
| 139 | } |
| 140 | |
Phil Burk | 99306c8 | 2017-08-14 12:38:58 -0700 | [diff] [blame] | 141 | // Prevent memory leak and reuse. |
| 142 | if(mUpCommandQueue != nullptr || mDataQueue != nullptr) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 143 | ALOGE("configure() endpoint already used"); |
Phil Burk | 99306c8 | 2017-08-14 12:38:58 -0700 | [diff] [blame] | 144 | return AAUDIO_ERROR_INTERNAL; |
| 145 | } |
| 146 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 147 | mUpCommandQueue = new FifoBuffer( |
| 148 | descriptor->bytesPerFrame, |
| 149 | descriptor->capacityInFrames, |
| 150 | descriptor->readCounterAddress, |
| 151 | descriptor->writeCounterAddress, |
| 152 | descriptor->dataAddress |
| 153 | ); |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 154 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 155 | // ============================ data queue ============================= |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 156 | descriptor = &pEndpointDescriptor->dataQueueDescriptor; |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 157 | ALOGV("configure() data framesPerBurst = %d", descriptor->framesPerBurst); |
| 158 | ALOGV("configure() data readCounterAddress = %p", |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 159 | descriptor->readCounterAddress); |
| 160 | |
| 161 | // An example of free running is when the other side is read or written by hardware DMA |
| 162 | // or a DSP. It does not update its counter so we have to update it. |
| 163 | int64_t *remoteCounter = (direction == AAUDIO_DIRECTION_OUTPUT) |
| 164 | ? descriptor->readCounterAddress // read by other side |
| 165 | : descriptor->writeCounterAddress; // written by other side |
| 166 | mFreeRunning = (remoteCounter == nullptr); |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 167 | ALOGV("configure() mFreeRunning = %d", mFreeRunning ? 1 : 0); |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 168 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 169 | int64_t *readCounterAddress = (descriptor->readCounterAddress == nullptr) |
| 170 | ? &mDataReadCounter |
| 171 | : descriptor->readCounterAddress; |
| 172 | int64_t *writeCounterAddress = (descriptor->writeCounterAddress == nullptr) |
| 173 | ? &mDataWriteCounter |
| 174 | : descriptor->writeCounterAddress; |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 175 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 176 | mDataQueue = new FifoBuffer( |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 177 | descriptor->bytesPerFrame, |
| 178 | descriptor->capacityInFrames, |
| 179 | readCounterAddress, |
| 180 | writeCounterAddress, |
| 181 | descriptor->dataAddress |
| 182 | ); |
| 183 | uint32_t threshold = descriptor->capacityInFrames / 2; |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 184 | mDataQueue->setThreshold(threshold); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 185 | return result; |
| 186 | } |
| 187 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 188 | aaudio_result_t AudioEndpoint::readUpCommand(AAudioServiceMessage *commandPtr) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 189 | { |
| 190 | return mUpCommandQueue->read(commandPtr, 1); |
| 191 | } |
| 192 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 193 | int32_t AudioEndpoint::getEmptyFramesAvailable(WrappingBuffer *wrappingBuffer) { |
| 194 | return mDataQueue->getEmptyRoomAvailable(wrappingBuffer); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 195 | } |
| 196 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 197 | int32_t AudioEndpoint::getEmptyFramesAvailable() |
| 198 | { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 199 | return mDataQueue->getEmptyFramesAvailable(); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 200 | } |
| 201 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 202 | int32_t AudioEndpoint::getFullFramesAvailable(WrappingBuffer *wrappingBuffer) |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 203 | { |
| 204 | return mDataQueue->getFullDataAvailable(wrappingBuffer); |
Phil Burk | 4485d41 | 2017-05-09 15:55:02 -0700 | [diff] [blame] | 205 | } |
| 206 | |
| 207 | int32_t AudioEndpoint::getFullFramesAvailable() |
| 208 | { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 209 | return mDataQueue->getFullFramesAvailable(); |
Phil Burk | 4485d41 | 2017-05-09 15:55:02 -0700 | [diff] [blame] | 210 | } |
| 211 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 212 | void AudioEndpoint::advanceWriteIndex(int32_t deltaFrames) { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 213 | mDataQueue->advanceWriteIndex(deltaFrames); |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 214 | } |
| 215 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 216 | void AudioEndpoint::advanceReadIndex(int32_t deltaFrames) { |
Phil Burk | 882c520 | 2018-04-23 10:32:45 -0700 | [diff] [blame] | 217 | mDataQueue->advanceReadIndex(deltaFrames); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 220 | void AudioEndpoint::setDataReadCounter(fifo_counter_t framesRead) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 221 | { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 222 | mDataQueue->setReadCounter(framesRead); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 223 | } |
| 224 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 225 | fifo_counter_t AudioEndpoint::getDataReadCounter() |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 226 | { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 227 | return mDataQueue->getReadCounter(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 228 | } |
| 229 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 230 | void AudioEndpoint::setDataWriteCounter(fifo_counter_t framesRead) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 231 | { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 232 | mDataQueue->setWriteCounter(framesRead); |
| 233 | } |
| 234 | |
| 235 | fifo_counter_t AudioEndpoint::getDataWriteCounter() |
| 236 | { |
| 237 | return mDataQueue->getWriteCounter(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 238 | } |
| 239 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 240 | int32_t AudioEndpoint::setBufferSizeInFrames(int32_t requestedFrames, |
| 241 | int32_t *actualFrames) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 242 | { |
| 243 | if (requestedFrames < ENDPOINT_DATA_QUEUE_SIZE_MIN) { |
| 244 | requestedFrames = ENDPOINT_DATA_QUEUE_SIZE_MIN; |
| 245 | } |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 246 | mDataQueue->setThreshold(requestedFrames); |
| 247 | *actualFrames = mDataQueue->getThreshold(); |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 248 | return AAUDIO_OK; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 249 | } |
| 250 | |
| 251 | int32_t AudioEndpoint::getBufferSizeInFrames() const |
| 252 | { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 253 | return mDataQueue->getThreshold(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 254 | } |
| 255 | |
| 256 | int32_t AudioEndpoint::getBufferCapacityInFrames() const |
| 257 | { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 258 | return (int32_t)mDataQueue->getBufferCapacityInFrames(); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 259 | } |
| 260 | |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 261 | void AudioEndpoint::dump() const { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 262 | ALOGD("data readCounter = %lld", (long long) mDataQueue->getReadCounter()); |
| 263 | ALOGD("data writeCounter = %lld", (long long) mDataQueue->getWriteCounter()); |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 264 | } |
Phil Burk | ea04d97 | 2017-08-07 12:30:44 -0700 | [diff] [blame] | 265 | |
| 266 | void AudioEndpoint::eraseDataMemory() { |
| 267 | mDataQueue->eraseMemory(); |
| 268 | } |