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

Commit f7573c77 authored by guochuang's avatar guochuang Committed by Chuang Guo
Browse files

Nuplayer: Handle get input/output format errors cleanly



In NuplayerDecoder, after MediaCodec::configure() returns success,
it is assumed that MediaCodec is in CONFIGURED state.
But, after MediaCodec::configure() has returned success, the codec
may be recycled by the mediaresourcemanager and its status will be
set to released.
So, errors from MediaCodec::getInputFormat() and getOutputFormat()
need to be handled cleanly instead of assert checks.

Bug: 379989075
Test: MediaPlayerTest
Change-Id: Iaaa03fb264c6b8ba7c784a2c00111c8a5e6153a7
Signed-off-by: default avatarguochuang <guochuang@xiaomi.corp-partner.google.com>
parent aa1a64aa
Loading
Loading
Loading
Loading
+12 −3
Original line number Diff line number Diff line
@@ -358,9 +358,18 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
    }
    rememberCodecSpecificData(format);

    // the following should work in configured state
    CHECK_EQ((status_t)OK, mCodec->getOutputFormat(&mOutputFormat));
    CHECK_EQ((status_t)OK, mCodec->getInputFormat(&mInputFormat));
    err = mCodec->getOutputFormat(&mOutputFormat);
    if (err == OK) {
        err = mCodec->getInputFormat(&mInputFormat);
    }
    if (err != OK) {
        ALOGE("Failed to get input/output format from [%s] decoder (err=%d)",
                mComponentName.c_str(), err);
        mCodec->release();
        mCodec.clear();
        handleError(err);
        return;
    }

    {
        Mutex::Autolock autolock(mStatsLock);