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

Commit 48abde81 authored by Phil Burk's avatar Phil Burk
Browse files

aaudio: reset volume ramps to avoid start glitch

When started, the volume scaler was ramping down from
the level it was at when stopped.
This could cause a short noise.

The fix is to reset the flowgraph so that the ramps
start at their target value instead of ramping to them.

Note that this CL only updates the playback side
so that it can be more easily backported.

Bug: 296270351
Bug: 297132022
Test: use repro steps at b/296270351#comment14
Change-Id: I307b76972d56b49e338b1a07b3ed921e996f2050
parent bc5ff305
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -72,6 +72,12 @@ public:
     */
    int32_t pull(void *destination, int32_t targetFramesToRead);

    // Reset the entire graph so that volume ramps start at their
    // target value and sample rate converters start with no phase offset.
    void reset() {
        mSink->pullReset();
    }

    /**
     * Set numFramesToWrite frames from the source into the flowgraph.
     * Then, attempt to read targetFramesToRead from the flowgraph.
+4 −0
Original line number Diff line number Diff line
@@ -100,6 +100,10 @@ aaudio_result_t AudioStreamInternalPlay::requestFlush_l() {
}

void AudioStreamInternalPlay::prepareBuffersForStart() {
    // Reset volume ramps to avoid a starting noise.
    // This was called here instead of AudioStreamInternal so that
    // it will be easier to backport.
    mFlowGraph.reset();
    // Prevent stale data from being played.
    mAudioEndpoint->eraseDataMemory();
}