Merge "stagefright: ACodec: read output port format on first frame" into nyc-dev
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index ed2abeb..bc11da2 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -253,6 +253,9 @@
sp<AMessage> mConfigFormat;
sp<AMessage> mInputFormat;
sp<AMessage> mOutputFormat;
+
+ // Initial output format + configuration params that is reused as the base for all subsequent
+ // format updates. This will equal to mOutputFormat until the first actual frame is received.
sp<AMessage> mBaseOutputFormat;
FrameRenderTracker mRenderTracker; // render information for buffers rendered by ACodec
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index fdb1a59..c9f16f0 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -2257,6 +2257,7 @@
err = setOperatingRate(rateFloat, video);
}
+ // NOTE: both mBaseOutputFormat and mOutputFormat are outputFormat to signal first frame.
mBaseOutputFormat = outputFormat;
// trigger a kWhatOutputFormatChanged msg on first buffer
mLastOutputFormat.clear();
@@ -5029,7 +5030,7 @@
}
void ACodec::onOutputFormatChanged() {
- // store new output format
+ // store new output format, at the same time mark that this is no longer the first frame
mOutputFormat = mBaseOutputFormat->dup();
if (getPortFormat(kPortIndexOutput, mOutputFormat) != OK) {
@@ -5812,6 +5813,10 @@
new AMessage(kWhatOutputBufferDrained, mCodec);
if (mCodec->mOutputFormat != mCodec->mLastOutputFormat && rangeLength > 0) {
+ // pretend that output format has changed on the first frame (we used to do this)
+ if (mCodec->mBaseOutputFormat == mCodec->mOutputFormat) {
+ mCodec->onOutputFormatChanged();
+ }
mCodec->addKeyFormatChangesToRenderBufferNotification(reply);
mCodec->sendFormatChange();
}