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

Commit 4b124770 authored by Avss Srikanth's avatar Avss Srikanth Committed by Arne Coucheron
Browse files

libmedia: Creating new sessionId when a dead IAudioTrack object is detected

-  Monkey: ToneGenerator: ToneGenerator init failed resulted in framework disconnect.
-  AudioFlinger could not create track because of a dead session id is used.
   As a result, AudioTrack failed to initialize Tonegenerator with the dead session.
-  Creating new sessionId when a dead IAudioTrack object is detected
   and also when the media server is killed in any state.

Change-Id: I9402bee89557846c80d13ba44a0f745c6cbd69c8
CRs-Fixed: 294151
parent 25bb0474
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -356,7 +356,7 @@ void AudioTrack::start()
        }

        if (mCblk->flags & CBLK_INVALID_MSK) {
            LOGW("start() track %p invalidated, creating a new one", this);
            LOGE("start() track %p invalidated, creating a new one", this);
            // no need to clear the invalid flag as this cblk will not be used anymore
            // force new track creation
            status = DEAD_OBJECT;
@@ -364,7 +364,8 @@ void AudioTrack::start()
            status = mAudioTrack->start();
        }
        if (status == DEAD_OBJECT) {
            LOGV("start() dead IAudioTrack: creating a new one");
            LOGE("start() dead IAudioTrack: creating a new one");
            mSessionId = 0;
            status = createTrack(mStreamType, mCblk->sampleRate, mFormat, mChannelCount,
                                 mFrameCount, mFlags, mSharedBuffer, getOutput(), false);
            if (status == NO_ERROR) {
@@ -848,8 +849,9 @@ status_t AudioTrack::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
                        cblk->lock.unlock();
                        result = mAudioTrack->start();
                        if (result == DEAD_OBJECT) {
                            LOGW("obtainBuffer() dead IAudioTrack: creating a new one");
                            LOGE("obtainBuffer() dead IAudioTrack: creating a new one");
create_new_track:
                            mSessionId = 0;
                            result = createTrack(mStreamType, cblk->sampleRate, mFormat, mChannelCount,
                                                 mFrameCount, mFlags, mSharedBuffer, getOutput(), false);
                            if (result == NO_ERROR) {
+2 −3
Original line number Diff line number Diff line
@@ -623,9 +623,8 @@ void MediaPlayer::notify(int msg, int ext1, int ext2)
        // ext1: Media framework error code.
        // ext2: Implementation dependant error code.
        LOGE("error (%d, %d)", ext1, ext2);
        if ( ext1 == MEDIA_ERROR_SERVER_DIED &&
                        mCurrentState == MEDIA_PLAYER_IDLE ) {
            LOGE("Mediaserver died in idle state");
        if ( ext1 == MEDIA_ERROR_SERVER_DIED ) {
            LOGE("Mediaserver died in %d state",mCurrentState);
            mAudioSessionId = AudioSystem::newAudioSessionId();
        }
        mCurrentState = MEDIA_PLAYER_STATE_ERROR;