Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 (mInService ? "AudioStreamInternalPlay_Service" \ |
| 18 | : "AudioStreamInternalPlay_Client") |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 19 | //#define LOG_NDEBUG 0 |
| 20 | #include <utils/Log.h> |
| 21 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 22 | #define ATRACE_TAG ATRACE_TAG_AUDIO |
| 23 | |
| 24 | #include <utils/Trace.h> |
| 25 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 26 | #include "client/AudioStreamInternalPlay.h" |
| 27 | #include "utility/AudioClock.h" |
| 28 | |
| 29 | using android::WrappingBuffer; |
| 30 | |
| 31 | using namespace aaudio; |
| 32 | |
| 33 | AudioStreamInternalPlay::AudioStreamInternalPlay(AAudioServiceInterface &serviceInterface, |
| 34 | bool inService) |
| 35 | : AudioStreamInternal(serviceInterface, inService) { |
| 36 | |
| 37 | } |
| 38 | |
| 39 | AudioStreamInternalPlay::~AudioStreamInternalPlay() {} |
| 40 | |
Phil Burk | 5cc83c3 | 2017-11-28 15:43:18 -0800 | [diff] [blame] | 41 | aaudio_result_t AudioStreamInternalPlay::requestPause() |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 42 | { |
Phil Burk | 5cc83c3 | 2017-11-28 15:43:18 -0800 | [diff] [blame] | 43 | aaudio_result_t result = stopCallback(); |
| 44 | if (result != AAUDIO_OK) { |
| 45 | return result; |
| 46 | } |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 47 | if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { |
| 48 | ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X", |
| 49 | mServiceStreamHandle); |
| 50 | return AAUDIO_ERROR_INVALID_STATE; |
| 51 | } |
| 52 | |
| 53 | mClockModel.stop(AudioClock::getNanoseconds()); |
| 54 | setState(AAUDIO_STREAM_STATE_PAUSING); |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 55 | mAtomicTimestamp.clear(); |
Phil Burk | 965650e | 2017-09-07 21:00:09 -0700 | [diff] [blame] | 56 | return mServiceInterface.pauseStream(mServiceStreamHandle); |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 57 | } |
| 58 | |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 59 | aaudio_result_t AudioStreamInternalPlay::requestFlush() { |
| 60 | if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) { |
| 61 | ALOGE("AudioStreamInternal::requestFlush() mServiceStreamHandle invalid = 0x%08X", |
| 62 | mServiceStreamHandle); |
| 63 | return AAUDIO_ERROR_INVALID_STATE; |
| 64 | } |
| 65 | |
| 66 | setState(AAUDIO_STREAM_STATE_FLUSHING); |
| 67 | return mServiceInterface.flushStream(mServiceStreamHandle); |
| 68 | } |
| 69 | |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 70 | void AudioStreamInternalPlay::advanceClientToMatchServerPosition() { |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 71 | int64_t readCounter = mAudioEndpoint.getDataReadCounter(); |
| 72 | int64_t writeCounter = mAudioEndpoint.getDataWriteCounter(); |
| 73 | |
| 74 | // Bump offset so caller does not see the retrograde motion in getFramesRead(). |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 75 | int64_t offset = writeCounter - readCounter; |
| 76 | mFramesOffsetFromService += offset; |
| 77 | ALOGD("advanceClientToMatchServerPosition() readN = %lld, writeN = %lld, offset = %lld", |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 78 | (long long)readCounter, (long long)writeCounter, (long long)mFramesOffsetFromService); |
| 79 | |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 80 | // Force writeCounter to match readCounter. |
| 81 | // This is because we cannot change the read counter in the hardware. |
Phil Burk | b336e89 | 2017-07-05 15:35:43 -0700 | [diff] [blame] | 82 | mAudioEndpoint.setDataWriteCounter(readCounter); |
| 83 | } |
| 84 | |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 85 | void AudioStreamInternalPlay::onFlushFromServer() { |
| 86 | advanceClientToMatchServerPosition(); |
| 87 | } |
| 88 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 89 | // Write the data, block if needed and timeoutMillis > 0 |
| 90 | aaudio_result_t AudioStreamInternalPlay::write(const void *buffer, int32_t numFrames, |
| 91 | int64_t timeoutNanoseconds) |
| 92 | |
| 93 | { |
| 94 | return processData((void *)buffer, numFrames, timeoutNanoseconds); |
| 95 | } |
| 96 | |
| 97 | // Write as much data as we can without blocking. |
| 98 | aaudio_result_t AudioStreamInternalPlay::processDataNow(void *buffer, int32_t numFrames, |
| 99 | int64_t currentNanoTime, int64_t *wakeTimePtr) { |
| 100 | aaudio_result_t result = processCommands(); |
| 101 | if (result != AAUDIO_OK) { |
| 102 | return result; |
| 103 | } |
| 104 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 105 | const char *traceName = "aaWrNow"; |
| 106 | ATRACE_BEGIN(traceName); |
| 107 | |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 108 | if (mClockModel.isStarting()) { |
| 109 | // Still haven't got any timestamps from server. |
| 110 | // Keep waiting until we get some valid timestamps then start writing to the |
| 111 | // current buffer position. |
| 112 | ALOGD("processDataNow() wait for valid timestamps"); |
| 113 | // Sleep very briefly and hope we get a timestamp soon. |
| 114 | *wakeTimePtr = currentNanoTime + (2000 * AAUDIO_NANOS_PER_MICROSECOND); |
| 115 | ATRACE_END(); |
| 116 | return 0; |
| 117 | } |
| 118 | // If we have gotten this far then we have at least one timestamp from server. |
| 119 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 120 | // If a DMA channel or DSP is reading the other end then we have to update the readCounter. |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 121 | if (mAudioEndpoint.isFreeRunning()) { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 122 | // Update data queue based on the timing model. |
| 123 | int64_t estimatedReadCounter = mClockModel.convertTimeToPosition(currentNanoTime); |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 124 | // ALOGD("AudioStreamInternal::processDataNow() - estimatedReadCounter = %d", (int)estimatedReadCounter); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 125 | mAudioEndpoint.setDataReadCounter(estimatedReadCounter); |
| 126 | } |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 127 | |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 128 | if (mNeedCatchUp.isRequested()) { |
| 129 | // Catch an MMAP pointer that is already advancing. |
| 130 | // This will avoid initial underruns caused by a slow cold start. |
| 131 | advanceClientToMatchServerPosition(); |
| 132 | mNeedCatchUp.acknowledge(); |
| 133 | } |
| 134 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 135 | // If the read index passed the write index then consider it an underrun. |
Phil Burk | 2329638 | 2017-11-20 15:45:11 -0800 | [diff] [blame] | 136 | // For shared streams, the xRunCount is passed up from the service. |
| 137 | if (mAudioEndpoint.isFreeRunning() && mAudioEndpoint.getFullFramesAvailable() < 0) { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 138 | mXRunCount++; |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 139 | if (ATRACE_ENABLED()) { |
| 140 | ATRACE_INT("aaUnderRuns", mXRunCount); |
| 141 | } |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | // Write some data to the buffer. |
| 145 | //ALOGD("AudioStreamInternal::processDataNow() - writeNowWithConversion(%d)", numFrames); |
| 146 | int32_t framesWritten = writeNowWithConversion(buffer, numFrames); |
| 147 | //ALOGD("AudioStreamInternal::processDataNow() - tried to write %d frames, wrote %d", |
| 148 | // numFrames, framesWritten); |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 149 | if (ATRACE_ENABLED()) { |
| 150 | ATRACE_INT("aaWrote", framesWritten); |
| 151 | } |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 152 | |
| 153 | // Calculate an ideal time to wake up. |
| 154 | if (wakeTimePtr != nullptr && framesWritten >= 0) { |
| 155 | // By default wake up a few milliseconds from now. // TODO review |
| 156 | int64_t wakeTime = currentNanoTime + (1 * AAUDIO_NANOS_PER_MILLISECOND); |
| 157 | aaudio_stream_state_t state = getState(); |
| 158 | //ALOGD("AudioStreamInternal::processDataNow() - wakeTime based on %s", |
| 159 | // AAudio_convertStreamStateToText(state)); |
| 160 | switch (state) { |
| 161 | case AAUDIO_STREAM_STATE_OPEN: |
| 162 | case AAUDIO_STREAM_STATE_STARTING: |
| 163 | if (framesWritten != 0) { |
| 164 | // Don't wait to write more data. Just prime the buffer. |
| 165 | wakeTime = currentNanoTime; |
| 166 | } |
| 167 | break; |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 168 | case AAUDIO_STREAM_STATE_STARTED: |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 169 | { |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 170 | // When do we expect the next read burst to occur? |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 171 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 172 | // Calculate frame position based off of the writeCounter because |
| 173 | // the readCounter might have just advanced in the background, |
| 174 | // causing us to sleep until a later burst. |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 175 | int64_t nextPosition = mAudioEndpoint.getDataWriteCounter() + mFramesPerBurst |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 176 | - mAudioEndpoint.getBufferSizeInFrames(); |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 177 | wakeTime = mClockModel.convertPositionToTime(nextPosition); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 178 | } |
| 179 | break; |
| 180 | default: |
| 181 | break; |
| 182 | } |
| 183 | *wakeTimePtr = wakeTime; |
| 184 | |
| 185 | } |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 186 | |
| 187 | ATRACE_END(); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 188 | return framesWritten; |
| 189 | } |
| 190 | |
| 191 | |
| 192 | aaudio_result_t AudioStreamInternalPlay::writeNowWithConversion(const void *buffer, |
| 193 | int32_t numFrames) { |
| 194 | // ALOGD("AudioStreamInternal::writeNowWithConversion(%p, %d)", |
| 195 | // buffer, numFrames); |
| 196 | WrappingBuffer wrappingBuffer; |
| 197 | uint8_t *source = (uint8_t *) buffer; |
| 198 | int32_t framesLeft = numFrames; |
| 199 | |
| 200 | mAudioEndpoint.getEmptyFramesAvailable(&wrappingBuffer); |
| 201 | |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 202 | // Write data in one or two parts. |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 203 | int partIndex = 0; |
| 204 | while (framesLeft > 0 && partIndex < WrappingBuffer::SIZE) { |
| 205 | int32_t framesToWrite = framesLeft; |
| 206 | int32_t framesAvailable = wrappingBuffer.numFrames[partIndex]; |
| 207 | if (framesAvailable > 0) { |
| 208 | if (framesToWrite > framesAvailable) { |
| 209 | framesToWrite = framesAvailable; |
| 210 | } |
| 211 | int32_t numBytes = getBytesPerFrame() * framesToWrite; |
| 212 | int32_t numSamples = framesToWrite * getSamplesPerFrame(); |
| 213 | // Data conversion. |
| 214 | float levelFrom; |
| 215 | float levelTo; |
Phil Burk | 9eba210 | 2017-11-20 12:25:38 -0800 | [diff] [blame] | 216 | bool ramping = mVolumeRamp.nextSegment(framesToWrite, &levelFrom, &levelTo); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 217 | // The formats are validated when the stream is opened so we do not have to |
| 218 | // check for illegal combinations here. |
| 219 | // TODO factor this out into a utility function |
| 220 | if (getFormat() == AAUDIO_FORMAT_PCM_FLOAT) { |
| 221 | if (mDeviceFormat == AAUDIO_FORMAT_PCM_FLOAT) { |
| 222 | AAudio_linearRamp( |
| 223 | (const float *) source, |
| 224 | (float *) wrappingBuffer.data[partIndex], |
| 225 | framesToWrite, |
| 226 | getSamplesPerFrame(), |
| 227 | levelFrom, |
| 228 | levelTo); |
| 229 | } else if (mDeviceFormat == AAUDIO_FORMAT_PCM_I16) { |
| 230 | if (ramping) { |
| 231 | AAudioConvert_floatToPcm16( |
| 232 | (const float *) source, |
| 233 | (int16_t *) wrappingBuffer.data[partIndex], |
| 234 | framesToWrite, |
| 235 | getSamplesPerFrame(), |
| 236 | levelFrom, |
| 237 | levelTo); |
| 238 | } else { |
| 239 | AAudioConvert_floatToPcm16( |
| 240 | (const float *) source, |
| 241 | (int16_t *) wrappingBuffer.data[partIndex], |
| 242 | numSamples, |
| 243 | levelTo); |
| 244 | } |
| 245 | } |
| 246 | } else if (getFormat() == AAUDIO_FORMAT_PCM_I16) { |
| 247 | if (mDeviceFormat == AAUDIO_FORMAT_PCM_FLOAT) { |
| 248 | if (ramping) { |
| 249 | AAudioConvert_pcm16ToFloat( |
| 250 | (const int16_t *) source, |
| 251 | (float *) wrappingBuffer.data[partIndex], |
| 252 | framesToWrite, |
| 253 | getSamplesPerFrame(), |
| 254 | levelFrom, |
| 255 | levelTo); |
| 256 | } else { |
| 257 | AAudioConvert_pcm16ToFloat( |
| 258 | (const int16_t *) source, |
| 259 | (float *) wrappingBuffer.data[partIndex], |
| 260 | numSamples, |
| 261 | levelTo); |
| 262 | } |
| 263 | } else if (mDeviceFormat == AAUDIO_FORMAT_PCM_I16) { |
| 264 | AAudio_linearRamp( |
| 265 | (const int16_t *) source, |
| 266 | (int16_t *) wrappingBuffer.data[partIndex], |
| 267 | framesToWrite, |
| 268 | getSamplesPerFrame(), |
| 269 | levelFrom, |
| 270 | levelTo); |
| 271 | } |
| 272 | } |
| 273 | source += numBytes; |
| 274 | framesLeft -= framesToWrite; |
| 275 | } else { |
| 276 | break; |
| 277 | } |
| 278 | partIndex++; |
| 279 | } |
| 280 | int32_t framesWritten = numFrames - framesLeft; |
| 281 | mAudioEndpoint.advanceWriteIndex(framesWritten); |
| 282 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 283 | // ALOGD("AudioStreamInternal::writeNowWithConversion() returns %d", framesWritten); |
| 284 | return framesWritten; |
| 285 | } |
| 286 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 287 | int64_t AudioStreamInternalPlay::getFramesRead() |
| 288 | { |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 289 | int64_t framesReadHardware; |
| 290 | if (isActive()) { |
| 291 | framesReadHardware = mClockModel.convertTimeToPosition(AudioClock::getNanoseconds()); |
| 292 | } else { |
| 293 | framesReadHardware = mAudioEndpoint.getDataReadCounter(); |
| 294 | } |
| 295 | int64_t framesRead = framesReadHardware + mFramesOffsetFromService; |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 296 | // Prevent retrograde motion. |
| 297 | if (framesRead < mLastFramesRead) { |
| 298 | framesRead = mLastFramesRead; |
| 299 | } else { |
| 300 | mLastFramesRead = framesRead; |
| 301 | } |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 302 | //ALOGD("AudioStreamInternalPlay::getFramesRead() returns %lld", (long long)framesRead); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 303 | return framesRead; |
| 304 | } |
| 305 | |
| 306 | int64_t AudioStreamInternalPlay::getFramesWritten() |
| 307 | { |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 308 | int64_t framesWritten = mAudioEndpoint.getDataWriteCounter() |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 309 | + mFramesOffsetFromService; |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 310 | //ALOGD("AudioStreamInternalPlay::getFramesWritten() returns %lld", (long long)framesWritten); |
| 311 | return framesWritten; |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | |
| 315 | // Render audio in the application callback and then write the data to the stream. |
| 316 | void *AudioStreamInternalPlay::callbackLoop() { |
| 317 | aaudio_result_t result = AAUDIO_OK; |
| 318 | aaudio_data_callback_result_t callbackResult = AAUDIO_CALLBACK_RESULT_CONTINUE; |
Phil Burk | 134f197 | 2017-12-08 13:06:11 -0800 | [diff] [blame] | 319 | if (!isDataCallbackSet()) return NULL; |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 320 | int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 321 | |
| 322 | // result might be a frame count |
| 323 | while (mCallbackEnabled.load() && isActive() && (result >= 0)) { |
| 324 | // Call application using the AAudio callback interface. |
Phil Burk | 134f197 | 2017-12-08 13:06:11 -0800 | [diff] [blame] | 325 | callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 326 | |
| 327 | if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 328 | // Write audio data to stream. This is a BLOCKING WRITE! |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 329 | result = write(mCallbackBuffer, mCallbackFrames, timeoutNanos); |
| 330 | if ((result != mCallbackFrames)) { |
| 331 | ALOGE("AudioStreamInternalPlay(): callbackLoop: write() returned %d", result); |
| 332 | if (result >= 0) { |
| 333 | // Only wrote some of the frames requested. Must have timed out. |
| 334 | result = AAUDIO_ERROR_TIMEOUT; |
| 335 | } |
Phil Burk | 134f197 | 2017-12-08 13:06:11 -0800 | [diff] [blame] | 336 | maybeCallErrorCallback(result); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 337 | break; |
| 338 | } |
| 339 | } else if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { |
| 340 | ALOGD("AudioStreamInternalPlay(): callback returned AAUDIO_CALLBACK_RESULT_STOP"); |
| 341 | break; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | ALOGD("AudioStreamInternalPlay(): callbackLoop() exiting, result = %d, isActive() = %d", |
| 346 | result, (int) isActive()); |
| 347 | return NULL; |
| 348 | } |
Phil Burk | 965650e | 2017-09-07 21:00:09 -0700 | [diff] [blame] | 349 | |
| 350 | //------------------------------------------------------------------------------ |
| 351 | // Implementation of PlayerBase |
| 352 | status_t AudioStreamInternalPlay::doSetVolume() { |
| 353 | mVolumeRamp.setTarget(mStreamVolume * getDuckAndMuteVolume()); |
| 354 | return android::NO_ERROR; |
| 355 | } |