OSDN Git Service

When a recording session is stopped, no outstanding input video frames exist for...
authorJames Dong <jdong@google.com>
Mon, 20 Jun 2011 18:40:52 +0000 (11:40 -0700)
committerJames Dong <jdong@google.com>
Mon, 20 Jun 2011 19:09:49 +0000 (12:09 -0700)
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

media/libstagefright/OMXCodec.cpp

index c4fcc79..bb8a8be 100644 (file)
@@ -1983,7 +1983,14 @@ OMXCodec::BufferInfo* OMXCodec::dequeueBufferFromNativeWindow() {
 
 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 @@ void OMXCodec::on_message(const omx_message &msg) {
                     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 @@ void OMXCodec::on_message(const omx_message &msg) {
                     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);