aaudio: fix ramp for volume smoothing
It was using numSamples instead of numFrames.
So timing was off.
Bug: 68804159
Test: raise and lower volume without clicking
Test: test_linear_ramp.cpp
Change-Id: I18b10dadbc47ab9cbe9c5aefd4e6197c50a0bedc
diff --git a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
index 1cf2c72..8d7a01e 100644
--- a/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalPlay.cpp
@@ -219,8 +219,7 @@
// Data conversion.
float levelFrom;
float levelTo;
- bool ramping = mVolumeRamp.nextSegment(framesToWrite * getSamplesPerFrame(),
- &levelFrom, &levelTo);
+ bool ramping = mVolumeRamp.nextSegment(framesToWrite, &levelFrom, &levelTo);
// The formats are validated when the stream is opened so we do not have to
// check for illegal combinations here.
// TODO factor this out into a utility function
diff --git a/media/libaaudio/src/utility/LinearRamp.h b/media/libaaudio/src/utility/LinearRamp.h
index ff09dce..2b1b8e0 100644
--- a/media/libaaudio/src/utility/LinearRamp.h
+++ b/media/libaaudio/src/utility/LinearRamp.h
@@ -87,7 +87,7 @@
std::atomic<float> mTarget;
- int32_t mLengthInFrames = 48000 / 50; // 20 msec at 48000 Hz
+ int32_t mLengthInFrames = 48000 / 100; // 10 msec at 48000 Hz
int32_t mRemaining = 0;
float mLevelFrom = 0.0f;
float mLevelTo = 0.0f;