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

Commit e827325f authored by Andy Hung's avatar Andy Hung
Browse files

audio: Treat PCM offload the same as compressed offload

Test: MediaPlayer PCM playback
Test: atest AudioTrackOffloadTest
Test: atest MediaPlayerTest
Test: atest CtsMediaAudioTestCases
Flag: EXEMPT bugfix
Bug: 357483620
Change-Id: Ib3b272a3d4571f2d23f2ac2e78a7c7d8c0b18b5c
parent 0ccf481d
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -2401,12 +2401,14 @@ nsecs_t AudioTrack::processAudioBuffer()
    int32_t flags = android_atomic_and(
        ~(CBLK_UNDERRUN | CBLK_LOOP_CYCLE | CBLK_LOOP_FINAL | CBLK_BUFFER_END), &mCblk->mFlags);

    const bool isOffloaded = isOffloaded_l();
    const bool isOffloadedOrDirect = isOffloadedOrDirect_l();
    // Check for track invalidation
    if (flags & CBLK_INVALID) {
        // for offloaded tracks restoreTrack_l() will just update the sequence and clear
        // AudioSystem cache. We should not exit here but after calling the callback so
        // that the upper layers can recreate the track
        if (!isOffloadedOrDirect_l() || (mSequence == mObservedSequence)) {
        if (!isOffloadedOrDirect || (mSequence == mObservedSequence)) {
            status_t status __unused = restoreTrack_l("processAudioBuffer");
            // FIXME unused status
            // after restoration, continue below to make sure that the loop and buffer events
@@ -2576,7 +2578,7 @@ nsecs_t AudioTrack::processAudioBuffer()
        mObservedSequence = sequence;
        callback->onNewIAudioTrack();
        // for offloaded tracks, just wait for the upper layers to recreate the track
        if (isOffloadedOrDirect()) {
        if (isOffloadedOrDirect) {
            return NS_INACTIVE;
        }
    }
@@ -2664,7 +2666,7 @@ nsecs_t AudioTrack::processAudioBuffer()
                __func__, mPortId, mRemainingFrames, avail, audioBuffer.frameCount, nonContig, err);
        if (err != NO_ERROR) {
            if (err == TIMED_OUT || err == WOULD_BLOCK || err == -EINTR ||
                    (isOffloaded() && (err == DEAD_OBJECT))) {
                    (isOffloaded && (err == DEAD_OBJECT))) {
                // FIXME bug 25195759
                return 1000000;
            }
@@ -2750,7 +2752,7 @@ nsecs_t AudioTrack::processAudioBuffer()
            // buffer size and skip the loop entirely.

            nsecs_t myns;
            if (audio_has_proportional_frames(mFormat)) {
            if (!isOffloaded && audio_has_proportional_frames(mFormat)) {
                // time to wait based on buffer occupancy
                const nsecs_t datans = mRemainingFrames <= avail ? 0 :
                        framesToNanoseconds(mRemainingFrames - avail, sampleRate, speed);
+4 −4
Original line number Diff line number Diff line
@@ -7151,7 +7151,7 @@ bool DirectOutputThread::checkForNewParameter_l(const String8& keyValuePair,
uint32_t DirectOutputThread::activeSleepTimeUs() const
{
    uint32_t time;
    if (audio_has_proportional_frames(mFormat)) {
    if (audio_has_proportional_frames(mFormat) && mType != OFFLOAD) {
        time = PlaybackThread::activeSleepTimeUs();
    } else {
        time = kDirectMinSleepTimeUs;
@@ -7162,7 +7162,7 @@ uint32_t DirectOutputThread::activeSleepTimeUs() const
uint32_t DirectOutputThread::idleSleepTimeUs() const
{
    uint32_t time;
    if (audio_has_proportional_frames(mFormat)) {
    if (audio_has_proportional_frames(mFormat) && mType != OFFLOAD) {
        time = (uint32_t)(((mFrameCount * 1000) / mSampleRate) * 1000) / 2;
    } else {
        time = kDirectMinSleepTimeUs;
@@ -7173,7 +7173,7 @@ uint32_t DirectOutputThread::idleSleepTimeUs() const
uint32_t DirectOutputThread::suspendSleepTimeUs() const
{
    uint32_t time;
    if (audio_has_proportional_frames(mFormat)) {
    if (audio_has_proportional_frames(mFormat) && mType != OFFLOAD) {
        time = (uint32_t)(((mFrameCount * 1000) / mSampleRate) * 1000);
    } else {
        time = kDirectMinSleepTimeUs;
@@ -7190,7 +7190,7 @@ void DirectOutputThread::cacheParameters_l()
    // no delay on outputs with HW A/V sync
    if (usesHwAvSync()) {
        mStandbyDelayNs = 0;
    } else if ((mType == OFFLOAD) && !audio_has_proportional_frames(mFormat)) {
    } else if (mType == OFFLOAD) {
        mStandbyDelayNs = kOffloadStandbyDelayNs;
    } else {
        mStandbyDelayNs = microseconds(mActiveSleepTimeUs*2);