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

Commit ae34ed2b authored by Haynes Mathew George's avatar Haynes Mathew George Committed by Glenn Kasten
Browse files

AudioTrack: Use original flags during track recreation



Also the OFFLOAD and DIRECT flags aren't denied by server.

authored-by: default avatarPavan <Chikkala&lt;pavanc@codeaurora.org>
Bug: 27554925
Change-Id: I6fd6b129928af4513bb0cba271019288605310f8
parent 63366697
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -949,9 +949,11 @@ protected:

    uint32_t                mUnderrunCountOffset;   // updated when restoring tracks

    audio_output_flags_t    mFlags;
        // const after set(), except for bits AUDIO_OUTPUT_FLAG_FAST and AUDIO_OUTPUT_FLAG_OFFLOAD.
        // mLock must be held to read or write those bits reliably.
    audio_output_flags_t    mFlags;                 // same as mOrigFlags, except for bits that may
                                                    // be denied by client or server, such as
                                                    // AUDIO_OUTPUT_FLAG_FAST.  mLock must be
                                                    // held to read or write those bits reliably.
    audio_output_flags_t    mOrigFlags;             // as specified in constructor or set(), const

    bool                    mDoNotReconnect;

+7 −24
Original line number Diff line number Diff line
@@ -455,7 +455,7 @@ status_t AudioTrack::set(
        mClientPid = pid;
    }
    mAuxEffectId = 0;
    mFlags = flags;
    mOrigFlags = mFlags = flags;
    mCbf = cbf;

    if (cbf != NULL) {
@@ -1153,6 +1153,9 @@ status_t AudioTrack::createTrack_l()
    audio_stream_type_t streamType = mStreamType;
    audio_attributes_t *attr = (mStreamType == AUDIO_STREAM_DEFAULT) ? &mAttributes : NULL;

    // mFlags (not mOrigFlags) is modified depending on whether fast request is accepted.
    // After fast request is denied, we will request again if IAudioTrack is re-created.

    status_t status;
    status = AudioSystem::getOutputForAttr(attr, &output,
                                           (audio_session_t)mSessionId, &streamType, mClientUid,
@@ -1211,7 +1214,6 @@ status_t AudioTrack::createTrack_l()
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied by client; transfer %d, "
                "track %u Hz, output %u Hz",
                mTransfer, mSampleRate, mAfSampleRate);
            // once denied, do not request again if IAudioTrack is re-created
            mFlags = (audio_output_flags_t) (mFlags & ~AUDIO_OUTPUT_FLAG_FAST);
        }
    }
@@ -1353,31 +1355,10 @@ status_t AudioTrack::createTrack_l()
                mAwaitBoost = true;
            }
        } else {
            ALOGV("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
            // once denied, do not request again if IAudioTrack is re-created
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %zu", frameCount);
            mFlags = (audio_output_flags_t) (mFlags & ~AUDIO_OUTPUT_FLAG_FAST);
        }
    }
    if (mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
        if (trackFlags & IAudioFlinger::TRACK_OFFLOAD) {
            ALOGV("AUDIO_OUTPUT_FLAG_OFFLOAD successful");
        } else {
            ALOGW("AUDIO_OUTPUT_FLAG_OFFLOAD denied by server");
            mFlags = (audio_output_flags_t) (mFlags & ~AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD);
            // FIXME This is a warning, not an error, so don't return error status
            //return NO_INIT;
        }
    }
    if (mFlags & AUDIO_OUTPUT_FLAG_DIRECT) {
        if (trackFlags & IAudioFlinger::TRACK_DIRECT) {
            ALOGV("AUDIO_OUTPUT_FLAG_DIRECT successful");
        } else {
            ALOGW("AUDIO_OUTPUT_FLAG_DIRECT denied by server");
            mFlags = (audio_output_flags_t) (mFlags & ~AUDIO_OUTPUT_FLAG_DIRECT);
            // FIXME This is a warning, not an error, so don't return error status
            //return NO_INIT;
        }
    }

    // Make sure that application is notified with sufficient margin before underrun.
    // The client's AudioTrack buffer is divided into n parts for purpose of wakeup by server, where
@@ -2089,6 +2070,8 @@ status_t AudioTrack::restoreTrack_l(const char *from)
        mStaticProxy->getBufferPositionAndLoopCount(&bufferPosition, &loopCount);
    }

    mFlags = mOrigFlags;

    // If a new IAudioTrack is successfully created, createTrack_l() will modify the
    // following member variables: mAudioTrack, mCblkMemory and mCblk.
    // It will also delete the strong references on previous IAudioTrack and IMemory.