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

Commit ec9a032c authored by Eric Laurent's avatar Eric Laurent
Browse files

AudioTrack: fix unwanted underrun when restarting

When restarting an AudioTrack from stopped state, it is necessary
to force refresh of mRemainingFrames by processAudioBuffer() as
the last write before stop() could be partial. No doing so will lead
into unnecessary sleep before filling the non contiguous part
of the buffer returned by obtainBuffer() when processAudioBuffer()
is executed for the first time after start().

Change-Id: Id703f8dc092a6f07c905eee194054b4a978f979d
parent 3bd3690f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -387,6 +387,9 @@ status_t AudioTrack::start()
    if (previousState == STATE_STOPPED || previousState == STATE_FLUSHED) {
        // reset current position as seen by client to 0
        mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition());
        // force refresh of remaining frames by processAudioBuffer() as last
        // write before stop could be partial.
        mRefreshRemaining = true;
    }
    mNewPosition = mProxy->getPosition() + mUpdatePeriod;
    int32_t flags = android_atomic_and(~CBLK_DISABLED, &mCblk->mFlags);