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

Commit 889ba33f authored by Shivaprasad Hongal's avatar Shivaprasad Hongal Committed by Steve Kondik
Browse files

stagefright: ExtendedStats: Fix ExtendStats AMessage dup crash.

AMessage setObject should not be called with NULL, as this would
cause a crash in dup(). Call AMessage setObject only if the
ExtendStats object is not NULL.

Change-Id: I61c88f820d5ff8d69e34ff0eef68bae2d28f4f52
parent 4e3496ba
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -1067,7 +1067,9 @@ sp<MediaSource> StagefrightRecorder::createAudioSource() {
        format->setInt32("time-scale", mAudioTimeScale);
    }

    if (mRecorderExtendedStats != NULL) {
        format->setObject(MEDIA_EXTENDED_STATS, mRecorderExtendedStats);
    }
    sp<MediaSource> audioEncoder =
            MediaCodecSource::Create(mLooper, format, audioSource);
    // If encoder could not be created (as in LPCM), then
@@ -1719,7 +1721,9 @@ status_t StagefrightRecorder::setupVideoEncoder(
        flags |= MediaCodecSource::FLAG_USE_SURFACE_INPUT;
    }

    if (mRecorderExtendedStats != NULL) {
        format->setObject(MEDIA_EXTENDED_STATS, mRecorderExtendedStats);
    }
    sp<MediaCodecSource> encoder =
            MediaCodecSource::Create(mLooper, format, cameraSource, flags);
    if (encoder == NULL) {
+6 −2
Original line number Diff line number Diff line
@@ -645,7 +645,9 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
            sp<AMessage> notify = new AMessage(kWhatRendererNotify, id());
            ++mRendererGeneration;
            notify->setInt32("generation", mRendererGeneration);
            if (mPlayerExtendedStats != NULL) {
                notify->setObject(MEDIA_EXTENDED_STATS, mPlayerExtendedStats);
            }
            mRenderer = new Renderer(mAudioSink, notify, flags);

            mRendererLooper = new ALooper;
@@ -1217,7 +1219,9 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) {
        *decoder = new Decoder(notify, mNativeWindow);
    }

    if (mPlayerExtendedStats != NULL) {
        format->setObject(MEDIA_EXTENDED_STATS, mPlayerExtendedStats);
    }

    (*decoder)->init();
    (*decoder)->configure(format);
+3 −1
Original line number Diff line number Diff line
@@ -156,7 +156,9 @@ void NuPlayer::Decoder::onConfigure(const sp<AMessage> &format) {
        // any error signaling will occur.
        ALOGW_IF(err != OK, "failed to disconnect from surface: %d", err);
    }
    if (mPlayerExtendedStats != NULL) {
        format->setObject(MEDIA_EXTENDED_STATS, mPlayerExtendedStats);
    }
    err = mCodec->configure(
            format, surface, NULL /* crypto */, 0 /* flags */);
    if (err != OK) {
+3 −1
Original line number Diff line number Diff line
@@ -460,7 +460,9 @@ status_t MediaCodecSource::initEncoder() {

    ALOGV("output format is '%s'", mOutputFormat->debugString(0).c_str());

    if (mRecorderExtendedStats != NULL) {
        mOutputFormat->setObject(MEDIA_EXTENDED_STATS, mRecorderExtendedStats);
    }
    status_t err = mEncoder->configure(
                mOutputFormat,
                NULL /* nativeWindow */,