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

Commit b5fd28ff authored by jiabin's avatar jiabin
Browse files

Advance client to match server position when preparing buffer for starting.

When stopping a stream, there can be stale data that hasn't been played.
The framework will erase the data memory to avoid playing stale data.
After erasing the data, advance client to match server position so that
the service side don't need to read stale data and cause the shared
mixer to run before the client writing data.

Bug: 391650832
Test: atest AAudioTests
Flag: EXEMPT bugfix
Change-Id: Ia46d3773c49b7b29f7ce23eda71692d193688bdd
parent 4a5f9716
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -108,6 +108,10 @@ void AudioStreamInternalPlay::prepareBuffersForStart() {
    mFlowGraph.reset();
    // Prevent stale data from being played.
    mAudioEndpoint->eraseDataMemory();
    // All data has been erased. To avoid mixer for the shared stream use stale
    // counters, which may cause the service side thinking stream starts flowing before
    // the client actually writes data, advance the client to match server position.
    advanceClientToMatchServerPosition(0 /*serverMargin*/);
}

void AudioStreamInternalPlay::prepareBuffersForStop() {