Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46ea3359 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "aaudio: set ramp frames based on sample rate"

parents 8e7bac6f 02fec70d
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -38,6 +38,18 @@ AudioStreamInternalPlay::AudioStreamInternalPlay(AAudioServiceInterface &servic

AudioStreamInternalPlay::~AudioStreamInternalPlay() {}

constexpr int kRampMSec = 10; // time to apply a change in volume

aaudio_result_t AudioStreamInternalPlay::open(const AudioStreamBuilder &builder) {
    aaudio_result_t result = AudioStreamInternal::open(builder);
    if (result == AAUDIO_OK) {
        // Sample rate is constrained to common values by now and should not overflow.
        int32_t numFrames = kRampMSec * getSampleRate() / AAUDIO_MILLIS_PER_SECOND;
        mVolumeRamp.setLengthInFrames(numFrames);
    }
    return result;
}

aaudio_result_t AudioStreamInternalPlay::requestPause()
{
    aaudio_result_t result = stopCallback();
@@ -45,7 +57,7 @@ aaudio_result_t AudioStreamInternalPlay::requestPause()
        return result;
    }
    if (mServiceStreamHandle == AAUDIO_HANDLE_INVALID) {
        ALOGE("AudioStreamInternal::requestPauseInternal() mServiceStreamHandle invalid = 0x%08X",
        ALOGE("requestPauseInternal() mServiceStreamHandle invalid = 0x%08X",
              mServiceStreamHandle);
        return AAUDIO_ERROR_INVALID_STATE;
    }
+2 −0
Original line number Diff line number Diff line
@@ -33,6 +33,8 @@ public:
    AudioStreamInternalPlay(AAudioServiceInterface  &serviceInterface, bool inService = false);
    virtual ~AudioStreamInternalPlay();

    aaudio_result_t open(const AudioStreamBuilder &builder) override;

    aaudio_result_t requestPause() override;

    aaudio_result_t requestFlush() override;