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

Commit f8e6c453 authored by Karthik Reddy Katta's avatar Karthik Reddy Katta Committed by Linux Build Service Account
Browse files

libstagefright: Fix for video can't be played if BT is connected

-Issue: Video can't be played if BT is connected.
-Rootcause: Source code to handle fallback to software decoder
 if offload audio track creation fails is not present.
-Fix: Add source code to handle fallback to software decoder
 if offload audio track creation fails.

Change-Id: Ie136a2117dd3f028c962b8b73ebc238bc982d79b
CRs-Fixed:  593230
parent 8b3dc406
Loading
Loading
Loading
Loading
+52 −29
Original line number Diff line number Diff line
@@ -1018,33 +1018,7 @@ status_t AwesomePlayer::play_l() {
                    false /* sendErrorNotification */);

            if ((err != OK) && mOffloadAudio) {
                ALOGI("play_l() cannot create offload output, fallback to sw decode");
                int64_t curTimeUs;
                getPosition(&curTimeUs);

                delete mAudioPlayer;
                mAudioPlayer = NULL;
                // if the player was started it will take care of stopping the source when destroyed
                if (!(mFlags & AUDIOPLAYER_STARTED)) {
                    mAudioSource->stop();
                }
                modifyFlags((AUDIO_RUNNING | AUDIOPLAYER_STARTED), CLEAR);
                mOffloadAudio = false;
                mAudioSource = mOmxSource;
                if (mAudioSource != NULL) {
                    err = mAudioSource->start();

                    if (err != OK) {
                        mAudioSource.clear();
                    } else {
                        mSeekNotificationSent = true;
                        if (mExtractorFlags & MediaExtractor::CAN_SEEK) {
                            seekTo_l(curTimeUs);
                        }
                        createAudioPlayer_l();
                        err = startAudioPlayer_l(false);
                    }
                }
                 err = fallbackToSWDecoder();
            }

            if (err != OK) {
@@ -1108,6 +1082,40 @@ status_t AwesomePlayer::play_l() {
    return OK;
}

status_t AwesomePlayer::fallbackToSWDecoder() {
    int64_t curTimeUs;
    status_t err = OK;

    ALOGI("play_l() cannot create offload output, fallback to sw decode");
    getPosition(&curTimeUs);

    delete mAudioPlayer;
    mAudioPlayer = NULL;
    // if the player was started it will take care of stopping the source when destroyed
    if (!(mFlags & AUDIOPLAYER_STARTED)) {
        mAudioSource->stop();
    }
    modifyFlags((AUDIO_RUNNING | AUDIOPLAYER_STARTED), CLEAR);
    mOffloadAudio = false;
    mAudioSource = mOmxSource;
    if (mAudioSource != NULL) {
        err = mAudioSource->start();

        if (err != OK) {
            mAudioSource.clear();
        } else {
            mSeekNotificationSent = true;
            if (mExtractorFlags & MediaExtractor::CAN_SEEK) {
                seekTo_l(curTimeUs);
            }
            createAudioPlayer_l();
            err = startAudioPlayer_l(false);
        }
    }

    return err;
}

void AwesomePlayer::createAudioPlayer_l()
{
    uint32_t flags = 0;
@@ -1972,9 +1980,24 @@ void AwesomePlayer::onVideoEvent() {
    finishSeekIfNecessary(timeUs);

    if (mAudioPlayer != NULL && !(mFlags & (AUDIO_RUNNING | SEEK_PREVIEW))) {
        status_t err = startAudioPlayer_l();
        status_t err = startAudioPlayer_l(false /* sendErrorNotification */);
        if ((err != OK) && mOffloadAudio) {
            err = fallbackToSWDecoder();
        }

        if (err != OK) {
            ALOGE("Starting the audio player failed w/ err %d", err);
            ALOGE("Failed to fallback to SW decoder err = %d", err);
            notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);

            delete mAudioPlayer;
            mAudioPlayer = NULL;

            modifyFlags((PLAYING | FIRST_FRAME), CLEAR);

            if (mDecryptHandle != NULL) {
               mDrmManagerClient->setPlaybackStatus(
                       mDecryptHandle, Playback::STOP, 0);
            }
            return;
        }
    }
+1 −0
Original line number Diff line number Diff line
@@ -234,6 +234,7 @@ private:
    void postAudioTearDownEvent(int64_t delayUs);

    status_t play_l();
    status_t fallbackToSWDecoder();

    MediaBuffer *mVideoBuffer;