Loading media/libaaudio/src/client/AudioStreamInternal.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { } const int32_t callbackBufferSize = mCallbackFrames * getBytesPerFrame(); mCallbackBuffer = new uint8_t[callbackBufferSize]; mCallbackBuffer = std::make_unique<uint8_t[]>(callbackBufferSize); } // For debugging and analyzing the distribution of MMAP timestamps. Loading Loading @@ -279,8 +279,7 @@ aaudio_result_t AudioStreamInternal::release_l() { mServiceStreamHandle = AAUDIO_HANDLE_INVALID; mServiceInterface.closeStream(serviceStreamHandle); delete[] mCallbackBuffer; mCallbackBuffer = nullptr; mCallbackBuffer.reset(); result = mEndPointParcelable.close(); aaudio_result_t result2 = AudioStream::release_l(); return (result != AAUDIO_OK) ? result : result2; Loading media/libaaudio/src/client/AudioStreamInternal.h +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ protected: // Offset from underlying frame position. int64_t mFramesOffsetFromService = 0; // offset for timestamps uint8_t *mCallbackBuffer = nullptr; std::unique_ptr<uint8_t[]> mCallbackBuffer; int32_t mCallbackFrames = 0; // The service uses this for SHARED mode. Loading media/libaaudio/src/client/AudioStreamInternalCapture.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ void *AudioStreamInternalCapture::callbackLoop() { int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames); // This is a BLOCKING READ! result = read(mCallbackBuffer, mCallbackFrames, timeoutNanos); result = read(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { ALOGE("callbackLoop: read() returned %d", result); if (result >= 0) { Loading @@ -255,7 +255,7 @@ void *AudioStreamInternalCapture::callbackLoop() { } // Call application using the AAudio callback interface. callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames); callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames); if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); Loading media/libaaudio/src/client/AudioStreamInternalPlay.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -268,11 +268,11 @@ void *AudioStreamInternalPlay::callbackLoop() { // result might be a frame count while (mCallbackEnabled.load() && isActive() && (result >= 0)) { // Call application using the AAudio callback interface. callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames); callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames); if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { // Write audio data to stream. This is a BLOCKING WRITE! result = write(mCallbackBuffer, mCallbackFrames, timeoutNanos); result = write(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { if (result >= 0) { // Only wrote some of the frames requested. Must have timed out. Loading media/libaaudio/tests/test_various.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -29,14 +29,19 @@ // Callback function that does nothing. aaudio_data_callback_result_t NoopDataCallbackProc( AAudioStream * stream, void *userData, void * /* userData */, void *audioData, int32_t numFrames ) { (void) stream; (void) userData; (void) audioData; (void) numFrames; int channels = AAudioStream_getChannelCount(stream); int numSamples = channels * numFrames; bool allZeros = true; float * const floatData = reinterpret_cast<float *>(audioData); for (int i = 0; i < numSamples; i++) { allZeros &= (floatData[i] == 0.0f); floatData[i] = 0.0f; } EXPECT_TRUE(allZeros); return AAUDIO_CALLBACK_RESULT_CONTINUE; } Loading @@ -56,6 +61,7 @@ void checkReleaseThenClose(aaudio_performance_mode_t perfMode, nullptr); AAudioStreamBuilder_setPerformanceMode(aaudioBuilder, perfMode); AAudioStreamBuilder_setSharingMode(aaudioBuilder, sharingMode); AAudioStreamBuilder_setFormat(aaudioBuilder, AAUDIO_FORMAT_PCM_FLOAT); // Create an AAudioStream using the Builder. ASSERT_EQ(AAUDIO_OK, Loading Loading @@ -114,6 +120,7 @@ void checkStateTransition(aaudio_performance_mode_t perfMode, // Request stream properties. AAudioStreamBuilder_setDataCallback(aaudioBuilder, NoopDataCallbackProc, nullptr); AAudioStreamBuilder_setPerformanceMode(aaudioBuilder, perfMode); AAudioStreamBuilder_setFormat(aaudioBuilder, AAUDIO_FORMAT_PCM_FLOAT); // Create an AAudioStream using the Builder. ASSERT_EQ(AAUDIO_OK, AAudioStreamBuilder_openStream(aaudioBuilder, &aaudioStream)); Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -230,7 +230,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { } const int32_t callbackBufferSize = mCallbackFrames * getBytesPerFrame(); mCallbackBuffer = new uint8_t[callbackBufferSize]; mCallbackBuffer = std::make_unique<uint8_t[]>(callbackBufferSize); } // For debugging and analyzing the distribution of MMAP timestamps. Loading Loading @@ -279,8 +279,7 @@ aaudio_result_t AudioStreamInternal::release_l() { mServiceStreamHandle = AAUDIO_HANDLE_INVALID; mServiceInterface.closeStream(serviceStreamHandle); delete[] mCallbackBuffer; mCallbackBuffer = nullptr; mCallbackBuffer.reset(); result = mEndPointParcelable.close(); aaudio_result_t result2 = AudioStream::release_l(); return (result != AAUDIO_OK) ? result : result2; Loading
media/libaaudio/src/client/AudioStreamInternal.h +1 −1 Original line number Diff line number Diff line Loading @@ -164,7 +164,7 @@ protected: // Offset from underlying frame position. int64_t mFramesOffsetFromService = 0; // offset for timestamps uint8_t *mCallbackBuffer = nullptr; std::unique_ptr<uint8_t[]> mCallbackBuffer; int32_t mCallbackFrames = 0; // The service uses this for SHARED mode. Loading
media/libaaudio/src/client/AudioStreamInternalCapture.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -243,7 +243,7 @@ void *AudioStreamInternalCapture::callbackLoop() { int64_t timeoutNanos = calculateReasonableTimeout(mCallbackFrames); // This is a BLOCKING READ! result = read(mCallbackBuffer, mCallbackFrames, timeoutNanos); result = read(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { ALOGE("callbackLoop: read() returned %d", result); if (result >= 0) { Loading @@ -255,7 +255,7 @@ void *AudioStreamInternalCapture::callbackLoop() { } // Call application using the AAudio callback interface. callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames); callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames); if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) { ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__); Loading
media/libaaudio/src/client/AudioStreamInternalPlay.cpp +2 −2 Original line number Diff line number Diff line Loading @@ -268,11 +268,11 @@ void *AudioStreamInternalPlay::callbackLoop() { // result might be a frame count while (mCallbackEnabled.load() && isActive() && (result >= 0)) { // Call application using the AAudio callback interface. callbackResult = maybeCallDataCallback(mCallbackBuffer, mCallbackFrames); callbackResult = maybeCallDataCallback(mCallbackBuffer.get(), mCallbackFrames); if (callbackResult == AAUDIO_CALLBACK_RESULT_CONTINUE) { // Write audio data to stream. This is a BLOCKING WRITE! result = write(mCallbackBuffer, mCallbackFrames, timeoutNanos); result = write(mCallbackBuffer.get(), mCallbackFrames, timeoutNanos); if ((result != mCallbackFrames)) { if (result >= 0) { // Only wrote some of the frames requested. Must have timed out. Loading
media/libaaudio/tests/test_various.cpp +13 −6 Original line number Diff line number Diff line Loading @@ -29,14 +29,19 @@ // Callback function that does nothing. aaudio_data_callback_result_t NoopDataCallbackProc( AAudioStream * stream, void *userData, void * /* userData */, void *audioData, int32_t numFrames ) { (void) stream; (void) userData; (void) audioData; (void) numFrames; int channels = AAudioStream_getChannelCount(stream); int numSamples = channels * numFrames; bool allZeros = true; float * const floatData = reinterpret_cast<float *>(audioData); for (int i = 0; i < numSamples; i++) { allZeros &= (floatData[i] == 0.0f); floatData[i] = 0.0f; } EXPECT_TRUE(allZeros); return AAUDIO_CALLBACK_RESULT_CONTINUE; } Loading @@ -56,6 +61,7 @@ void checkReleaseThenClose(aaudio_performance_mode_t perfMode, nullptr); AAudioStreamBuilder_setPerformanceMode(aaudioBuilder, perfMode); AAudioStreamBuilder_setSharingMode(aaudioBuilder, sharingMode); AAudioStreamBuilder_setFormat(aaudioBuilder, AAUDIO_FORMAT_PCM_FLOAT); // Create an AAudioStream using the Builder. ASSERT_EQ(AAUDIO_OK, Loading Loading @@ -114,6 +120,7 @@ void checkStateTransition(aaudio_performance_mode_t perfMode, // Request stream properties. AAudioStreamBuilder_setDataCallback(aaudioBuilder, NoopDataCallbackProc, nullptr); AAudioStreamBuilder_setPerformanceMode(aaudioBuilder, perfMode); AAudioStreamBuilder_setFormat(aaudioBuilder, AAUDIO_FORMAT_PCM_FLOAT); // Create an AAudioStream using the Builder. ASSERT_EQ(AAUDIO_OK, AAudioStreamBuilder_openStream(aaudioBuilder, &aaudioStream)); Loading