When a recording session is stopped, no outstanding input video frames exist for the output buffers returned from OMX component to SF.
When this happens, default value of 0 will be used for the "decoding" time for these output buffers.
These buffers do not contain valid media data anyway.
related-to-bug: 4725803
Change-Id: I0eaf248bb2ac022ff072eaffd0ed3f21171f824e
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index c4fcc79..bb8a8be 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -1983,7 +1983,14 @@
int64_t OMXCodec::retrieveDecodingTimeUs(bool isCodecSpecific) {
CHECK(mIsEncoder);
- CHECK(!mDecodingTimeList.empty());
+
+ if (mDecodingTimeList.empty()) {
+ CHECK(mNoMoreOutputData);
+ // No corresponding input frame available.
+ // This could happen when EOS is reached.
+ return 0;
+ }
+
List<int64_t>::iterator it = mDecodingTimeList.begin();
int64_t timeUs = *it;
@@ -2152,11 +2159,6 @@
buffer->meta_data()->setInt32(kKeyIsUnreadable, true);
}
- if (mIsEncoder) {
- int64_t decodingTimeUs = retrieveDecodingTimeUs(isCodecSpecific);
- buffer->meta_data()->setInt64(kKeyDecodingTime, decodingTimeUs);
- }
-
buffer->meta_data()->setPointer(
kKeyPlatformPrivate,
msg.u.extended_buffer_data.platform_private);
@@ -2170,6 +2172,11 @@
mNoMoreOutputData = true;
}
+ if (mIsEncoder) {
+ int64_t decodingTimeUs = retrieveDecodingTimeUs(isCodecSpecific);
+ buffer->meta_data()->setInt64(kKeyDecodingTime, decodingTimeUs);
+ }
+
if (mTargetTimeUs >= 0) {
CHECK(msg.u.extended_buffer_data.timestamp <= mTargetTimeUs);