Loading media/libaaudio/src/client/AudioStreamInternal.cpp +1 −6 Original line number Diff line number Diff line Loading @@ -134,12 +134,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { request.getConfiguration().setInputPreset(getInputPreset()); request.getConfiguration().setPrivacySensitive(isPrivacySensitive()); // When sample rate conversion is needed, we use the device sample rate instead of the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the (sampleRate / deviceSampleRate) // scaling there. request.getConfiguration().setBufferCapacity(builder.getBufferCapacity() * 48000 / getSampleRate()); request.getConfiguration().setBufferCapacity(builder.getBufferCapacity()); mServiceStreamHandleInfo = mServiceInterface.openStream(request, configurationOutput); if (getServiceHandle() < 0 Loading services/oboeservice/AAudioServiceEndpointMMAP.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,21 @@ aaudio_result_t AAudioServiceEndpointMMAP::openWithConfig( ALOGD("%s(format = 0x%X) deviceIds = %s, sessionId = %d", __func__, config->format, toString(getDeviceIds()).c_str(), getSessionId()); ALOGD("%s bufferCapacity = %d, deviceSampleRate = %d, requestedSampleRate = %d", __func__, getBufferCapacity(), config->sample_rate, getSampleRate()); const int32_t requestedSampleRate = getSampleRate(); const int32_t deviceSampleRate = config->sample_rate; // When sample rate conversion is needed, we use the device sample rate and the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the // (requestedSampleRate / deviceSampleRate) scaling there. if (requestedSampleRate != AAUDIO_UNSPECIFIED && requestedSampleRate != deviceSampleRate) { setBufferCapacity(static_cast<int64_t>(getBufferCapacity()) * deviceSampleRate / requestedSampleRate); } // Create MMAP/NOIRQ buffer. result = createMmapBuffer_l(); if (result != AAUDIO_OK) { Loading services/oboeservice/AAudioServiceStreamShared.cpp +17 −2 Original line number Diff line number Diff line Loading @@ -76,7 +76,21 @@ std::string AAudioServiceStreamShared::dump() const NO_THREAD_SAFETY_ANALYSIS { } int32_t AAudioServiceStreamShared::calculateBufferCapacity(int32_t requestedCapacityFrames, int32_t framesPerBurst) { int32_t framesPerBurst, int32_t requestedSampleRate, int32_t deviceSampleRate) { if (requestedSampleRate != AAUDIO_UNSPECIFIED && requestedSampleRate != deviceSampleRate) { // When sample rate conversion is needed, we use the device sample rate and the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the // (requestedSampleRate / deviceSampleRate) scaling there. requestedCapacityFrames = static_cast<int64_t>(requestedCapacityFrames) * deviceSampleRate / requestedSampleRate; ALOGV("calculateBufferCapacity() scaled buffer capacity to %d frames, requested SR = %d" ", device SR = %d", requestedCapacityFrames, requestedSampleRate, deviceSampleRate); } if (requestedCapacityFrames > MAX_FRAMES_PER_BUFFER) { ALOGE("calculateBufferCapacity() requested capacity %d > max %d", Loading Loading @@ -168,7 +182,8 @@ aaudio_result_t AAudioServiceStreamShared::open(const aaudio::AAudioStreamReques } setBufferCapacity(calculateBufferCapacity(configurationInput.getBufferCapacity(), mFramesPerBurst)); mFramesPerBurst, configurationInput.getSampleRate(), getSampleRate())); if (getBufferCapacity() < 0) { result = getBufferCapacity(); // negative error code setBufferCapacity(0); Loading services/oboeservice/AAudioServiceStreamShared.h +3 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,9 @@ protected: * @return capacity or negative error */ static int32_t calculateBufferCapacity(int32_t requestedCapacityFrames, int32_t framesPerBurst); int32_t framesPerBurst, int32_t requestedSampleRate, int32_t deviceSampleRate); private: Loading Loading
media/libaaudio/src/client/AudioStreamInternal.cpp +1 −6 Original line number Diff line number Diff line Loading @@ -134,12 +134,7 @@ aaudio_result_t AudioStreamInternal::open(const AudioStreamBuilder &builder) { request.getConfiguration().setInputPreset(getInputPreset()); request.getConfiguration().setPrivacySensitive(isPrivacySensitive()); // When sample rate conversion is needed, we use the device sample rate instead of the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the (sampleRate / deviceSampleRate) // scaling there. request.getConfiguration().setBufferCapacity(builder.getBufferCapacity() * 48000 / getSampleRate()); request.getConfiguration().setBufferCapacity(builder.getBufferCapacity()); mServiceStreamHandleInfo = mServiceInterface.openStream(request, configurationOutput); if (getServiceHandle() < 0 Loading
services/oboeservice/AAudioServiceEndpointMMAP.cpp +15 −0 Original line number Diff line number Diff line Loading @@ -243,6 +243,21 @@ aaudio_result_t AAudioServiceEndpointMMAP::openWithConfig( ALOGD("%s(format = 0x%X) deviceIds = %s, sessionId = %d", __func__, config->format, toString(getDeviceIds()).c_str(), getSessionId()); ALOGD("%s bufferCapacity = %d, deviceSampleRate = %d, requestedSampleRate = %d", __func__, getBufferCapacity(), config->sample_rate, getSampleRate()); const int32_t requestedSampleRate = getSampleRate(); const int32_t deviceSampleRate = config->sample_rate; // When sample rate conversion is needed, we use the device sample rate and the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the // (requestedSampleRate / deviceSampleRate) scaling there. if (requestedSampleRate != AAUDIO_UNSPECIFIED && requestedSampleRate != deviceSampleRate) { setBufferCapacity(static_cast<int64_t>(getBufferCapacity()) * deviceSampleRate / requestedSampleRate); } // Create MMAP/NOIRQ buffer. result = createMmapBuffer_l(); if (result != AAUDIO_OK) { Loading
services/oboeservice/AAudioServiceStreamShared.cpp +17 −2 Original line number Diff line number Diff line Loading @@ -76,7 +76,21 @@ std::string AAudioServiceStreamShared::dump() const NO_THREAD_SAFETY_ANALYSIS { } int32_t AAudioServiceStreamShared::calculateBufferCapacity(int32_t requestedCapacityFrames, int32_t framesPerBurst) { int32_t framesPerBurst, int32_t requestedSampleRate, int32_t deviceSampleRate) { if (requestedSampleRate != AAUDIO_UNSPECIFIED && requestedSampleRate != deviceSampleRate) { // When sample rate conversion is needed, we use the device sample rate and the // requested sample rate to scale the capacity in configureDataInformation(). // Thus, we should scale the capacity here to cancel out the // (requestedSampleRate / deviceSampleRate) scaling there. requestedCapacityFrames = static_cast<int64_t>(requestedCapacityFrames) * deviceSampleRate / requestedSampleRate; ALOGV("calculateBufferCapacity() scaled buffer capacity to %d frames, requested SR = %d" ", device SR = %d", requestedCapacityFrames, requestedSampleRate, deviceSampleRate); } if (requestedCapacityFrames > MAX_FRAMES_PER_BUFFER) { ALOGE("calculateBufferCapacity() requested capacity %d > max %d", Loading Loading @@ -168,7 +182,8 @@ aaudio_result_t AAudioServiceStreamShared::open(const aaudio::AAudioStreamReques } setBufferCapacity(calculateBufferCapacity(configurationInput.getBufferCapacity(), mFramesPerBurst)); mFramesPerBurst, configurationInput.getSampleRate(), getSampleRate())); if (getBufferCapacity() < 0) { result = getBufferCapacity(); // negative error code setBufferCapacity(0); Loading
services/oboeservice/AAudioServiceStreamShared.h +3 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,9 @@ protected: * @return capacity or negative error */ static int32_t calculateBufferCapacity(int32_t requestedCapacityFrames, int32_t framesPerBurst); int32_t framesPerBurst, int32_t requestedSampleRate, int32_t deviceSampleRate); private: Loading