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

Commit 860eff19 authored by Chong Zhang's avatar Chong Zhang
Browse files

Make a copy of output format in onOutputFormatChanged

Make a copy of output format in NDK and camera's heic encoder.
(MediaCodec.java JNI is already making a copy, so copy out of
MediaCodec.cpp to avoid unnecessary dup)

bug:141140020
Change-Id: I8afb1e48b73f0fb2fa584bdee2b93985b48a5e91
parent 0f9e1f52
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -221,7 +221,13 @@ void CodecHandler::onMessageReceived(const sp<AMessage> &msg) {
                         break;
                     }

                     AMediaFormat *aMediaFormat = AMediaFormat_fromMsg(&format);
                     // Here format is MediaCodec's internal copy of output format.
                     // Make a copy since the client might modify it.
                     sp<AMessage> copy;
                     if (format != nullptr) {
                         copy = format->dup();
                     }
                     AMediaFormat *aMediaFormat = AMediaFormat_fromMsg(&copy);

                     Mutex::Autolock _l(mCodec->mAsyncCallbackLock);
                     if (mCodec->mAsyncCallbackUserData != NULL
+7 −2
Original line number Diff line number Diff line
@@ -1671,8 +1671,13 @@ void HeicCompositeStream::CodecCallbackHandler::onMessageReceived(const sp<AMess
                         ALOGE("CB_OUTPUT_FORMAT_CHANGED: format is expected.");
                         break;
                     }

                     parent->onHeicFormatChanged(format);
                     // Here format is MediaCodec's internal copy of output format.
                     // Make a copy since onHeicFormatChanged() might modify it.
                     sp<AMessage> formatCopy;
                     if (format != nullptr) {
                         formatCopy = format->dup();
                     }
                     parent->onHeicFormatChanged(formatCopy);
                     break;
                 }